this refers to CESNET/UltraGrid#341
hi, when QSV is compressing from a RGB format (BGRA for now; but applies also to X2RGB), it converts unconditionally to limited-range YUV BT.601, but sets stream metadata according to AVCodecContext::color_primaries and AVCodecContext::color_range. If those are not set explicitly, it sets full-range to metadata, anyways.
Please see following test case:
-
input
ffmpeg -y -f lavfi -i color=#ff0000 -t 1 -pix_fmt bgra [params] -c:v hevc_qsv out.h265
-
output evaluation
mediainfo --Language=raw --Full --Inform='Video;%matrix_coefficients%,%colour_range%' out.h265 &&
ffmpeg -y -loglevel quiet -i out.h265 -strict -1 -frames 1 out.y4m; sed '1,2d' < out.y4m | od -t x1
input RGB=[0xff,0x00,0x00] corresponds¹ to full-range YCbCr BT.601 [76,85,255]=[0x4c,0x55,0xff], limited range [65,91,237]=[0x51,0x5b,0xed] ²
¹ computed using this coefficient; Cb,Cr coefficients are offset by 128
² or Y=67=0x53 if using Y range 16-240, which I think is correct
evaluation:
- no params for 1. above - [0x51,0x5b,0xef], mediainfo: ",Full"
-colorspace bt709 - [0x51,0x5b,0xef], mediainfo: "BT.709,Full"
-colorspace bt709 -color_range tv- (ditto), mediainfo: "BT.709,Limited"
-color_range tv - (ditto), mediainfo: ",Limited"
-colorspace smpte170m -color_range tv - (ditto), mediainfo: "BT.601,Limited"
So, in all cases, the output is in limitted-range YCbCr 601, but metadata are correct only in case 5 (and also 4, assuming that implicit value is OK).
PS: -vf lavfi -i color=#ff0000 -t 1 -pix_fmt bgra seems to convert to [0x00,0x00,0xfd,0xff] - the swscale conversion is not entirely accurate but I don't know how to produce single-color RGB directly, without conversion from YUV (-vf lavfi -i color produces YUV)
this refers to CESNET/UltraGrid#341
hi, when QSV is compressing from a RGB format (BGRA for now; but applies also to X2RGB), it converts unconditionally to limited-range YUV BT.601, but sets stream metadata according to AVCodecContext::color_primaries and AVCodecContext::color_range. If those are not set explicitly, it sets full-range to metadata, anyways.
Please see following test case:
input
ffmpeg -y -f lavfi -i color=#ff0000 -t 1 -pix_fmt bgra [params] -c:v hevc_qsv out.h265output evaluation
input RGB=[0xff,0x00,0x00] corresponds¹ to full-range YCbCr BT.601 [76,85,255]=[0x4c,0x55,0xff], limited range [65,91,237]=[0x51,0x5b,0xed] ²
¹ computed using this coefficient; Cb,Cr coefficients are offset by 128
² or Y=67=0x53 if using Y range 16-240, which I think is correct
evaluation:
-colorspace bt709- [0x51,0x5b,0xef], mediainfo: "BT.709,Full"-colorspace bt709 -color_range tv- (ditto), mediainfo: "BT.709,Limited"-color_range tv- (ditto), mediainfo: ",Limited"-colorspace smpte170m -color_range tv- (ditto), mediainfo: "BT.601,Limited"So, in all cases, the output is in limitted-range YCbCr 601, but metadata are correct only in case 5 (and also 4, assuming that implicit value is OK).
PS:
-vf lavfi -i color=#ff0000 -t 1 -pix_fmt bgraseems to convert to [0x00,0x00,0xfd,0xff] - the swscale conversion is not entirely accurate but I don't know how to produce single-color RGB directly, without conversion from YUV (-vf lavfi -i colorproduces YUV)