Log in

View Full Version : Add HDR metadata on SDR video.


Cedvano
26th March 2022, 18:14
Hello, is it possible to convert SDR video to HDR video (or even Dolby Vision)? A bit like MadVR does to convert HDR to Dovi.

I tried with ffmpeg, but they catch a tint to red.

I'm upscaling videos in 4K and would like to put them in HDR.

Thank you for your answers.

FranceBB
26th March 2022, 22:24
Hello, is it possible to convert SDR video to HDR video (or even Dolby Vision)? A bit like MadVR does to convert HDR to Dovi.

I tried with ffmpeg, but they catch a tint to red.

I'm upscaling videos in 4K and would like to put them in HDR.

Thank you for your answers.

I've gone past the times in which I used to ask users "why", I just roll out solutions now XD
Assuming you're upscaling from BT709 SDR FULL HD and your video is already progressive:

#Indexing
video=LWLibavVideoSource("yoursource.whatever")
audio=LWLibavAudioSource("yoursource.whatever")
AudioDub(video, audio)

#Bring everything to 16bit planar
ConvertBits(16)

#Upscale
nnedi3_rpow2(cshift="Spline64ResizeMT", rfactor=2, fwidth=3840, fheight=2160, nsize=4, nns=4, qual=1, etype=0, pscrn=2, threads=0, csresize=true, mpeg2=true, threads_rs=0, logicalCores_rs=true, MaxPhysCore_rs=true, SetAffinity_rs=false)

#Going from BT709 SDR to BT2020 HLG HDR
LinearTransformation(Input="Linear_BT709", Output="BT2020_HLG")

then feed this Avisynth Script to x265 with the following BAT:


ffmpeg.exe -i "\\VBOXSVR\Share_Windows_Linux\Production\AVS\test.avs" -vf scale=out_color_matrix=bt2020nc:out_h_chr_pos=0:out_v_chr_pos=0 -pix_fmt yuv420p16le -strict -1 -an -f yuv4mpegpipe - | x265.exe --y4m - --dither --preset medium --level 5.0 --no-high-tier --ref 4 --profile main10 --crf 22 --deblock -1:-1 --hdr-opt --hrd --min-luma 64 --max-luma 940 --chromaloc 2 --range limited --videoformat component --colorprim bt2020 --transfer arib-std-b67 --colormatrix bt2020nc --atc-sei 18 --overscan show --repeat-headers --rd 3 --vbv-maxrate 25000 --vbv-bufsize 25000 --wpp -o "\\VBOXSVR\Share_Windows_Linux\raw_video.hevc"

ffmpeg.exe -i "\\VBOXSVR\Share_Windows_Linux\Production\AVS\test.avs" -map 0:1 -af loudnorm=I=-24:LRA=14:tp=-2 -c:0:1 ac3 -b:0:1 384k -ar 48000 "\\VBOXSVR\Share_Windows_Linux\audio.ac3"

pause


then you can use MKVToolnix to mux them in .mkv
I would write a command line command for it but it's 10PM on Saturday evening and I just don't feel like it, but yeah, you can use whatever you want to encode it with whatever settings and whatever container as long as it supports H.265 and HDR metadata.

p.s in case you don't feel comfortable using Avisynth or x265 directly and you wanna use FFMpeg to do everything, just apply the LUT from within FFMpeg and call it a day: https://forum.doom9.org/showthread.php?t=176091

Cheers,
Frank

benwaggoner
27th March 2022, 03:19
why++

Simple automated SDR to HDR upsampling won't always give accurate or visual pleasing "enhancements." And they certainly don't match the HDR grade the creatives would have made.

lvqcl
27th March 2022, 06:29
why++

some like it fake

Balling
27th March 2022, 11:37
The worst part is the opposite when you have SDR video (means tagged as 709 transfer), yet it has sei with hdr10 metadata. Like in sony camp demo.

Cedvano
27th March 2022, 15:25
Thank you @FranceBB

kolak
4th April 2022, 21:13
It's going to be far from perfect.
You would need some well done tool, which would do it in 2 passes and per scene. Technicolor use to work on such a tool, but no idea what happened with it.
We still struggle with HDR to SDR conversion as any tool which does it globally (not per scene based on analysis) will give compromised results.