How to convert hdr 4k file to sdr 4k file with handbrake

General questions or discussion about HandBrake, Video and/or audio transcoding, trends etc.
Post Reply
dj02
Posts: 2
Joined: Fri May 10, 2019 7:18 am

How to convert hdr 4k file to sdr 4k file with handbrake

Post by dj02 » Fri May 10, 2019 7:36 am

Description of problem or question:
I cant seem to find a way to convert hdr file to sdr file with handbrake. If i first just do an basic convert with handbrake and then with ffmpeg commandline i do the hdr -> sdr convert with command:
ffmpeg.exe -i How To Train Your Dragon-Seg Mainfeature Hdr-x265.mkv -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:v libx265 -crf 23 -preset slow output.mkv
, then the file converts to sdr. but if try to add the previous command to handbrake's extra commands box. hdr -> sdr conversion doesnt happen. Following command i tried to add extra commands box:
zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p
. So how i need to modify handbrake preset, to include functionality of that command?


HandBrake version (e.g., 1.0.0):
1.2.2



Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):
Windows 10 Pro 1809



HandBrake Activity Log ***required*** (see How-to get an activity log)

Log file: https://pastebin.com/L6arjCLY
Presetfile: https://pastebin.com/EL9rWq5S

mduell
Veteran User
Posts: 6751
Joined: Sat Apr 21, 2007 8:54 pm

Re: How to convert hdr 4k file to sdr 4k file with handbrake

Post by mduell » Fri May 10, 2019 6:30 pm

HB's extra commands are for encoder library options only, not arbitrary options for an unrelated piece of software.

If you do any encode with HB from an HDR source, your output will be SDR. It may not be the tone/color mapping you want, but it will be SDR.

User avatar
JohnAStebbins
HandBrake Team
Posts: 5484
Joined: Sat Feb 09, 2008 7:21 pm

Re: How to convert hdr 4k file to sdr 4k file with handbrake

Post by JohnAStebbins » Fri May 10, 2019 7:29 pm

mduell wrote:
Fri May 10, 2019 6:30 pm
If you do any encode with HB from an HDR source, your output will be SDR. It may not be the tone/color mapping you want, but it will be SDR.
Actually, it's a bit more complicated than that. What is popularly known as "HDR" is a combination of an expanded color gamut (bt.2020) plus metadata that is added to the stream that tells a display how to map the expanded color gamut down when the display does not support the full gamut.

HandBrake passes the color characteristics through unmodified (transfer, primaries, and matrix), but HandBrake truncates the pixel's color components to 8 bits per component and does not pass through the color mapping metadata for the display. So the result is something with some of the characteristics of HDR but *not* HDR :?

Any player that properly respects color transfer, primaries, and matrix should be able to reproduce the original colors accurately. But I don't know how many players properly account for all relevant factors. I.e. the color gamut supported by the display is an important factor.

I have investigated adding a color map filter to do true HDR to SDR conversion (which is what your ffmpeg command line is doing). It's on my todo list to implement. But no ETA.

dj02
Posts: 2
Joined: Fri May 10, 2019 7:18 am

Re: How to convert hdr 4k file to sdr 4k file with handbrake

Post by dj02 » Sun May 12, 2019 8:05 am

JohnAStebbins wrote:
Fri May 10, 2019 7:29 pm
mduell wrote:
Fri May 10, 2019 6:30 pm
If you do any encode with HB from an HDR source, your output will be SDR. It may not be the tone/color mapping you want, but it will be SDR.
Actually, it's a bit more complicated than that. What is popularly known as "HDR" is a combination of an expanded color gamut (bt.2020) plus metadata that is added to the stream that tells a display how to map the expanded color gamut down when the display does not support the full gamut.

HandBrake passes the color characteristics through unmodified (transfer, primaries, and matrix), but HandBrake truncates the pixel's color components to 8 bits per component and does not pass through the color mapping metadata for the display. So the result is something with some of the characteristics of HDR but *not* HDR :?

Any player that properly respects color transfer, primaries, and matrix should be able to reproduce the original colors accurately. But I don't know how many players properly account for all relevant factors. I.e. the color gamut supported by the display is an important factor.

I have investigated adding a color map filter to do true HDR to SDR conversion (which is what your ffmpeg command line is doing). It's on my todo list to implement. But no ETA.
Could you help how to insert my linked preset settings to that ffmpeg command i posted?

User avatar
JohnAStebbins
HandBrake Team
Posts: 5484
Joined: Sat Feb 09, 2008 7:21 pm

Re: How to convert hdr 4k file to sdr 4k file with handbrake

Post by JohnAStebbins » Mon May 13, 2019 3:49 pm

Could you help how to insert my linked preset settings to that ffmpeg command i posted?
You can't do this in HandBrake.

Post Reply