Table of Contents

Convert MKV to MP4

For LG TV you may need convert Dolby Vision MKV to MP4
(mkv tool, dolby vision muxer and mp4box required)

mkvextract.exe input.mkv tracks 0:video.hevc 1:audio.ac3 3:en.srt 9:cs.srt
mp4muxer.exe --dv-profile 5 --input-file video.hevc --input-file audio.ac3 --output-file movie.mp4
mp4box.exe  -brand mp42isom -tight -itags cover=cover.jpg -ab dby1 -no-iod -add "movie.mp4" -add "en.srt#subtitle:lang=en-EN:name=English"  -add "cs.srt#subtitle:lang=cs-CZ:name=Czech" -new "outfinal.mp4"
pause

Convert remux MP4

mp4demuxer --input-file input.mp4 --output-folder tmp
mp4muxer --dv-profile 5 --input-file tmp\out_1.h265 --input-file tmp\out_2.ec3 --output-file movie.mp4
mp4box.exe -brand mp42isom -tight -itags cover=cover.jpg -ab dby1 -no-iod -add "movie.mp4" -add "tmp\en.srt#subtitle:lang=en-EN:name=English" -new "outfinal.mp4"
pause

Extract metadata

ffmpeg -i input.mp4 -c:v copy -vbsf hevc_mp4toannexb -f hevc - | dovi_tool extract-rpu --rpu-out metadata.rpu -

Encode Dolby Vision

ffmpeg -i input.mp4 -f yuv4mpegpipe -strict -1 -pix_fmt yuv420p10le - | x265-10b - --input-depth 10 --output-depth 10 --y4m --preset veryfast --crf 22 --master-display "G(8500,39850)B(6550,2300)R(35400,14600)WP(15635,16450)L(40000000,50)" --max-cll "0,0" --colormatrix bt2020nc --colorprim bt2020 --transfer smpte2084 --dolby-vision-rpu glass.rpu --dolby-vision-profile 8.1 --vbv-bufsize 20000 --vbv-maxrate 20000 output.hevc

HDR10 to SDR

ffmpeg -y -ss 07:48 -t 60 -i input.mkv -vf 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 ultrafast -x265-params lossless=1 -an -sn -dn -reset_timestamps 1 movie_non_hdr.mkv