I'm trying to overlay some subs on an .mp4 file using the following command:

ffmpeg -y -i count5.mp4 -i subs1.png -i subs2.png \
-filter_complex "[0][1]overlay=enable=between(t\,1\,2):x=0:y=0[out]; \
[out][2]overlay=enable=between(t\,3.5\,4.6):x=0:y=0[out]" \
-map [out] -map 0:a? new.mp4

It works, but the subtitle colors are not correct: Here is the overlay:

enter image description here

Here is how it looks on the .mp4 output:

enter image description here

Looks like it turned a little pink or orange. Maybe the better question is how do I maintain the correct video quality? I have very limited knowledge of video formats and ffmpeg so not sure where to start debugging or the right keywords to use.

Finder tells me the png is color profile sRGB IEC61966-2.1 and the video is HD (1-1-1)

Here's a link to the files

  • Is it reproducible with only one overlay stage (instead of overlaying twice)? Can you please share subs1.png, subs2.png and small part of count5.mp4 (share using Google Drive for example)?
    – Rotem
    Commented Aug 14, 2023 at 19:24
  • @Rotem hi yes, I've updated the question with a link to the files stored in Google Drive
    – PGT
    Commented Aug 15, 2023 at 3:34

1 Answer 1


The issue resembled the issue described in the following post.

In out case, the pixel format of subs1.png and subs2.png is RGBA (applies sRGB standard with alpha transparency channel).

The pixels format of count5.mp4 is "limited range" yuv420p in BT.709 standard.
The output video new.mp4, keeps the BT.709 characteristics.
We may see these details using MediaInfo tool.

As described in my other answer, FFmpeg always assume BT.601 color characteristics, and doesn't convert to BT.709 when it should.

The solution is converting the color format of the PNG images to BT.709 using scale filter:

ffmpeg -y -i count5.mp4 -i subs1.png -i subs2.png -filter_complex "[1]scale=out_color_matrix=bt709:dst_format=yuva420p[v1];[2]scale=out_color_matrix=bt709:dst_format=yuva420p[v2];[0][v1]overlay=enable=between(t\,1\,2):x=0:y=0[out];[out][v2]overlay=enable=between(t\,3.5\,4.6):x=0:y=0[out]" -map [out] -map 0:a? new.mp4

For getting better text quality, we may avoid chroma subsampling and use yuv444 instead of yuv420 (note that I don't know if your target application can handle yuv444 pixel format):

ffmpeg -y -i count5.mp4 -i subs1.png -i subs2.png -filter_complex "[1]scale=out_color_matrix=bt709:dst_format=yuva444p[v1];[2]scale=out_color_matrix=bt709:dst_format=yuva444p[v2];[0][v1]overlay=enable=between(t\,1\,2):x=0:y=0:format=yuv444[out];[out][v2]overlay=enable=between(t\,3.5\,4.6):x=0:y=0:format=yuv444[out]" -map [out] -map 0:a? -c:v libx264 -crf 17 -pix_fmt yuv444p new.mp4

Examining the color using paint.net:

enter image description here

Frame from new.mp4:
enter image description here

As we can see, the output has almost the same color values as the input.

  • I would never had guessed that you can manage color options with the scale filter.... Commented Aug 15, 2023 at 9:16
  • thanks, let me try this out, this is some crazy stuff lol
    – PGT
    Commented Aug 17, 2023 at 2:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .