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. |
![]() |
#1 | Link |
Registered User
Join Date: Apr 2024
Posts: 401
|
HDR to SDR Full Conversion
How do I fully convert HDR videos/movies to SDR, so that the output SDR will have all the colors from the HDR input? Or, if that's not possible, how do I upload HDR videos to YouTube with all of its colors?
Also, do gif files support HDR? If so, how do I make those files with all of the HDR colors? |
![]() |
![]() |
![]() |
#2 | Link |
Registered User
Join Date: Aug 2024
Posts: 529
|
If the SDR by definition is in contrast to HDR then the answer is absolutely not.
If you mean tranfer chararistics often used in SDR content (e.g. bt.1886) then the answer is maybe you won't like it. I have a useful link for you, again: https://www.google.com/search?q=how+...deo+to+youtube GIF? LOL. |
![]() |
![]() |
![]() |
#3 | Link |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 349
|
Converting from 10-bit BT.2020 HDR to 8-bit BT.709 SDR is a lossy operation, going from bigger to smaller. Also, there is no one accepted way of doing it properly; each method gives different results. The tone-mapping step varies greatly depending on the choice of function: Reinhard, Hable, and Mobius are popular and give good results, particularly the first two.
Using FFmpeg (just take out the line-breaks I put in for clarity): Code:
ffmpeg -i "INPUT.mkv" -map 0 -vf zscale=t=linear:npl=203,format=gbrpf32le, tonemap=reinhard:desat=0,zscale=1920:-1:f=spline36, zscale=m=709:t=709:p=709:r=limited:dither=error_diffusion,format=yuv420p,sidedata=delete -c:v libx264 -profile:v high -level 4.1 -preset veryslow -tune film -crf 18 -aq-mode 3 -c:a copy -c:s copy "OUTPUT.mkv" Code:
-vf zscale=min=bt2020nc:tin=smpte2084:pin=2020:rin=limited:m=gbr:t=linear:p=2020:dither=none:npl=203,format=gbrpf32le, tonemap=reinhard:desat=0,zscale=1920:-1:f=spline36, zscale=m=709:t=709:p=709:r=limited:dither=error_diffusion,format=yuv420p,sidedata=delete In VapourSynth, using fmtconv: Code:
from vapoursynth import core clip = core.lsmas.LWLibavSource(filename) clip = clip.fmtc.bitdepth(bits=32) clip = clip.fmtc.resample(css="444") clip = clip.fmtc.matrix(mats="2020", matd="rgb") clip = clip.fmtc.transfer(transs="2084", transd="linear", match=2) clip = clip.tonemap.Reinhard(exposure=1, peak=100) #clip = clip.tonemap.Mobius(exposure=0.7, transition=0.3, peak=100) #clip = clip.tonemap.Hable(exposure=1.9) clip = clip.resize.Spline36(1920, 1080) clip = clip.fmtc.primaries(prims="2020", primd="709") clip = clip.fmtc.transfer(transs="linear", transd="709") clip = clip.fmtc.matrix(mats="rgb", matd="709") clip = clip.fmtc.resample(css="420") clip = clip.fmtc.bitdepth(bits=8) clip.set_output() In VapourSynth, using zimg: Code:
import vapoursynth as vs clip = vs.core.lsmas.LWLibavSource(filename) clip = clip.resize.Bilinear(format=vs.RGBS, matrix_in_s="2020ncl", transfer_in_s="st2084", primaries_in_s="2020", range_in_s="limited", matrix_s="rgb", transfer_s="linear", primaries_s="2020", dither_type="none", nominal_luminance=203) clip = clip.tonemap.Reinhard(exposure=1, peak=100) #clip = clip.tonemap.Mobius(exposure=0.7, transition=0.3, peak=100) #clip = clip.tonemap.Hable(exposure=1.9) clip = clip.resize.Spline36(1920, 1080) clip = clip.resize.Bilinear(format=vs.YUV420P8, matrix_in_s="rgb", transfer_in_s="linear", primaries_in_s="2020", matrix_s="709", transfer_s="709", primaries_s="709", range_s="limited", dither_type="error_diffusion") clip.set_output() Last edited by GeoffreyA; 1st December 2024 at 09:52. |
![]() |
![]() |
![]() |
#5 | Link | |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 349
|
Quote:
Concerning GIFs, no, they can't hold HDR colours. Remember, they only support up to 256 colours. As for APNGs, I'm not clued up on them so cannot comment, but if they support BT.2020, then yes. |
|
![]() |
![]() |
![]() |
#8 | Link |
Registered User
Join Date: Aug 2024
Posts: 529
|
@GeoffreyA @kolak The point is what does jay mean by "SDR" and "colors". I'm pretty sure he doesn't know anything about them, what worse is that he's not even trying to understand them. This "entity" is like ChatGPT, or even worse.
In the case of the real SDR, since HDR and SDR, by definition, in a simplified speaking, is like "SDR is the subset of HDR", so the conversion is simply impossile, period. In the case of converting or even reinterpreting the EOTFs usually used in HDR (e.g. PQ) to/as the EOTFs usually used in SDR (e.g. BT.1886), it's very much possible (but the result is not real SDR). Primaries, I think it's a separate topic, not related to the dynamic range. Last edited by Z2697; 2nd December 2024 at 01:08. |
![]() |
![]() |
![]() |
#9 | Link | ||
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 349
|
Z2697, I think when people talk of HDR to SDR in colloquial terms, the following is technically meant: BT.2020 NCL or BT.2100 matrix; PQ or HLG transfer; and BT.2020 primaries > BT.709 matrix; BT.709/BT.1886 transfer; and BT.709 primaries. Also, usually, shrinking to 1080p from 2160p and dropping the bit depth. HDR has turned into a colloquialism for high dynamic range, wide colour gamut, and, more often than not, 2160p resolution. Arguably, we've got 4K TV and BD marketing to thank for that.
I think Jay is referring to the primaries and colour space, not dynamic range. But of course, the latter has to be also dealt with and is the most challenging part of the process. Quote:
Quote:
Last edited by GeoffreyA; 2nd December 2024 at 07:25. |
||
![]() |
![]() |
![]() |
#11 | Link | |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 349
|
Quote:
Apparently, PNG can, so APNG quite likely. This Netflix article explains a lot on the topic you're addressing. It's all about HDR in images. I look forward to reading it later when I've got time. https://netflixtechblog.com/enhancin...dr-1e7506ad3e8 |
|
![]() |
![]() |
![]() |
#12 | Link | |
Registered User
Join Date: Apr 2024
Posts: 401
|
Quote:
|
|
![]() |
![]() |
![]() |
#14 | Link | |
Registered User
Join Date: Aug 2024
Posts: 529
|
Quote:
https://forum.doom9.org/showthread.p...86#post2010086 |
|
![]() |
![]() |
![]() |
#15 | Link |
Registered User
Join Date: Apr 2024
Posts: 401
|
I get it now, png itself doesn't support HDR, but it can using ICC profiles.
A quote from the article: "The key realization was that we could add an ICC Profile to each image to signal the HDR color profile of that image." By the way, if I use a image format that does support HDR and then convert it to PNG, will that work too? |
![]() |
![]() |
![]() |
#16 | Link |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 349
|
I think it will depend on the software used. As the article notes, it's one big mess. I suspect most software will not add the necessary information to the PNG. It would be advisable to use something more modern like JPEG XL.
|
![]() |
![]() |
![]() |
#17 | Link | |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 349
|
Quote:
|
|
![]() |
![]() |
![]() |
Tags |
hdr to sdr, image-quality, youtube hq videos |
Thread Tools | Search this Thread |
Display Modes | |
|
|