VideoHelp Forum
+ Reply to Thread
Results 1 to 19 of 19
Thread
  1. Member
    Join Date
    May 2019
    Location
    brazil
    Search Comp PM
    Need help to convert this example, 65mb only if you guys want to try before giving me tips, its on google drive ( tiny.cc/msxr6y ) to h264 without messing with colors and losing quality, this is the originalImage
    [Attachment 49062 - Click to enlarge]
    , this is when converted Image
    [Attachment 49064 - Click to enlarge]
    , see the difference? i did not change a thing, help me with this pls.
    Quote Quote  
  2. It's HDR video. If you want to convert to non-HDR AVC, then you need to do tone mapping.
    Quote Quote  
  3. Member
    Join Date
    May 2019
    Location
    brazil
    Search Comp PM
    Originally Posted by veresov View Post
    It's HDR video. If you want to convert to non-HDR AVC, then you need to do tone mapping.
    what software can help me with this tone mapping, when i search for hdr tone mapping i find only pictures related, not videos
    Quote Quote  
  4. Tell us all details of your current processing chain and tell us your target format. Thank you.
    Quote Quote  
  5. Member
    Join Date
    May 2019
    Location
    brazil
    Search Comp PM
    Originally Posted by veresov View Post
    Tell us all details of your current processing chain and tell us your target format. Thank you.
    i just want to change the hevc to h264 without losing quality, bitrate and colors. when i open the file in a software the colors are different, thats the problem.
    Quote Quote  
  6. Well, at least can you say if you use Avisynth or Vapoursynth scripts? And if not, then what? We could answer better.
    Quote Quote  
  7. Member
    Join Date
    May 2019
    Location
    brazil
    Search Comp PM
    Originally Posted by veresov View Post
    Well, at least can you say if you use Avisynth or Vapoursynth scripts? And if not, then what? We could answer better.
    i use vegas and render as magix avc/aac mp4, same bitrate and resolution.
    Quote Quote  
  8. Originally Posted by elimitado View Post
    i use vegas
    Oy. I think there is a professional version that can do HDR to SDR, but I don't know anything about it. Good luck!

    Or maybe Vegas can open Avisynth scripts? Or maybe use a lossless intermediate. I can give you Avisynth/Vapoursynth solutions up the wazoo.

    You can apply a 3D cube using DaVinci resolve, etc.
    Last edited by veresov; 15th May 2019 at 22:25.
    Quote Quote  
  9. Member
    Join Date
    May 2019
    Location
    brazil
    Search Comp PM
    Originally Posted by veresov View Post
    Originally Posted by elimitado View Post
    i use vegas
    Oy. I think there is a professional version that can do it, but I don't know much about it. Good luck!

    Or maybe Vegas can open Avisynth scripts?
    vegas cant. but the main issue for me here is the color changing, if i could find a way to change the vid to h264 without messing with the colors the rest is easy fix, could you get the vid i posted the link and use what you know to see if it works, i mean if the colors dont change? its only 65mb here is the short link ( tiny.cc/msxr6y ) or here the full ( https://drive.google.com/drive/folders/1yHVWbxHde5Tq3WKTOcxtjZj9866sUGFp ). thank you
    Quote Quote  
  10. Frame serve your video using an appropriate source filter under Avisynth/Vapoursynth (I use DGSource).
    Apply a HDR->SDR filter in your Avisynth/Vapoursynth script (I use DGHDRtoSDR).
    Encode the resulting raw stream to H.264 SDR (any decent encoder app such as mulder's great Simple Launcher).
    Multiplex the encoded video into MKV (mkvtoolnix).
    Now open the new MKV in Vegas.
    Voila!
    Last edited by veresov; 15th May 2019 at 22:53.
    Quote Quote  
  11. Member
    Join Date
    May 2019
    Location
    brazil
    Search Comp PM
    Originally Posted by veresov View Post
    Frame serve your video using an appropriate source filter under Avisynth/Vapoursynth (I use DGSource).
    Apply a HDR->SDR filter in your Avisynth/Vapoursynth script (I use DGHDRtoSDR).
    Encode the resulting raw stream to H.264 SDR (any decent encoder app such as mulder's great Simple Launcher).
    Multiplex the encoded video into MKV (mkvtoolnix).
    Now open the new MKV in Vegas.
    Voila!
    i will try and edit this when done saying how it went
    Quote Quote  
  12. Sounds good. You definitely need Avisynth+. Then if you have an nVidia card, use DGDecNV; otherwise FFMS2, LSmash, etc. DGDecNV will always be fastest if you have a decent nVidia GPU.

    Or you can use Vapoursynth in the same way. Different strokes for different folks.

    Onward and upward!
    Last edited by veresov; 15th May 2019 at 23:12.
    Quote Quote  
  13. Member
    Join Date
    Mar 2011
    Location
    Nova Scotia, Canada
    Search Comp PM
    Try opering the HEVC source file in Mediainfo. If it has 10 bit colour and you're encoding to 8 bt colour AVC the colous are going to look washed out. I'm pretty sure you can encode AVC with 10 bit colour but I haven't done it and I suspect you'd need to use a high profile.
    Quote Quote  
  14. as a side note tonemapping is also available in ffmpeg
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  15. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    How do you go from high to low without losing height? You cannot. And you cannot go from HDR to SDR without losing quality and colors.
    But tone mapping process is meant to give you perceptual equivalent in SDR of what you had in HDR, if you do it right, so hopefully you should still be happy with the end result.
    I don't know of any tonemapping video process that is cheap, though. Ffmpeg and other tools can do generic & automated conversions, but those could very likely not be appropriate for your material (there are at least 6 or 8 tonemapping methods available so far, IIRC).

    Scott
    Quote Quote  
  16. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    I experimented with it; I just installed avisynth+ 32 bit and 64 bit, the tonemap and avsresize tools provide
    both versions, so for this quick and dirty I got lazy and used the 32 bit system.
    I used DG's sample script as is, didn't try hable or adjust the parameters
    Here's a tonemap'd encode of the HEVC HDR file which is itself a re-encode of the untouched blu-ray sample, about 250 MB
    Image Attached Files
    Quote Quote  
  17. Originally Posted by elimitado View Post
    Originally Posted by veresov View Post
    Originally Posted by elimitado View Post
    i use vegas
    Oy. I think there is a professional version that can do it, but I don't know much about it. Good luck!

    Or maybe Vegas can open Avisynth scripts?
    vegas cant. but the main issue for me here is the color changing, if i could find a way to change the vid to h264 without messing with the colors the rest is easy fix, could you get the vid i posted the link and use what you know to see if it works, i mean if the colors dont change? its only 65mb here is the short link ( tiny.cc/msxr6y ) or here the full ( https://drive.google.com/drive/folders/1yHVWbxHde5Tq3WKTOcxtjZj9866sUGFp ). thank you
    I gave it a shot in Vapoursynth, using exactly this script from user age. He tries it for a while to get right colors so I gave it a shot.

    Conversion to RGBS -floating point using matrix 2020ncl, transfer st2084, tonemapping and back to YUV BT709
    Not sure if colors are correct, this is what came out, its downconverted to 1280x534 , just to see colors
    Image Attached Thumbnails Click image for larger version

Name:	HDR to SDR.JPG
Views:	241
Size:	127.5 KB
ID:	49086  

    Image Attached Files
    Quote Quote  
  18. Or using again Vapoursynth and tonemap.dll , description here.
    It is much faster because of dll, had to restrict cache in Vapoursynth , I do not have much RAM and it took some. Exposure could be tuned up, I set it to 10.0, because default value gave dark picture.

    Also including the whole Vapoursynth script that also produces final mp4 file.
    Code:
    input=r'C:/hevc HDR to h264 help.mkv'
    import vapoursynth as vs
    from vapoursynth import core
    import subprocess
    clip = core.ffms2.Source(input)
    
    source_peak=1000 
    matrix_in_s="2020ncl"
    transfer_in_s="st2084"
    
    core.max_cache_size=800
    clip=core.resize.Bicubic(clip, format=vs.RGBS, filter_param_a=0, filter_param_b=0.75, matrix_in_s=matrix_in_s,chromaloc_in_s="center",chromaloc_s="center", range_in_s="limited",dither_type="none")
    clip=core.resize.Bilinear(clip, format=vs.RGBS, transfer_in_s=transfer_in_s, transfer_s="linear",dither_type="none", nominal_luminance=source_peak)
    
    clip = core.tonemap.Hable(clip , exposure=10.0, a=0.15, b=0.50, c=0.10, d=0.20, e=0.02, f=0.30, w=11.2)
    
    clip=core.resize.Bilinear(clip, format=vs.RGBS, primaries_in_s="2020", primaries_s="709",dither_type="none")
    clip=core.resize.Bilinear(clip, format=vs.RGBS, transfer_in_s="linear", transfer_s="709",dither_type="none")
    
    clip=core.resize.Bicubic(clip, format=vs.YUV420P8,matrix_s="709", filter_param_a=0, filter_param_b=0.75, range_in_s="full",range_s="limited", chromaloc_in_s="center", chromaloc_s="center",dither_type="none")
    clip= core.resize.Spline36(clip, 1280, 534)
    
    import shutil
    import os
    
    output_264 = r'C:/Target/temp.264'
    output_mp4 = r'C:/Target/HDR to SDR tonemap.mp4'
    #on linux x264 or mp4box should be in system path,  on windows add those to path or put in current directory fot shutil to find it
    x264 = shutil.which('x264')
    #mp4box = shutil.which('mp4box') 
    mp4box = r'C:\tools\MP4box-64bit\mp4box.exe'
    
    x264_cmd = [x264, '--frames',  f'{len(clip)}',
                 '--input-csp',     'i420',
                 '--demuxer',       'raw',
                 '--input-depth',   '8',
                 '--input-res',    f'{clip.width}x{clip.height}',
                 '--fps',          f'{clip.fps_num}/{clip.fps_den}',
                 '--crf',           '18',
                 '--colorprim',     'bt709',
                 '--transfer',      'bt709',
                 '--colormatrix',   'bt709',
                 '--output', output_264,
                 '-']  #input
    process = subprocess.Popen(x264_cmd, stdin=subprocess.PIPE)
    clip.output(process.stdin)
    process.communicate()
    
    #mp4box does not support stdin
    mp4box_cmd = [mp4box, '-add' , output_264+':fps=23.976'  , '-new',  output_mp4]
    process = subprocess.Popen(mp4box_cmd, stderr=subprocess.PIPE)
    process.communicate()
    
    if os.path.exists(output_264):
        os.remove(output_264)
    
    clip.set_output() #perhaps this line for VSEdit to not throw error
    Image Attached Files
    Last edited by _Al_; 18th May 2019 at 23:54.
    Quote Quote  
  19. and again some snap from that conversion with tonemap.dll
    Image Attached Thumbnails Click image for larger version

Name:	HDR to SDR tonemap dll.JPG
Views:	180
Size:	127.4 KB
ID:	49091  

    Quote Quote  



Similar Threads

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