[FFmpeg-user] preserving YUV color range of 0-255

Dave Rice dave at dericed.com
Fri Mar 7 17:42:18 CET 2014


I'm having trouble preserving YUV color range of 0-255 through a filter chain. For my tests below I'm using this test pattern http://dericed.com/media/256shades_ntsc.mov (the test video provides vertical columns of all 256 possible values for Y with U and V always at 128. The 256 Y shades are delimited by columns of white and black to separate them into units of 4 and 16).

Given that the test pattern has U and V at 128 I would expect these two commands to give the same results:

ffplay 256shades_ntsc.mov -vf 'histogram=mode=waveform:waveform_mode=column'
ffplay 256shades_ntsc.mov -vf 'extractplanes=y,histogram=mode=waveform:waveform_mode=column'

But the latter one shows the luma values are condensed to 16-235 before plotting, so data goes into extractplanes as 0-255 but comes out as 16-235. Is there a workaround, I'd like to preserve the color range of each planes but utilize extractplanes. I tried experimenting with using -color_range and format before extractplanes but got the same results.

Similar example, this visualized what data is in the 8th bit of the samples:
ffplay 256shades_ntsc.mov -vf 'lut=c0=bitand(val\,pow(2\,8-8))*pow(2\,8):c1=128:c2=128'

if I want to restrict that to the Y channel only (which should be the same in the sample since there is no chroma), then I'd like to add extractplanes=y, but then the output is different since the sample which contains all 256 values for Y are squeezed down to 16-235. Such as:

ffplay 256shades_ntsc.mov -vf 'extractplanes=y,lut=c0=bitand(val\,pow(2\,8-8))*pow(2\,8)'

I'm testing carefully to make sure I'm using filterchains that preserve the values without inadvertently adding a 0-255 to 16-235 squeeze. But is there a better workaround, is there a way to start the filterchain by saying to subsequent filters that I want these values preserved or is extractplanes not safe to use if I want to avoid a color range squeeze?

More information about the ffmpeg-user mailing list