Log in

View Full Version : FFMPEG, colorimetry conversion advice


Keiyakusha
31st December 2015, 21:10
Hey guys. Can you please suggest me what commandline I should use. I am trying to figure out the right one but FFMPEG's documentation is kinda lacking.

Here is a sample commandline:
ffmpeg -i <input> -vcodec <any> -an <output>

<input> is a some kind of RGB source. Let's assume UTvideo rgb24 for simplicity
<any> is any YUV codec but for this case we assume it expects 4:2:2 8bit input
<output> Container format hardly matters here.

Question: how do I modify this commandline so that <input> will be converted to fullrange YUV 4:2:2 using bt709 coefficients before encoding it?
Also i need to be sure it is converted to fullrange, not converted to limited range and then expanded via postprocessing.

I know there is a -vf colormatrix switch, but it requires specifying input and output coefficients, which doesn't makes much sense for rgb input and I don't see a way to force fullrange conversion.

Follow-up question: What it would look like if the input is 4:4:4 YUV fullrange?

sneaker_ger
31st December 2015, 22:26
-vf scale=out_color_matrix=bt709:out_range=full:ohsub=2:ovsub=1

?

/edit:
Oh, ffmpeg does not recognize ohsub despite it being in the documentation. :( (Or maybe it's just my binary) Maybe you can just use -pix_fmt instead for the subsampling, though.

Keiyakusha
1st January 2016, 01:48
-vf scale=out_color_matrix=bt709:out_range=full:ohsub=2:ovsub=1

?

/edit:
Oh, ffmpeg does not recognize ohsub despite it being in the documentation. :( (Or maybe it's just my binary) Maybe you can just use -pix_fmt instead for the subsampling, though.

Thanks! This seem to be working (haven't tried ohsub/ovsub).
Also if codec _expects_ some specific pixel format as input, manually setting pixel format doesn't seem to be required at all. Edit: oh never mind, it is better to set it I guess, to avoid possible issues with bitdepth and whatnot

pandy
4th January 2016, 11:25
My experience with ffmpeg shows that internal signal flow ignore even explicit colour space and format, only format selected for output is used during processing chain.

I suggest to use separate filters instead scale options.

http://ffmpeg.org/ffmpeg-filters.html#colorlevels
http://ffmpeg.org/ffmpeg-filters.html#colormatrix
http://ffmpeg.org/ffmpeg-filters.html#lut_002c-lutrgb_002c-lutyuv
http://ffmpeg.org/ffmpeg-filters.html#lut3d-1

etc.

This is one of most annoying things in ffmpeg - sometimes it is too smart".