Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th January 2025, 20:10   #1  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 419
HDR to SDR Near-Full Conversion

How do I convert HDR videos/movies to SDR, to the point where people will not notice the difference?
jay123210599 is offline   Reply With Quote
Old 20th January 2025, 20:21   #2  |  Link
microchip8
ffx264/ffhevc author
 
microchip8's Avatar
 
Join Date: May 2007
Location: /dev/video0
Posts: 1,929
You do tonemapping. Most people will not notice it's been converted if done right. Tonemapping is not perfect and will never be
__________________
ffx264 || ffhevc || ffxvid || microenc
microchip8 is offline   Reply With Quote
Old 20th January 2025, 20:54   #3  |  Link
GeoffreyA
Registered User
 
Join Date: Jun 2024
Location: South Africa
Posts: 366
Quote:
Originally Posted by jay123210599 View Post
How do I convert HDR videos/movies to SDR, to the point where people will not notice the difference?
https://forum.doom9.org/showthread.p...51#post2011951
GeoffreyA is offline   Reply With Quote
Old 20th January 2025, 22:48   #4  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 419
Quote:
Originally Posted by GeoffreyA View Post
But none of them will achieve the result I want?
jay123210599 is offline   Reply With Quote
Old 20th January 2025, 23:24   #5  |  Link
GeoffreyA
Registered User
 
Join Date: Jun 2024
Location: South Africa
Posts: 366
Quote:
Originally Posted by jay123210599 View Post
But none of them will achieve the result I want?
Use the libplacebo version. Its results are excellent and, I reckon, will solve your problem. I'll post a cleaner version of the command tomorrow, but you can use that for now; it's the same and will work. The target resolution is 1080p, which you can adjust.

Are you aiming for a bit depth of 8 or 10 bits?

Also, what about your audio? Are you downmixing or copying straight over?
GeoffreyA is offline   Reply With Quote
Old 21st January 2025, 01:24   #6  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,683
Quote:
Originally Posted by jay123210599 View Post
How do I convert HDR videos/movies to SDR, to the point where people will not notice the difference?
If we could do that, there'd be no point in HDR in the first place.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 21st January 2025, 03:00   #7  |  Link
jay123210599
Registered User
 
Join Date: Apr 2024
Posts: 419
Quote:
Originally Posted by GeoffreyA View Post
Use the libplacebo version. Its results are excellent and, I reckon, will solve your problem. I'll post a cleaner version of the command tomorrow, but you can use that for now; it's the same and will work. The target resolution is 1080p, which you can adjust.

Are you aiming for a bit depth of 8 or 10 bits?

Also, what about your audio? Are you downmixing or copying straight over?
About my HDR video: It's a clip of a 2160p HDR movie with black bars. I want the output to trim out those black bars and I'm aiming for 10 bits.
jay123210599 is offline   Reply With Quote
Old 21st January 2025, 10:24   #8  |  Link
GeoffreyA
Registered User
 
Join Date: Jun 2024
Location: South Africa
Posts: 366
This script will convert the video stream, discarding audio, to 10-bit BT.709 SDR, encoding as HEVC. Place in a BAT file, collapsing the FFmpeg command onto one line, set the crop values highlighted in bold, as well as x265 settings.

Code:
setlocal
set crop=Width:Height:Left:Top

ffmpeg -init_hw_device vulkan -i INPUT -map 0:v:0 -map_metadata -1 -vf libplacebo=upscaler=spline36:downscaler=spline36:w=1920:h=-1:
                                                                       tonemapping=spline:gamut_mode=perceptual:
                                                                       colorspace=bt709:color_trc=bt709:color_primaries=bt709:range=limited:format=yuv420p10le,
                                                                       crop=%crop%:exact=true,sidedata=delete -c:v libx265 [...] OUTPUT

endlocal
pause
For my part, I prefer to add the cropping filter after libplacebo has processed everything, avoiding issues with scaling. The simplest way to get the cropping values are to open the source in VirtualDub2, add a resize filter to shrink to 1080p, and a crop filter after that. Crop the picture on a bright scene and note all numbers.

Now, where it says crop=Width:Height:Left:Top above, take your values from VD2 and substitute them. Generally, Height and Top are key. For example:

Code:
crop=1920:804:0:138
As others have noted, converting from HDR to SDR is a lossy process, and there is no one "right" way of doing it. A reasonable aim would be to match, come close to, or surpass the official 1080p version.

Last edited by GeoffreyA; 21st January 2025 at 10:40.
GeoffreyA is offline   Reply With Quote
Old 21st January 2025, 21:46   #9  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 581
It's not possible unless there's little to none highlight (when you playback them on non-crap HDR devices)

If the device is not HDR or crap HDR, it's likely been doing tonemapping already (or clipping which should be worse) so good tonemapping will give you similar or better looking

Last edited by Z2697; 21st January 2025 at 21:56.
Z2697 is offline   Reply With Quote
Old 25th January 2025, 18:39   #10  |  Link
wswartzendruber
hlg-tools Maintainer
 
wswartzendruber's Avatar
 
Join Date: Feb 2008
Posts: 460
Question: Do you have control over which playback devices are used? I ask because I have found converting to HLG to work quite well. Most of the highlights are preserved on devices that can show them, yet it naturally looks like SDR when played back as such. The reason you need to control the playback is that some players absolutely suck at BT.2020->BT.709 color mapping.
wswartzendruber is offline   Reply With Quote
Old 26th January 2025, 07:24   #11  |  Link
GeoffreyA
Registered User
 
Join Date: Jun 2024
Location: South Africa
Posts: 366
Quote:
Originally Posted by wswartzendruber View Post
Question: Do you have control over which playback devices are used? I ask because I have found converting to HLG to work quite well. Most of the highlights are preserved on devices that can show them, yet it naturally looks like SDR when played back as such. The reason you need to control the playback is that some players absolutely suck at BT.2020->BT.709 color mapping.
If you mean in reference to libplacebo, I'm not too sure but expect it to be able, having a rich selection of settings.

https://github.com/haasn/libplacebo/...ocs/options.md
https://ffmpeg.org/ffmpeg-filters.html#libplacebo
GeoffreyA is offline   Reply With Quote
Old 27th January 2025, 16:35   #12  |  Link
wswartzendruber
hlg-tools Maintainer
 
wswartzendruber's Avatar
 
Join Date: Feb 2008
Posts: 460
Quote:
Originally Posted by GeoffreyA View Post
If you mean in reference to libplacebo, I'm not too sure but expect it to be able, having a rich selection of settings.

https://github.com/haasn/libplacebo/...ocs/options.md
https://ffmpeg.org/ffmpeg-filters.html#libplacebo
I wasn't referring to libplacebo specifically. I have written a tool set for converting from PQ to HLG:

Source: https://github.com/wswartzendruber/hlg-tools
Wiki: https://github.com/wswartzendruber/hlg-tools/wiki
Binaries: https://github.com/wswartzendruber/hlg-tools/releases

I'm not going to act like this is objectively the best way to go about things, but it does address what I believe to be the elephant in the room: 4K UltraHD discs are mastered with wildly varying levels of brightness. Fundamentally, if someone is downconverting from absolute brightness (HDR-PQ) to relative brightness (HDR-HLG and SDR), they have to know where reference white is on the PQ source. This is because the implicit definition of HDR-PQ over HDR-HLG and SDR is expanding the room between reference white and max white. And because of this, downconversion is the inverse: compressing the space between reference white and max white. If you get reference white wrong, you'll either over-compress or under-compress different brightness ranges.
wswartzendruber is offline   Reply With Quote
Old 28th January 2025, 11:03   #13  |  Link
lollo2
Registered User
 
lollo2's Avatar
 
Join Date: Aug 2017
Location: Italy
Posts: 145
Quote:
Originally Posted by wonkey_monkey View Post
If we could do that, there'd be no point in HDR in the first place.
the only appropriate comment in this thread
__________________
A channel on S-VHS / VHS capture and AviSynth restoration https://www.youtube.com/channel/UCMs...h1MmNAs7I8nu4g
lollo2 is offline   Reply With Quote
Old 28th January 2025, 18:14   #14  |  Link
wswartzendruber
hlg-tools Maintainer
 
wswartzendruber's Avatar
 
Join Date: Feb 2008
Posts: 460
Quote:
Originally Posted by lollo2 View Post
the only appropriate comment in this thread
That's kind of why I proposed HLG as an alterative to SDR. Again, this depends on:

1. Correct brightness adjustment.
2. SDR playback on a BT.2020-aware player.
wswartzendruber is offline   Reply With Quote
Old 28th January 2025, 19:47   #15  |  Link
GeoffreyA
Registered User
 
Join Date: Jun 2024
Location: South Africa
Posts: 366
Quote:
Originally Posted by wswartzendruber View Post
I wasn't referring to libplacebo specifically. I have written a tool set for converting from PQ to HLG:

Source: https://github.com/wswartzendruber/hlg-tools
Wiki: https://github.com/wswartzendruber/hlg-tools/wiki
Binaries: https://github.com/wswartzendruber/hlg-tools/releases

I'm not going to act like this is objectively the best way to go about things, but it does address what I believe to be the elephant in the room: 4K UltraHD discs are mastered with wildly varying levels of brightness. Fundamentally, if someone is downconverting from absolute brightness (HDR-PQ) to relative brightness (HDR-HLG and SDR), they have to know where reference white is on the PQ source. This is because the implicit definition of HDR-PQ over HDR-HLG and SDR is expanding the room between reference white and max white. And because of this, downconversion is the inverse: compressing the space between reference white and max white. If you get reference white wrong, you'll either over-compress or under-compress different brightness ranges.
I think it's an interesting tool. Using HLG as an alternative to SDR hadn't occurred to me.
GeoffreyA is offline   Reply With Quote
Old 28th January 2025, 20:02   #16  |  Link
lollo2
Registered User
 
lollo2's Avatar
 
Join Date: Aug 2017
Location: Italy
Posts: 145
Quote:
Originally Posted by wswartzendruber View Post
That's kind of why I proposed HLG as an alterative to SDR. Again, this depends on:

1. Correct brightness adjustment.
2. SDR playback on a BT.2020-aware player.
Makes sense. But note that the OP is a well known troll (videohelp forums are full of his non-sense) and he asked in purpose "to the point where people will not notice the difference?"
__________________
A channel on S-VHS / VHS capture and AviSynth restoration https://www.youtube.com/channel/UCMs...h1MmNAs7I8nu4g
lollo2 is offline   Reply With Quote
Old 29th January 2025, 07:01   #17  |  Link
wswartzendruber
hlg-tools Maintainer
 
wswartzendruber's Avatar
 
Join Date: Feb 2008
Posts: 460
Quote:
Originally Posted by lollo2 View Post
Makes sense. But note that the OP is a well known troll (videohelp forums are full of his non-sense) and he asked in purpose "to the point where people will not notice the difference?"
Perhaps by that he means that someone should not realize just from watching the video that it comes from a PQ source.
wswartzendruber is offline   Reply With Quote
Old 29th January 2025, 07:43   #18  |  Link
GeoffreyA
Registered User
 
Join Date: Jun 2024
Location: South Africa
Posts: 366
Quote:
Originally Posted by wswartzendruber View Post
Perhaps by that he means that someone should not realize just from watching the video that it comes from a PQ source.
That's what I think: that the video should be indistinguishable from the "official" SDR version.
GeoffreyA is offline   Reply With Quote
Old 29th January 2025, 08:42   #19  |  Link
rwill
Registered User
 
Join Date: Dec 2013
Location: Berlin, Germany
Posts: 463
Quote:
Originally Posted by lollo2 View Post
Makes sense. But note that the OP is a well known troll (videohelp forums are full of his non-sense) and he asked in purpose "to the point where people will not notice the difference?"
Regarding noticing if something has been hand graded to SDR or tonemapped down from HDR, it is more or less the same concept as at which point do people notice the difference between an honest question and a troll. Some will notice right away, some will if it is pointed out to them, some will never.
__________________
My github...
rwill is offline   Reply With Quote
Old 29th January 2025, 15:39   #20  |  Link
lollo2
Registered User
 
lollo2's Avatar
 
Join Date: Aug 2017
Location: Italy
Posts: 145
Quote:
Originally Posted by GeoffreyA View Post
That's what I think: that the video should be indistinguishable from the "official" SDR version.
OP meant SDR indistinguishable from HDR, that’s why he’s trolling
__________________
A channel on S-VHS / VHS capture and AviSynth restoration https://www.youtube.com/channel/UCMs...h1MmNAs7I8nu4g
lollo2 is offline   Reply With Quote
Reply

Tags
hdr to sdr

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:26.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.