• Most new users don't bother reading our rules. Here's the one that is ignored almost immediately upon signup: DO NOT ASK FOR FANEDIT LINKS PUBLICLY. First, read the FAQ. Seriously. What you want is there. You can also send a message to the editor. If that doesn't work THEN post in the Trade & Request forum. Anywhere else and it will be deleted and an infraction will be issued.
  • If this is your first time here please read our FAQ and Rules pages. They have some useful information that will get us all off on the right foot, especially our Own the Source rule. If you do not understand any of these rules send a private message to one of our staff for further details.
  • Please read our Rules & Guidelines

    Read BEFORE posting Trades & Request

FFMPEG UHD colorspace conversion to rec709

FrameSniffer

Well-known member
Donor
Faneditor
Messages
127
Reaction score
161
Trophy Points
58
I'm trying to convert (unsuccessfully) a 4K Blu Ray MKV (BT.2020) to rec709, so that I have usable colorspace in Adobe premiere pro. I also need to retain the original 4K resolution.

first try:
ffmpeg -i "My.mkv" -c:v dnxhd -profile:v dnxhr_hqx "My.mov" - this essentially converts the KKV to dnxhd, without any changes. i.e. i end up with BT.2020

I've tried the following (based on few examples I found online) but this doesn't seem to change the colorspace. I think its because of the -x265 switch, which i'm assuming is reserved for h265 content and isn't compatible with dnxhd

ffmpeg -i "My.mkv" -c:v dnxhd -profile:v dnxhr_hq -x265-params "keyint=15:no-deblock=1" -pix_fmt yuv422p -sws_flags spline+accurate_rnd+full_chroma_int -color_range 1 -colorspace 1 -color_primaries 1 -color_trc 1 "My.mov"

Can anyone help?
 
Did you try a simple tonemap from HDR to SDR in StaxRip. It has some nice HDR tools filters, and you can export in prores. It's not perfect, but it works quite well, and it will build avisynth script for you. Did not use it in a while, as I pretty much import BT.2020 to Premiere directly, and color correct from there.
 
Did you try a simple tonemap from HDR to SDR in StaxRip. It has some nice HDR tools filters, and you can export in prores. It's not perfect, but it works quite well, and it will build avisynth script for you. Did not use it in a while, as I pretty much import BT.2020 to Premiere directly, and color correct from there.
Thanks I’ll check that out. I was hoping to find a native FFMPEG way to do it, to keep the quality loss to a minimum.
 
You could try using Shutter Encoder, which is basically a FFMPEG frontend and has a couple of pretty solid HDR-to-SDR options. It even has the option to export the commands for use directly in FFMPEG if you prefer.
I’d like to maintain HDR, so it’s not HDR to SDR unless you mean the colourspace of SDR?
 
Did you try a simple tonemap from HDR to SDR in StaxRip. It has some nice HDR tools filters, and you can export in prores. It's not perfect, but it works quite well, and it will build avisynth script for you. Did not use it in a while, as I pretty much import BT.2020 to Premiere directly, and color correct from there.

I've been struggling to get the perfect conversion for Blade Runner, but I've had some luck with others using Shutter. The only way I've gotten decent results is to choose the HDR to SDR conversion and then Rec 709 below it. My Handbrake HDR to SDR conversions all look terrible. I'll try that StaxRip next. Thanks @Mnm !
 
  • Like
Reactions: Mnm
when you say you want to retain HDR, do you mean you want to maintain the bits per pixel and the pixel values, but change the PQ curve into an sRGB gamma curve? I believe that would require tone mapping? I'm not versed in methods to actually do that, I'm just trying to clarify.
 
As far as I am aware, and in my limited experience, the answer to this would be yes. You cannot keep higher dynamic range if you constrict the color space from BT.2020 to BT.709, so you will loose the HDR. Tone mapping would always be required.

Not that there is anything wrong with BT.709, it's more than enough, in my opinion. I just like to work in BT.2020, 'cause why not... :)
 
As far as I am aware, and in my limited experience, the answer to this would be yes. You cannot keep higher dynamic range if you constrict the color space from BT.2020 to BT.709, so you will loose the HDR. Tone mapping would always be required.

Not that there is anything wrong with BT.709, it's more than enough, in my opinion.
rec709 is a colour curve though. applying a different curve to it only effects the data conversion to light levels. it doesn't remove any data. if the bits per pixel is the same then you still have the original data. The image would still be a 10bit image if you convert it to an appropriate 10bit format, it would just be presented badly without the correct colour curve. You still have the HDR data.
 
That might be the case, I will trust you on that. 'Did not encounter this information before, but then again, I did not go deeper into it, beyond making sure I can import native BT.2020 files in my projects. After that, pretty much did not care. :)
 
I've been reading about the standards and the implementations and I was thinking if your NLE supports it, it might be a good idea to convert from PQ to HLG.
I found a topic on Doom9 called "I Made a PQ to HLG Converter" but I won't link it as I'm not sure if it's safe.
PQ in HDR10 is an absolute curve, but HLG is relative and also allows for display on SDR screens, so it may help you to maintain as much data as possible and potentially have both SDR and HDR output. More reading is required though, and maybe you could experiment with it?
 
I've been reading about the standards and the implementations and I was thinking if your NLE supports it, it might be a good idea to convert from PQ to HLG.
I found a topic on Doom9 called "I Made a PQ to HLG Converter" but I won't link it as I'm not sure if it's safe.
PQ in HDR10 is an absolute curve, but HLG is relative and also allows for display on SDR screens, so it may help you to maintain as much data as possible and potentially have both SDR and HDR output. More reading is required though, and maybe you could experiment with it?
So in my use case, when I probed the colorspace info of the 4K blu ray, it’s listed as BT.2020… so for me converting to rec709 is the only viable option. Agree there might be other ways, depending on the source colorspace.

Shutter Encoder worked a treat for me. It converted BT.2029 to Rec709 very nicely. So that’s an MKV to DNxHR HQX, retaining the UHD resolution.
 
when you say you want to retain HDR, do you mean you want to maintain the bits per pixel and the pixel values, but change the PQ curve into an sRGB gamma curve? I believe that would require tone mapping? I'm not versed in methods to actually do that, I'm just trying to clarify.
Yes, I wanted to retain everything except the BT.2020 colorspace. I’m not sure if Shutter Encoder (Ffmpeg) tone maps as part of the conversion to rec709, I’ll check that tonight 😁
 
Ok so, when comparing the converted UHD MKV (BT.2020 to Rec.709) to a HD MVK of the same film, I noticed that the colours were way off, even though the converted UHD MVK look pretty good colour wise.

So I've gone with HDR to SDR colorspace conversation and the colorspace of the UHD MKV now matches the HD MKV...

Here is the FFMPEG command

ffmpeg -hide_banner -threads 0 -hwaccel auto -i "MY.mkv" -c:v dnxhd -profile:v dnxhr_hqx -pix_fmt yuv422p10 -filter_complex "[0:v]lut3d=file=LUTs/HDR-to-SDR.cube[out]" -map "[out]" -c:a pcm_s32le -ar 48k -map a? -sws_flags bicubic -vsync passthrough -metadata creation_time="2023-10-23T14:56:57.921436100Z" -y "MY.mov"
 
Back
Top Bottom