VideoHelp Forum




+ Reply to Thread
Results 1 to 3 of 3
  1. Happy New 2018 Everyone!!

    I have noticed that albeit slowly more discussions are surfacing about HDR to SDR conversion as folks are trying to find solutions to playback HDR content on their SDR devices and displays. I'm one of those folks. It seems that madVR is phenomenal for playing HDR on a SDR display but for my setup I'm leaning more towards transcoding. From what I learned thus far it looks like Davinci Resolve might be the way to go but I'm wondering about other solutions like RipBot264 combined with an AviSynth+ script. In case you're wondering why Ripbot264 it's to take advantage of its distributed encoding feature that makes encoding faster.

    With that said, by doing some more digging I found the following VapourSynth script for HDR to SDR conversion and was wondering if those who are experts could perhaps write an AviSynth+ equivalent? Unfortunately, I'm a newb when it comes to scripting so would appreciate some help. In any for those using VapourSynth this might be helpful as well as so here is the script.

    Code:
    import vapoursynth as vs
    
    core = vs.get_core()
    
    c = core.ffms2.Source(source = 'path/to/file')
    
    source_peak=1200 #set manually
    
    c=core.resize.Bilinear(clip=c, format=vs.YUV444PS, range_in_s="limited", range_s="full",chromaloc_in_s="center",dither_type="none")
    
    c=core.resize.Bilinear(clip=c, format=vs.RGBS, matrix_in_s="2020ncl", range_in_s="full",dither_type="none")
    
    c=core.resize.Bilinear(clip=c, format=vs.RGBS, transfer_in_s="st2084", transfer_s="linear",dither_type="none", nominal_luminance=source_peak)
    
    exposure_bias=source_peak/100
    
    #hable/uncharted tone mapping
    
    tm = core.std.Expr(c, expr="x {exposure_bias} * 0.15 x {exposure_bias} * * 0.05 + * 0.004 + x {exposure_bias} * 0.15 x {exposure_bias} * * 0.50 + * 0.06 + / 0.02 0.30 / - ".format(exposure_bias=exposure_bias),format=vs.RGBS)#12=1200 nits / 100 nits
    
    w = core.std.Expr(c, expr="{exposure_bias} 0.15 {exposure_bias} * 0.05 + * 0.004 + {exposure_bias} 0.15 {exposure_bias} * 0.50 + * 0.06 + / 0.02 0.30 / - ".format(exposure_bias=exposure_bias),format=vs.RGBS)#
    
    c = core.std.Expr(clips=[tm,w], expr=" x 1 y / * ",format=vs.RGBS)
    
    #c=core.fmtc.primaries(clip=c, prims="2020", primd="709")
    
    c=core.resize.Bilinear(clip=c, format=vs.RGBS, primaries_in_s="2020", primaries_s="709",dither_type="none")
    
    c=core.resize.Bilinear(clip=c, format=vs.RGBS, transfer_in_s="linear", transfer_s="709",dither_type="none")
    
    c=core.resize.Bilinear(clip=c, format=vs.YUV420P8, matrix_s="709", range_in_s="full",range_s="limited",chromaloc_in_s="center")
    
    c.set_output()
    Thank you for your help in advance.
    Quote Quote  
  2. As an alternative way you could:
    1. process your video with Avisynth+ (while not messing with the color space, no RGB<>YUV conversions)
    2. decode it with ffmpeg, while using toneMap from ffmpeg
    3. feed the output of ffmpeg to your encoder
    like Atak_Snajpera does over at: https://forum.doom9.org/showthread.php?p=1827936#post1827936
    Sure this limits the processing through Avisynth+ somewhat, but might help in a few scenarios until someone using Avisynth+ ports it.

    btw. for Vapoursynth the script isn't really necessary any more since there's a toneMap port for Vapoursynth now (https://github.com/ifb/vapoursynth-tonemap) thanks to ifb!

    Cu Selur
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  3. Thanks Selur for the suggestion. Atak_Snajpera actually just recently released a new version of RipBot that does tone mapping when encoding from x265 to x264. I haven't tried it yet but I think this will be the best thing since with RipBot I can take advantage of the Distributed Encoding feature which is amazing.

    Thanks again.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!