View Full Version : Recode UHD Bluray ?
Nico8583
16th May 2018, 19:25
Hi,
I would like to try to recode one of my UHD Bluray, just to reduce the video size.
Is it possible to do it and keep all UHD characteristics, so just reduce the bitrate ?
Thank you !
Asmodian
16th May 2018, 21:05
I know DVDFab can do it but I do not know of a free option.
ffmpeg can encode HDR if you do not need to keep the disc structure.
Nico8583
16th May 2018, 21:46
Thank you.
I didn't like the DVDFab H264 quality but I don't know if it's better now.
I prefer to use a quality tool like ffmpeg or x265 and I don't need to keep the disc structure, a MKV is OK :)
Asmodian
16th May 2018, 22:04
Then this thread (https://forum.doom9.org/showthread.php?t=174491) is what you are looking for. :)
Nico8583
16th May 2018, 22:21
Thank you, I read it but I find it difficult to draw something concrete :(
FranceBB
17th May 2018, 00:29
Take the latest build of ffmpeg, x265 and mkvmerge and put them together in the same folder called "encoder".
ffmpeg build: https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20180508-293a6e8-win64-static.zip
x265 build: http://msystem.waw.pl/x265/x265-2.7+348-0968a46_gcc81.7z
mkvmerge: https://www.videohelp.com/download/mkvtoolnix-64-bit-23.0.0-setup.exe
Create a new text file (.txt) and rename it ".bat"
Paste the following command in it:
ffmpeg.exe -i "file.m2ts" -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 3 --rc-lookahead 5 -b 3 --profile main10 --crf 18 --deblock -4:-4 --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)" --overscan show --no-open-gop --min-keyint 1 --keyint 24 --repeat-headers --rd 3 --vbv-maxrate 25000 --vbv-bufsize 25000 --wpp -o "raw_video.hevc"
ffmpeg.exe -i "file.m2ts" -vn -sn -c:a ac3 -b:a 384k -ar 48000 "raw_audio.ac3"
mkvmerge.exe --output "raw_video.mkv" --language 0:und ^"^(^" raw_video.hevc ^"^)^" --language 0:und ^"^(^" raw_audio.ac3 ^"^)^" --track-order 0:0,1:0
pause
CRF is set at 18; if you lower it down you will increase quality, if you set it higher than 18 you'll lower the quality. I think 18 is gonna be a good compromise, but it's really up to you.
Double click on the .bat file and it will encode video and audio and mux them in an mkv file called raw_video.mkv.
Make sure your input file is called "file.m2ts". You have to change it if it's different. ;)
Nico8583
17th May 2018, 07:03
Thank you very much, I'll try it :D
Nico8583
17th May 2018, 09:00
I've tried it and there is an error : lookahead depth must be greater than the max consecutive frame count
If I change "--rc-lookahead" value from 3 to 20 (I don't know what value must be set), it works.
FranceBB
17th May 2018, 14:06
I made a typo, my bad. Yep, --rc-lookahead 5 is gonna be fine, but you can increase it if using more RAM is not a big deal. ^_^
Nico8583
17th May 2018, 14:11
No problem, thank you to answer :)
It uses more RAM only to encode or encode/decode ?
Asmodian
17th May 2018, 18:28
Those are pretty low quality settings for x265. Do you need fastdecode or a max keyint of 24? I suggest --tune slow, --rc-lookahead 40, and --keyint 240.
The extra RAM used for rc-lookahead is only when encoding.
edit: also remove no-high-tier. ;)
Thanks for the command line FranceBB.
Nico8583
17th May 2018, 20:54
Thank you but do you say to remove --tune fastdecode or replace it ? --tune slow doesn't seem to exist, do you what to say --preset slow ? :)
Thank you !
Asmodian
17th May 2018, 21:14
Oh sorry, yes. No tune at all in x265. :o
Nico8583
17th May 2018, 21:41
No problem :)
And what about min-keyint ? Still 1 or higher ?
Asmodian
17th May 2018, 23:41
min-keyint of 1 is fine, it should only use a key frame if it is helpful.
Nico8583
18th May 2018, 07:28
Thank you, I launch my encode to try ;)
Nico8583
18th May 2018, 08:32
Other question : --vbv-maxrate 25000 --vbv-bufsize 25000 and --level 5.0 are not too "limited" ?
Asmodian
18th May 2018, 10:27
Those are quite reasonable options but there is not a strong reason to use them if you simply intend to watch it on a computer. Also set --ref 4 instead of --ref 3 if you want, that is still very compatible and gives a better quality/size ratio. Or remove the --ref option and set the many speed/quality options with a --preset. There are other debatable options in that command line too, like --deblock -4:-4, I would probably go with -2:-2 or even -1:-1 myself.
Nico8583
18th May 2018, 10:37
Thank you :)
I'll try without --vbv-maxrate and --vbv-bufsize and I'll set --level 5.1, --ref 4 and --deblock -1:-1.
If you have any other comment please let me know, I'll try all in order to compare ;)
excellentswordfight
18th May 2018, 12:01
Thank you :)
I'll try without --vbv-maxrate and --vbv-bufsize and I'll set --level 5.1, --ref 4 and --deblock -1:-1.
If you have any other comment please let me know, I'll try all in order to compare ;)
In my experience just using preset slow and using a level thats compatible with your target decoder works absolutly fine. Other then that the only one that I found very usefull is --no-sao for encodes that dont have a very limited bitrate (that option gives better fine detail retention).
I agree with excellentswordfight. :)
--preset slow, --no-sao and a CRF below ~20 is all you need for a transparent UHD-BD encode.
In my experience, --keyint 120 or --keyint 96 (and --min-keyint 1) are good trade-offs between seeking compatibility and bitrate savings.
Nico8583
18th May 2018, 13:07
Thank you both, I'll try that ;)
Boulder
19th May 2018, 15:20
What about these values:
--colorprim bt2020 --transfer smpte2084 --colormatrix bt2020nc --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,0.0050)"
Do you need to pick them from the source characteristics, i.e. are they distinct for every source?
Asmodian
19th May 2018, 22:50
The first bit is for anything BT.2020.
However, the --master-display command describe the primaries used, the white point, and the luminance (peek white nits and black level nits) for the mastering display. You would probably only need to change the L(1000000,0.0050) for different sources. I think most of my UHD blurays' metadata uses L(4000,0.0050) or L(1000,0.0050). The example command seems to be setting peek white of the mastering display to 10 million instead of 10 thousand? Isn't 10 thousand the max? :confused:
FranceBB
20th May 2018, 00:34
If he can take them from his source, it would be better, 'cause my line was just an example of common settings.
user1085
21st May 2018, 18:28
If he can take them from his source, it would be better, 'cause my line was just an example of common settings.
So look for these values with Mediainfo and replace?
FranceBB
21st May 2018, 23:04
Yes, check media info, it should provide the original information.
Boulder
22nd May 2018, 04:13
What if all the values are not available? For example, The Last Jedi video file has this information:
Color range : Limited
Color primaries : BT.2020
Transfer characteristics : PQ
Matrix coefficients : BT.2020 non-constant
Mastering display color primaries : Display P3
Mastering display luminance : min: 0.0020 cd/m2, max: 1000 cd/m2
In fact, the couple of videos I could check had only these values there.
Asmodian
22nd May 2018, 05:01
That is all the information. You simply need to look up what "P3" means in terms of:
--master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(1000,0.0020)"
(I believe these values are for P3, with the standard D65 white point)
While the luminance values inform:
--master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(1000,0.0020)"
user1085
22nd May 2018, 06:12
That is all the information. You simply need to look up what "P3" means in terms of:
--master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(1000,0.0020)"
(I believe these values are for P3, with the standard D65 white point)
While the luminance values inform:
--master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(1000,0.0020)"
Similar question to poster above, what about the last two values (Maximum Content Light Level & Maximum Frame-Average Light Level). This is from Dark Knight Rises
Transfer characteristics : PQ
Matrix coefficients : BT.2020 non-constant
Original source medium : Blu-ray
Mastering display color primaries : Display P3
Mastering display luminance : min: 0.0050 cd/m2, max: 4000 cd/m2
Maximum Content Light Level : 500 cd/m2
Maximum Frame-Average Light Level : 200 cd/m2
Boulder
22nd May 2018, 06:15
Thanks :) I think I also saw "P2" in some video but I need to make sure since I just made some quick checks.
Regarding the L value, is it OK to use the values directly or do they need to be normalized? The x265 docs say that for L(max=1000, min=0.0001) the parameter would be L(10000000,1). It probably must be calculated as per the docs: "The SEI includes X,Y display primaries for RGB channels and white point (WP) in units of 0.00002 and max,min luminance (L) values in units of 0.0001 candela per meter square" so you need to divide the L value shown by MediaInfo by 0.0001?
EDIT: also, what about the "transfer" value? It's PQ but what's the correct parameter in x265?
Asmodian
22nd May 2018, 19:22
You are correct, I see why it looked like 10 million instead of 10 thousand. No decimal points.
Not sure about PQ, I would leave it smpte2084 for HDR but there may be situations where this is incorrect. :o
tyler durdan
23rd June 2018, 02:06
Hi all
I just wanted to resurrect this.
I have a number of UHD rips that I really want to reduce the size
while keeping the video as transparent as possible.
I went through this thread and others but I seem to get lost.
The last encoding I have done was 1080p with Staxrip where I just had CRF @ 18, preset to very slow and tune to film.
That was it, where as now UHD seems alot more complicated
Can someone point me to the right GUI i should be using please and what settings
Thanks
MeteorRain
27th June 2018, 19:18
Tyler:
The only difference is the visual parameters as suggested above. All you need is copy-paste from #23 and change some numbers according to mediainfo results.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.