View Single Post
Old 11th March 2019, 20:31   #4  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by lansing View Post
So basically the entire description of the official colormatrix documentation is wrong?
It's from like 2004, of course it's wrong. You always need to check metadata to see what the input colorspace is, and that has always been true. Avisynth's ConvertToRGB has supported both rec601 and rec709 input for a long ass time now too.

Quote:
Originally Posted by lansing View Post
Does that mean there would still be a rec601->rec709 conversion but it would be taken care by the player automatically?
No. Again, Rec601/709 define what a set of YUV values translates to in RGB. The vast majority of computer monitors are fed with (s)RGB, so to correctly convert the encoded YUV to RGB for display, you need to know which YUV variant/colorimetry to use. In the bad old days, players would always assume Rec601 because that was the NTSC and PAL SDTV standard (they were in fact slightly different, bt470bg for PAL and bt470m/fcc for NTSC if you want to be pedantic about it, but I don't think anyone cares). If you had Rec709 YUV, you couldn't easily convert that to RGB correctly on playback, so people would use Colormatrix to convert their perfectly good YUV to slightly different YUV that would look correct when converted to RGB by something that assumed Rec601 colors.

This has not been necessary for least a decade now, since better video players and renderers that could handle both conversions (YUV/601->RGB and YUV/709->RGB) started to appear and effectively solved the problem. For the last few years the problem has instead been converting HDR to SDR on playback in a reasonable way, since most computer monitors can't really display HDR properly, but that's an entirely different story.

Quote:
Originally Posted by lansing View Post
So if I am to encode a dvd into x264 and playback on my computer, I shouldn't be doing the rec601->rec709 conversion in the script? But then how would the player knows what colorimetry to use on playback?
No, you should not. Instead you should set a metadata flag in the video stream that tells the decoder/player what the YUV values mean in RGB. Both DGSource and ffmpeg can show you similar metadata flag from your DVD's video stream, so you can tell what the source colorimetry is and carry it over through the conversion. If you're using an Avisynth script as input to x264 this won't be done by default since Avisynth doesn't have a way to output colorimetry metadata, so you need to use the --colormatrix option manually. If you're using a video file as input x264 can usually pick up the metadata automatically. There won't be a YUV-to-YUV conversion, but there will be a conversion to RGB for display, using the proper constants.

For DVD's/SD content in general that's good enough; for HDR or other more exotic colorspaces you need more metadata.

Here's an old thread I quickly googled up if you want some more info about the x264 options.

e: forgot to mention - if the video stream doesn't have any colorimetry metadata, some (many?) players will do a quick-and-dirty guess about the input colorimetry and assume Rec601 if the video's vertical resolution is SD-ish (less than 600 pixels tall, or so), and Rec709 if it's more than that.

Last edited by TheFluff; 11th March 2019 at 20:50.
TheFluff is offline   Reply With Quote