FastFlix icon indicating copy to clipboard operation
FastFlix copied to clipboard

[SUGGESTION] FFMPEG color space "legalization"

Open MarcoRavich opened this issue 4 years ago • 2 comments

This feature will help all videomakers to "legalize" color space produced by their cameras for broadcast standard.

All started from this discussion started by me for solving the problem with "Canon HF100 colorspace".

After evaluating a clip, Gyan (an FFMPEG maintainer) suggested me:

You can use the geq filter to remap the pixel value ranges.

ffmpeg -i input -vf "geq=lum='(p(X,Y)-16)/(255-16)*(235-16)+16':cb='(p(X,Y)-16)/(255-16)*(240-16)+16'" -c:v libx264 -c:a copy out.mp4

The geq filter rescales the input luma from 16-255 to 16-235, and both the input chroma from 16-255 to 16-240, which is the legal range for broadcast 8-bit signals.

Hope that inspires !

MarcoRavich avatar Apr 28 '21 08:04 MarcoRavich

That could be a nice thing to add under the advanced section. Would also need to figure out the equivalent for 10-bit videos.

cdgriffith avatar Apr 29 '21 01:04 cdgriffith

BT.2100 eq signal:

Luma Narrow range D = Round [(219 x E′ + 16) x 2^(n−8) ] Chroma Narrow range D = Round [(224 x E′ + 128) x 2^(n−8)]

so just multiply by 2^(n-8) for 10 or 12 bit since for 8 bit the last term is 1;

brunogm0 avatar Mar 26 '22 19:03 brunogm0