[FFmpeg-user] YUV->RGB conversion. What is the default matrix used?
nichot20 at yahoo.com
Wed Jul 4 18:20:44 CEST 2012
On 04/07/12 15:31, Mike Scheutzow wrote:
> Tim Nicholson wrote:
>> Although we now have the "colormatrix" filter to convert between
>> different YUV colorspace standards it occurs to me that it is not clear
>> what matrixing is used by default when converting between YUV and RGB.
>> A quick test using:-
>> ffmpeg -i bars-601.mov -t 1 -an -r 1 %04d-601.png
>> and an inspection of the resultant png shows RGB values of the bars to
>> differ from the values expected if using the 601 matrix values, and even
>> a grey scale has significant colour casting at certain levels.
>> So it begs the question, what coefficients are being used by default?
> As near as I can tell from the code, and from the command:
> ./ffmpeg -i test.mov -vframes 1 out%d.png
> the default colorspace for yuv->rgb conversion is:
> /* ITU-R Rec. 624-4 System B, G */
> This is chosen in sws_getContext() in libswscale/utils.c.
Ahh I wondered where it was... Thanks
I have been looking at libswscale/yuv2rgb.c and noticed that 601 wasn't
even defined in the list of coefficients there. However I am struggling
to understand the coefficients as listed there as they don't match any
figures I am use to, and there are 4 of them not the expected three, as
> I found no way to select a different colorspace from the ./ffmpeg
> command line.
No, unfortunately, and also the colormatrix filter doesn't allow
conversion to that standard either, which would have been a workaround.
If I could relate the coefficients as defined in the two files above I
might be able to add 634/smpte 170m (they use the same values) to
colormatrix to provide a workaround...
> Mike Scheutzow
More information about the ffmpeg-user