View Full Version : How to convert HDR 4K .MKV to HDR 1440p .MP4?
etoegor
25th August 2018, 02:12
Hello! I really don't understand how to convert HDR 4K .MKV to HDR 1440p or 1080p .MP4 without HDR loss! Can someone give me a proven method please?
FranceBB
25th August 2018, 05:28
HDR 4K .MKV to HDR 1440p or 1080p .MP4 without HDR loss!
Which HDR? HDR10? HDR10+? HLG? Dolby Vision?
You mean downscaled HEVC files with HDR metadata? Why would you want to downscale and preserve HDR metadata?
What *I think* you want is a way to bring everything to SDR while preserving an "HDR-like" feel thanks to good tone-mapping, but since I don't know that for sure, I'm gonna show the two scenarios, assuming your mkv is just your personal UHD-BD Remux which has been made in HDR10:
1) HEVC Downscale 1080p and encode as HDR10 PQ (like the source):
Open MediaInfo and find the Master Display Values and max-cll and write in the x265 command line the exact same values that MediaInfo shows.
This is an example:
ffmpeg.exe -hwaccel dxva2 -i "file.mkv" -s 1920:1080 -aspect 16:9 -vf scale=out_color_matrix=bt2020nc:out_h_chr_pos=0:out_v_chr_pos=0 -pix_fmt yuv420p10 -strict -1 -an -f yuv4mpegpipe - | x265.exe --y4m - --dither --preset medium --level 5.0 --tune fastdecode --no-high-tier --ref 4 --profile main10 --crf 18 --deblock -1:-1 --hdr-opt --hrd --min-luma 64 --max-luma 940 --chromaloc 2 --range limited --videoformat component --colorprim bt2020 --transfer smpte2084 --colormatrix bt2020nc --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,0.0050)" --max-cll 1000,400 --overscan show --wpp -o "raw_video.hevc"
The example involves ffmpeg and x265 only, but if you wanna use Avisynth, you are free to do so and you can use a better resizer to downscale, (I generally use Lanczos to downscale).
2) H.264 Downscale 1080p + HDR10 to SDR tone-mapping and 8bit dithering:
Avisynth (Actually, Avisynth+):
#Index
FFMpegSource2("video.mkv", atrack=-1)
#Tone-mapping HDR to SDR using Reinhard
#There are other methods available, but I linke results obtained by Reinhard
ConvertYUVtoXYZ(Color=0, OutputMode=1)
ConvertXYZ_Reinhard_HDRtoSDR()
ConvertXYZtoYUV()
#Floyd-Steinberg error diffusion dithering down to 8bit
ConvertBits(8, dither=1)
You need HDRTools in order to do this: https://forum.doom9.org/showthread.php?t=175488
x264:
x264.exe "AVS Script.avs" --preset slow --level 4.1 --ref 4 --crf 18 -o "raw_video.h264"
Tweak whatever x264 parameters you want, the command line above is just an example.
I truly believe that "scenario 2" is what you want: way to tone-map HDR to SDR.
I don't really think you wanna make a 1080p HDR (like in "scenario 1"), 'cause it wouldn't be standard, it wouldn't be playable by legacy players and the ones that would be able to play it... well... they would be able to play the original 4K version, but anyway, you asked, I replied xD
etoegor
25th August 2018, 16:15
I just want to watch HDR films on my iPad Pro 10.5 64gb, but I don't have so much storage to upload ~60gb 4k HDR films
FranceBB
26th August 2018, 00:09
Got it.
By the way, I suggest you to remove the torrent link.
According to rule 6) Links to content of a questionable nature (e.g. anything you don't own and/or have downloaded), asking for, offering, or asking for help/helping to process such content in any way or form is not tolerated.
Forteen88
26th August 2018, 10:45
This is an example:
ffmpeg.exe -hwaccel dxva2 -i "file.mkv"..."
Is FFmpeg's -hwaccel option really faster decoding than CPU-decoding? Did anyone do benchmarks on this, and also is the image-quality with GPU-decoding as good as CPU-decoding?
The MeGUI-similar program 'Hybrid' says:
"Use gpu for decoding":
When enabled Hybrid will add '-hwaccel auto' to ffmpeg decoding calls.
This option has no effect if the selected hwaccel is not available or not supported by the chosen decoder (only mpeg-2, H.264, VC-1 and WMV3 content are supported atm.).
Note that most acceleration methods are intended for playback and will not be faster than software decoding on modern CPUs. Additionally, ffmpeg will usually need to copy the decoded frames from the GPU memory into the system memory, resulting in further performance loss. So this option might not provide any additional speed and thus is mainly useful for testing.
Blue_MiSfit
27th August 2018, 21:19
This is clearly for helping with pirated content. We really can't have that kind of thing discussed on doom9. Closing this thread.
benwaggoner
28th August 2018, 18:14
I just want to watch HDR films on my iPad Pro 10.5 64gb, but I don't have so much storage to upload ~60gb 4k HDR films
Do you have a way to sideload HDR files on to your iPad? Last time I tried (both iPad Pro 10.5 and iPhone X), iOS refused to transfer anything with HDR in it. Even when I got tricky by putting the .mp4 in a .7z I downloaded, it still wouldn't play the file.
I wouldn't spend a whole lot of time trying to figure this out before you've got a way to play the content. And if you find one, tell me!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.