This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

[HELP] "BT.709 or BT.2020?" But…
#1
Video 
I don't usually do this thing with 4K 10-bit HEVC MKV videos but right now I do need to downgrade one of them in my hard disk to a 4K 8-bit H264 MP4 video due to compatibility issues with playing on this one old laptop that I decided to turn it into somekind of a "slave device"

Problem here is when directly encoding it with FFMPEG while only explicitly specifying -c:v libx264 -preset:v medium, the encoded MP4 had the color noticably darker and green-ish.

I'm thinking that this has something to do with downgrading from 10-bit to 8-bit color depth and maybe because FFMPEG preserved the matrix coefficient flag at bt2020nc and it made my player (MPC-HC 64-bit from K-Lite Codec Mega Pack thingy) think that it has to use bt2020nc matrix to convert the bits to RGB back. As far as I have read about BT2020, it's a matrix for UHD 10-bit YUV videos.

So I thought maybe because the encoded video is 8-bit and the player is doing its stuff by using BT2020 matrix causes the color changes, and that's when I thought maybe I could add something like -vf scale=out_color_matrix=bt709 and reset the flag for matrix coefficient explicitly to bt709 just to "make sure" that my player won't mess up with the color conversion but then I'm not sure about that since I'm quite new to this color space and pixel format stuffs but I've also done tons of reading already; I'm just not sure, so I thought maybe I could post a thread here for a quick help? Cuz this is a damned 2-hour movie and I don't want to waste my time on testing things even on "ultrafast" preset

So, what's the real problem here? Color matrix?
If it's really just the color matrix then in my case, what should I do and to what should I set it to?
And when exactly, like EXACTLY, should I use the matrix BT2020? Does it entirely depend only on the resolution/size, or both the resolution/size and bit depth?
Reply
#2
Quote:had the color noticably darker and green-ish.
might be a tv (16-235) vs. pc (0-255) scale issue.

Quote:So, what's the real problem here? Color matrix?
I doubt it's a color matrix issue unless the player doesn't support the matrix or ignores it and always uses the same matrix (or the same depending on the resolution).
-> if you want to change the color matrix:
a. use Color Matrix filter (https://www.ffmpeg.org/ffmpeg-all.html#toc-colormatrix to convert from one to another color matrix)
b. make sure to properly set the vui settings (color matrix, color range, color primaries)
-color_range XXX -colorspace XXX -color_primaries XXX -color_trc XXX


-> read
a. https://trac.ffmpeg.org/wiki/colorspace is also has some examples.
b. https://www.ffmpeg.org/ffmpeg-all.htm for details on the options

Usually ITU-R recommends for:
1. HDR and UHD content BT.2020
2. SDR and FullHD content BT.709
but there's also UHD content with BT.709 and SDR content with BT.601 or other color matrixes, so there is no strict you need to use color matrix xy for resolution A or B. (Side note: when doing HDR to SDR conversions tome mapping is recommended.)
Problem is not all players support all matrices and some always assume BT.2020 requires HDR which it doesn't. SDR content can have a WCG (wide color gamut, see: https://en.wikipedia.org/wiki/Rec._2020) and you can have WCG without HDR (high dynamic range).
iirc. (not totally sure) to take full advantage of BT.2020 10bit or higher is required (it is for HDR), but it should be possible with 8bit.

-> I would use BT.709 for SDR content independent of the resolution.
And recommend to use BT.2020 only for HDR content (independent of the resolution).

Cu Selur
Reply
#3
(01.01.2021, 20:29)Selur Wrote:
Quote:had the color noticably darker and green-ish.
might be a tv (16-235) vs. pc (0-255) scale issue.

Quote:So, what's the real problem here? Color matrix?
I doubt it's a color matrix issue unless the player doesn't support the matrix or ignores it and always uses the same matrix (or the same depending on the resolution).
-> if you want to change the color matrix:
a. use Color Matrix filter (https://www.ffmpeg.org/ffmpeg-all.html#toc-colormatrix to convert from one to another color matrix)
b. make sure to properly set the vui settings (color matrix, color range, color primaries)
-color_range XXX -colorspace XXX -color_primaries XXX -color_trc XXX


-> read
a. https://trac.ffmpeg.org/wiki/colorspace is also has some examples.
b. https://www.ffmpeg.org/ffmpeg-all.htm for details on the options

Usually ITU-R recommends for:
1. HDR and UHD content  BT.2020
2. SDR and FullHD content BT.709
but there's also UHD content with BT.709 and SDR content with BT.601 or other color matrixes, so there is no strict you need to use color matrix xy for resolution A or B. (Side note: when doing HDR to SDR conversions tome mapping is recommended.)
Problem is not all players support all matrices and some always assume BT.2020 requires HDR which it doesn't. SDR content can have a WCG (wide color gamut, see: https://en.wikipedia.org/wiki/Rec._2020) and you can have WCG without HDR (high dynamic range).
iirc. (not totally sure) to take full advantage of BT.2020 10bit or higher is required (it is for HDR), but it should be possible with 8bit.

-> I would use BT.709 for SDR content independent of the resolution.
And recommend to use BT.2020 only for HDR content (independent of the resolution).

Cu Selur

Ahh, so it wasn't really color matrix. I did suspect it was the color range since despite the MediaInfo reporting both my input and output is at TV/Limited range, I am aware that these are just flags and it don't always reflects the exact properties of the content (the input could've been at PC/Full but this is a movie but then again this is at 10-bit depth…ahh that's where I missed *realizes by the time of writing)
I end up trying to mess with the matrix thinking it would fix everything just because I thought it was the  that should change according to bit depth, damnit

Okay so you suggest that I can convert the color matrix using the colormatrix filter. What about scale? I kinda prefer that more. It should not make any difference, right? I'm just utilizing them to convert between matrices

Also, assuming I'll use scale, I'm thinking of doing -vf scale=in_range=pc:out_range=tv hoping it would fix this color shifting issue. Unless I'm wrong, I think converting to a different 8-bit color range would prevent players from misinterpreting things. Or am I being an idiot again for not putting out_range=pc instead? Or is this whole idea pointless once again? Assume I will properly set the flags

Lastly, thank you for providing references and elucidation for matrices BT709 and BT2020. Will definitely check them out (for my own sake anyways)
So I can use any matrices where most of the time I can just pick BT709. But when I want to experience a full color range video with HDR, I should choose BT2020 at 10-bit color depth (at least?), I see

Thank you for replying, you're the beast (yes, beast)
Reply
#4
Quote:Okay so you suggest that I can convert the color matrix using the colormatrix filter. What about scale? I kinda prefer that more. It should not make any difference, right?
Yes, Color matrix changes through scale should work too.
Important remember to also change the vui flags otherwise your content will still be displayed wrong.

Quote: -vf scale=in_range=pc:out_range=tv hoping it would fix this color shifting issue. Unless I'm wrong, I think converting to a different 8-bit color range would prevent players from misinterpreting things. Or am I being an idiot again for not putting out_range=pc instead? Or is this whole idea pointless once again? Assume I will properly set the flags
-vf scale=in_range=pc:out_range=pc
should do nothing, so using it doesn't make sense. Smile

Quote:So I can use any matrices where most of the time I can just pick BT709. But when I want to experience a full color range video with HDR, I should choose BT2020 at 10-bit color depth (at least?), I see
Main points are:
a. stick with BT.2020 for HDR content
b. when your SDR content is > SD use BT.709 and make sure to properly to any color space conversions and adjust the vui flags accordingly to you changes
c. if your input content isn't properly flagged make sure you don't mess the conversion up
d. when doing HDR to SDR conversion, use a tone mapping filter and adjust the flags properly

Cu Selur
Reply
#5
I see. Thank you very much Selur
And wishing you a Happy New Year!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)