Log in

View Full Version : How/with what to convert HEVC HLG video to HEVC SDR video?


Mounter81
28th November 2023, 18:49
So I have a couple of HLG videos witch didn't play with fine colors (too dark) on my media player (but fine with MPC-BE on Windows). So I want them to be converted to SDR.

What is the best converter program and how to set it up to do this?

Thank you!

benwaggoner
28th November 2023, 21:21
I believe zscale in ffmpeg also has a pretty good HLG to 709 conversion mode. Most HLG is close enough to SDR that it doesn't take a whole lot of processing; much simpler than converting from PQ.

Mounter81
29th November 2023, 09:35
Ok, thanks to both, but where can I find some tutorials to do this conversion with the mentioned programs?

Mounter81
29th November 2023, 15:26
You're unlikely to find a tutorial covering all those things. Let's start by asking what experience do you have in multimedia? For example, have you ever used Avisynth(+)?

No never I have used Avisynth. I have used Handbrake sometimes for other purposes.

Mounter81
29th November 2023, 16:17
Oh and for hardwarewitse I have a 10.th Gen i3 CPU with Intel UHD 630 IGP to do the encoding.

Mounter81
29th November 2023, 17:14
Looks like Handbrake can do it:

https://www.reddit.com/r/handbrake/comments/mom65d/4k_hdr_to_1080p_sdr_question/

If you want to get pedal-to-the-metal with this stuff, you're going to have to learn all the steps individually. You can start by researching and learning Avisynth(+) and filtering.

No Handbrake can't do the conversion it just convert it to SDR without the color correction (like HDR video on an SDR display).

I have found this Avisynth script somwhere:

LoadPlugin("path\LSMASHSource.dll")
LWLibavVideoSource("path of the video", format="YUV420P16")
loadplugin("path\dgdecodenv.dll")
loadplugin("path\dghdrtosdr.dll")
DGHDRtoSDR(mode="pq",white=2000)

I have loaded it into Virtualdub, but it doesn't work for me, because the dgdecodenv.dll file is for NVida GPUs only. I need a version that works with my intel IGP. Can someone help me in that?

Mounter81
30th November 2023, 16:19
You don't have to load DGDecodeNV.dll if you use LSMASHSource.dll:

LoadPlugin("path\LSMASHSource.dll")
LoadPlugin("path\dghdrtosdr.dll")
LWLibavVideoSource("path of the video", format="YUV420P16")
DGHDRtoSDR(mode="hlg", impl="sw") # kinda slow in sw mode

Read the accompanying DGHDRtoSDR text file for other options.

There are also other filters to do it. I'll let their authors chime in, or do a search.

I want to do it a hardware level mode, if possible. The UHD 630 IGP is capable of HEVC 10 encoding (intel QSV). Any ideas?

Mounter81
1st December 2023, 05:58
Ok, I have loaded the script in Virtualdub, but don't know how to start the encoding...

So what option should I select in Vurtualdub next?

Mounter81
1st December 2023, 07:03
And one more question, how do I add/enable x265.exe (https://www.videohelp.com/software/x265-Encoder#download) to Virtualdub?

StvG
1st December 2023, 13:54
I want to do it a hardware level mode, if possible. The UHD 630 IGP is capable of HEVC 10 encoding (intel QSV). Any ideas?

There are libplacebo (Vulkan) implementations for VapourSynth/AviSynth that can do tonemapping.

FranceBB
3rd December 2023, 02:52
And one more question, how do I add/enable x265.exe (https://www.videohelp.com/software/x265-Encoder#download) to Virtualdub?

x265 is generally used via command line, however if you wanna use it through VirtualDub, just make sure you're you using the latest version of VirtualDub, Build 44282 (2020) from here: Link (https://www.videohelp.com/download/VirtualDub2_44282.zip)

and you'll find it in "video -> compression":

https://i.imgur.com/tQ9ntl5.png

then hit the "configure" button and you can pick a fraction of parameters like the preset, the crf and the bit depth.
If you want more parameters then I'm afraid you'll have to use the command line. If you were to actually use the command line, it might seem intimidating at frist, but you'll see that it's actually pretty straightforward and many of us here prefer it to any GUI.

About converting HDR HLG to SDR BT709, you can do:


#Indexing
video=LWLibavVideoSource("your_video.m2ts")
audio=LWLibavAudioSource("your_audio.m2ts")
AudioDub(video, audio)

#Bringing everything to 16bit planar
ConvertBits(16)

#From YUV to XYZ
ConvertYUVtoXYZ(Color=0, HDRmode=2)

#HLG HDR to BT709 SDR tonemapping
ConvertXYZ_Reinhard_HDRtoSDR(exposure_X=2.1)

#Bringing everything back to YUV
ConvertXYZtoYUV(pColor=0)

#Dithering
ConvertBits(bits=8, dither=1)



but you'll need to put the DLLs in plugins64+ from here: Link (https://github.com/HomeOfAviSynthPlusEvolution/L-SMASH-Works/releases) - Link (https://github.com/jpsdr/plugins_JPSDR/releases)