BT.709 colorspace discrepancies


#1

Hello everyone,

I’ve been struggling to get the colors of my videos for YouTube right for quite a while now. The colorspace, color_trc, color_primaries, color_range settings when exporting e.g. H.264 video do make a difference not only when uploading to YouTube but also with other media players. Also, most players show colors differently/incorrectly depending on their settings, e.g. whether they use GPU acceleration or not, which is also true for different web browsers when viewing HTML5 video. By “getting the colors right” I actually mean to merely maximize compatibility since there always seems to be some combination of settings which makes some browser misbehave and show colors incorrectly. I aim to make it look correctly at least on the most common browsers.

Although this general interoperability issue is a topic for itself, I would like to focus on one specific observation that I made and would like to ask whether this is a possible error in one of the software involved, or if it’s some oversight on my part.

YouTube appears to default to BT.709 matrix coefficients, transfer characteristics and color primaries (and limited/mpeg color range) if no more specific information is given in the metadata of the video being uploaded. This can be seen by uploading e.g. a RGB video using the utvideo codec or creating a slideshow of a color test image I provide below such that it’s up to YouTube to decide how to convert it to YUV. If you download the MP4 created by YouTube and take a look at the metadata using e.g. “mediainfo”, you will see that everything is set to BT.709. Also, the colors of the resulting video look (almost) perfect on most platforms like GPU-accelerated browsers or mplayer (for instance, measure the fully saturated RGB colors in the resulting video, they should be almost perfectly 255,0,0; 0,255,0; 0,0,255).

Since the default for YouTube seems to be BT.709, I would like to have a workflow with shotcut to generate BT.709 videos for uploading to YouTube, but there is an issue:

If I import the color test image into shotcut and set the profile to use the BT.709 color space, export a clip of the image using libx264 and either upload the result to YouTube or view it in mplayer, the fully saturated colors are incorrect. For instance, the fully saturated green is rather something like 19,255,6 in RGB (too bright) while the red is something like 232,0,1 (too dark). Taking a look at the metadata of the video, the color primaries property is not set, but even adding “color_primaries=bt709” manually in the export settings of shotcut doesn’t seem to make a difference to the resulting colors.

So my question is whether this is a possible problem with color conversion in shotcut or mlt regarding the BT.709 color space. It should be noted that this is not limited to the color test image as input – the colors of other input videos, also in other color spaces, yield similar results, but I wanted to focus on one particular scenario that might be useful for reproducing the problem.

Let me know if I should provide more details.

EDIT: I tried to create a BT.709 video using only ffmpeg and it seems to work fine, at least the colors look correct to me and different from what shotcut outputs. Example command line to generate a video from the test image using ffmpeg 3.2.1 as reference:

ffmpeg -loop 1 -i OchiColorTest_v2.png -c:v libx264 -colorspace bt709 -color_trc bt709 -to 0:10 output.mp4


#2

You need a proper test pattern and a measuring tool such as Colorzilla, and you shouldn’t be relying on .png images for color accuracy. Use .bmp images instead. Don’t try to eyeball color errors; use a measuring tool. Also check your assumptions about Firefox defaulting to bt.709 and any color encoding performed by YouTube. I understand Gecko-based browsers such as Firefox default to bt.601.

Below are links to two test patterns, both encoded with ffmpeg from a .bmp image, one encoded to bt.601 and the other to bt.709. In my testing the colors of the 601 test pattern are accurate to +/- 2 when played on Firefox, while the 709 colors are way off. This suggests that Firefox defaults to bt.601. You’re not going to get accuracy better than +/- 2 due to the floating-point values used in the YUV conversion. This test calls into question whether YouTube alters the colors in any significant way. Further, Microsoft Edge and VLC player render the colors of the 709 pattern accurately so apparently they default to 709.

sRGB is the IEC standard for web color and it calls for bt.709 coefficients. The developers of Firefox, Chrome, Chromium and Opera need to get with it and make their browsers sRGB compliant and default to bt.709 coefficients.