[FFmpeg-user] ffmpeg MP4/x264 output colours change when input source is different resolution (bug?)

Erik Dobberkau erik.dobberkau at gmail.com
Fri Sep 16 17:51:22 EEST 2022


> I know enough to say I can't wait until everyone can unify under a single
> colour space/profile, scrap YUV, scrap chroma subsampling and go with RGB.
> Disk space and bandwidth is getting cheaper and cheaper after all.


Unfortunately it’s not that simple, please see below.

Haha, okay let's put egos aside. Michael recommended I try going
> through the various colour spaces, so that's what I did. And hey, FCC
> worked for me!
> What might go wrong if I stick with this technique?
>

A lot. Please see below.


> FCC colorspace is not correct way to represent encoded material.
>>
>> Use -color_range flags.
>>
>
> Why didn't you recommend this originally? Anyway, *finally* found docs for
> it
> under the codecs section: https://ffmpeg.org/ffmpeg-codecs.html
>
> I tried all of them: "tv", "mpeg", "pc", "jpeg". Here's the line I used:
>
> ffmpeg.exe -i testchart.tif -color_range mpeg -crf 0 -vcodec libx264
> -pix_fmt yuv420p output-mpeg.mp4
>
> Unfortunately, colours are still muted/changed:
> https://i.imgur.com/H7GzYS4.png
>
> Am I supposed to combine it with another CLI argument?
>

Apart from width, height, PAR, DAR and SAR, bit depth and subsampling
method, the color encoding parameters are responsible for the visual
representation of an image: color space, primaries, white point, transfer
function, color range, and color matrix (if something other than RGB
encoding is used). There are typical combinations which have been used over
the course of history (and they were created for practical reasons), and
there are many cases (i.e., video streams stored in files) in which the
parameters were set wrong and are hard and sometimes impossible to fix (in
a lossless way). Therefore, it’s important to know the parameters or
characteristics of your source image(s), and the same goes for your output
image(s), so they may likely be needed to be set manually to achieve the
desired results.

Thinking RGB would be the remedy for everything is simply a bit naive (no
offense intended), because even RGB may (quite likely) not be one and the
same in any given case.

Erik


More information about the ffmpeg-user mailing list