AnyDVD UHD (4K-HDR)

Discussion in 'High Definition Software' started by Futuria, Mar 17, 2017.

  1. gereral1

    gereral1 Well-Known Member

    I have a hdr lut in abobe premiere but want to test further. I have bluray and hdr material to match the RGB parade and LUMA so the conversion will be accurate for the 4k to 4k h264 to paly on older tvs or whatever. Just pressed for time but I will release my work soon
     
  2. jetli

    jetli Member

    thanks so far. so far it does appear to work. i need to finish converting a few of these to verify the results,
    but so far this is the best and only solution to downgrade hdr to sdr.
    i'm now working on getting the quality up while keeping the total bits used to a minimum.
    need to fit (4) 1hr clips onto 1 bd25.

    ffmpeg -i AC_S01E01.mkv -map 0:1 -c copy -map 0:v:0 -aspect 1920:1080 -r 23.976 -vf crop=3840:1920:0:0,scale=1920:1080,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:v libx264 -preset veryslow -profile:v high -level 4.1 -crf 12 -y output_AC_S01E01h264.mkv
     
  3. fornit

    fornit Member

    Hi,

    you don't write how many audio tracks you have in the file AC_S01E01.mkv. In my reply I assume it's one audio track only.

    If you want to fit 4 videos of 1 hour on one BD25, then each should get a size of 6 GB. This would lead to a bitrate of 14.3 Mbits.

    As you must consider the size of the audio track and some overhead for the container, I would suggest to try a bitrate of 13M for the video part of each video. Maybe better 12M to be on the safe side.

    If you have a given bitrate then the best will be to do the classic 2 pass conversion with ffmepg. The 1st pass to write the log file and the second pass to write the video.

    You can do that with ffmpeg as follows. Please note that I've adjusted your encoding string a bit.

    1st pass
    Code:
    ffmpeg -i AC_S01E01.mkv -map 0:v:0 -map 0:a:0 -aspect 1920:1080 -r 23.976 -vf scale=1920:1080,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:v libx264 -preset fast -profile:v high -level 4.1 -b:v 12M -ac 2 -c:a aac -b:a 192k -pass 1 -passlogfile AC_S01E01 -f matroska -y NUL
    2nd pass
    Code:
    ffmpeg -i AC_S01E01.mkv -map 0:v:0 -map 0:a:0 -aspect 1920:1080 -r 23.976 -vf scale=1920:1080,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:v libx264 -preset fast -profile:v high -level 4.1 -b:v 12M -ac 2 -c:a aac -b:a 192k -pass 2 -passlogfile AC_S01E01 -y output_AC_S01E01h264.mkv
    Hope that helps.
     
  4. jetli

    jetli Member

    thanks, so you recommend a 2nd pass.

    i am currently getting 15.5mbit overall bit rates.
    i put 3 on disk1, 4 on disk2, 3 on disk3, totaling 10 episodes.
    audio is 640k ac5.1
    7 are done so far working on last 3.

    i will try your approach on episode 1 only and compare to my output so far before i burn disks.
    thanks for your help. if you didn't come up with this, i would have had to accept the 6mbitrate
    from netflix 1080p version. no one has a mapping of HDR to SDR except this.
    others say they are working on it, but they are lost.
    i can watch the original 4k HDR letting the oppo 203 downconvert, and it does a really good job,
    but i want these on disk and off my drive.

    thanks again.
     
  5. jetli

    jetli Member

    ok ran 2 pass version it seems a tad better but ...
    i do have with all of these though.

    after analyzing more, it seems that there is too much red, and it seems to be bleeding over
    into the blue sky and is too strong throughout.
    is there a way to tone the red down a bit and reduce the artifacts ffmpeg is producing in general.
     
  6. fornit

    fornit Member

    Hm, it's not clear to me, whether you want to copy or convert the audio track. In my reply I'll assume now that you want to copy it.

    You would like to improve the overall quality of the encodes? Then I'd suggest to use x265 (HEVC) instead of x264 (AVC) at the same bitrate. This will improve quality significantly.

    A 2-pass encoding would then look as follows.

    First pass
    ffmpeg -i AC_S01E01.mkv -map 0:v:0 -map 0:a:0 -aspect 1920:1080 -r 23.976 -vf scale=1920:1080,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:v libx265 -preset fast -b:v 12M -an -pass 1 -f matroska -y NUL

    Second pass
    ffmpeg -i AC_S01E01.mkv -map 0:v:0 -map 0:a:0 -aspect 1920:1080 -r 23.976 -vf scale=1920:1080,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:v libx265 -preset fast -b:v 12M -c:a copy -pass 2 -f matroska -y output_AC_S01E01h265.mkv

    Converting HDR to SDR is challenging because colours not existing in the SDR colorspace must be mapped to it. Of course ffmpeg has some switches to reduce a specific colour. The question is whether this will be good for all material.

    You can try e.g. the "curves" filter, but it's hard for me to guess what will happen without a look at the videos you are converting.

    To apply that filter you can extend the vf statement. Append curves=red="0/0 0.5/0.4 1/0.8" and it will reduce red a bit:

    Code:
    -vf scale=1920:1080,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p,curves=red="0/0 0.5/0.4 1/0.8"
     
    Last edited: Jun 20, 2018 at 1:21 AM
  7. gereral1

    gereral1 Well-Known Member

    I'm playing with Adobe premiere 8.1.1.1 and using Intel's GPU acceleration to encode min for min HDR to sdr 4k tests. The final does not have HDR but rec709 and my tests are exactly what you get from madvrs 120 nit pixels shader math. Madvr does wonderful HDR conversion. Love Intel's GPU encoding. A 4 k rip that's 1 hr takes 1 hr to encode 40mbit lol. H265 real HDR takes me 6-8 hrs on my Intel 8700k using straxrip with 10bit UHD HDR output.
     
  8. fornit

    fornit Member

    Hi,

    last year I've tried around a while with Intel qsv and Nvidia nvenc. I've then choosen nvenc because it was faster and more reliable.

    But there's one thing you can read everywhere and you should keep in mind when it comes to GPU acceleration: Quality will suffer a lot or you must accept a significant increase in file size.
     
  9. gereral1

    gereral1 Well-Known Member

    True I'm YouTube creator so this GPU add-on is a dream for kabylake GPUs. My old h264 rips were done at 18mbit with untouched audio and they looked great. HDR to sdr is a biych. Even with rgb and luma scopes I still can get a perfect match but my test lut is really close. When I get it perfect I'll share it. Until then I'll keep at it. I'm using madvrs output as a reference. The problem lies in the white black level or HDR to sdr. The color shift to from bt2020 to rec709.