Reducing MKV size with Handbrake without loosing too much quality

Please post here for issues related to UHD discs
davie
Posts: 4
Joined: Sun Sep 29, 2019 9:57 pm

Reducing MKV size with Handbrake without loosing too much quality

Post by davie »

Whats the best video settings for handbrake to reduce the size of a 4K BD rip size without loosing too much quality?
Woodstock
Posts: 9912
Joined: Sun Jul 24, 2011 11:21 pm

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by Woodstock »

This is not the handbrake support forum, and "too much quality" is subjective in any case.

Best way to not lose quality is to not encode, but that ship sailed when the disk master was created. The 1080p version is already smaller with good quality.
MakeMKV Frequently Asked Questions
How to aid in finding the answer to your problem: Activating Debug Logging
oddeyeball
Posts: 40
Joined: Wed Sep 18, 2019 8:20 am

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by oddeyeball »

Personally I would just use the regular blu-ray version as Woodstock suggested. If your 4k rip is a UHD one, do not use handbrake since it uses 8-bit processing and the 4k UHD video uses 10-bit. The colors will be washed out. If you really want to shrink that 4k video, I would do some research on google for it, its kinda of a pain.

Edit - My mistake, Handbrake actually has codecs for 10-bit so ignore the part where I say handbrake uses 8-bit processing only. Now I need to start messing with this new discovery for me, even though its been around for a long time........
Last edited by oddeyeball on Fri Oct 04, 2019 10:19 pm, edited 1 time in total.
MartyMcNuts
Posts: 2460
Joined: Wed Nov 22, 2017 11:45 pm

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by MartyMcNuts »

davie wrote:
Mon Sep 30, 2019 4:11 am
Whats the best video settings for handbrake to reduce the size of a 4K BD rip size without loosing too much quality?
A bitrate of 25 Mb/s.
Cheers :D
----------------------------------------------------------------------------------------------------------------------------
For UHD enabled drives (AU/NZ/SG) & DIY Single Drive Flasher (WW): https://www.uhdenableddrives.com
1wayjonny
Posts: 32
Joined: Wed Oct 31, 2018 12:03 am

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by 1wayjonny »

https://codecalamity.com/encoding-setti ... -bit-x265/

This should help as a starter, not sure about the loss of 10bit to 8bit being I see an update from 2017/2018 that can handle 10bit but that may be worth looking into in case I am wrong.

I have a 40TB adaptec raid and will leave the quality as it sits. Int he future time and size will not matter. Remember trying to store 5-10GB files? Its an after thought now. =)
oddeyeball
Posts: 40
Joined: Wed Sep 18, 2019 8:20 am

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by oddeyeball »

1wayjonny wrote:
Thu Oct 03, 2019 9:45 pm
https://codecalamity.com/encoding-setti ... -bit-x265/

This should help as a starter, not sure about the loss of 10bit to 8bit being I see an update from 2017/2018 that can handle 10bit but that may be worth looking into in case I am wrong.

I have a 40TB adaptec raid and will leave the quality as it sits. Int he future time and size will not matter. Remember trying to store 5-10GB files? Its an after thought now. =)
Oh, you're right. I never noticed they included the libraries for it because I already have presets already made. Previously I've had to download the libraries for night builds just to do it and now I finally clicked the video codecs and see the 10-bit ones listed. My mistake, that's what I get for just using the same presets for a long long time, lol
1wayjonny
Posts: 32
Joined: Wed Oct 31, 2018 12:03 am

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by 1wayjonny »

No worries at all, I have been interested my self and searched over time but never did the compress with my raid. But this thread forced me to search again and I came across that detailed article, saved it myself for potential future use. It was a nice write up.

Cheers
majstrzvasi
Posts: 3
Joined: Mon Oct 28, 2019 11:36 am

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by majstrzvasi »

Hi a did some testing in handbrake at a 30 second movie clip i extracted from a original 4k hdr movie. For me personaly a 2hour movie 2160p hdr rip compresed to arround 4 to 5gb is good enough quality.
Looking from my couch on my 43inch HDR tv i cant really benefit from higher bitrates and filesizes becasue diference is not noticable in my case.

For riping i use H265 10bit and constant quality. Becuase this way quality is always constant and it adapts bitrate to the scene complexity.

And there are presets. Slower the preset better the quality but also bigger the filesize. Slower the preset longer the riping times. Example on my intel i7 cpu 2 hour movie 4k resolution on medium preset it needs arround 20-30hours on fast preset it needs like 15-20hours.
ultrafast
superfast
veryfast
faster
fast
medium (default)
slow
slower
veryslow
placebo
For diferent presets diference in filesize is around 10-15% between each preset

RF settings is constant quality and lower the number better quality bigger the filesize.
Recommended settings for x264 and x265 encoders:
RF 18-22 for 480p/576p Standard Definition1
RF 19-23 for 720p High Definition2
RF 20-24 for 1080p Full High Definition3
RF 22-28 for 2160p 4K Ultra High Definition4
difference between each rf is quite big and it is around 30-40% in filesize.

So medium preset at 23rf has better quality and biger filesize than preset fast on 23rf. Also fast preset on 22rf shuld have similar quality and size as medium 23rf but fast preset would need shorter amount of time to process because the fast preset is not that demanding.

I made a graf of different presets and RF.
Results in the graf are filesize in MB
Image

So you can test this for yourselfs what i am talking about i made a 4k hdr rip 30second clip in diferent settings and you can download and check the quality.I would really appreciate if you try to play sthis clips on you home HDR tvs and tell me your opinions. Link to clips

[Link to copyrighted material removed]
Woodstock
Posts: 9912
Joined: Sun Jul 24, 2011 11:21 pm

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by Woodstock »

Loss of quality is a subjective matter. Any lossy encoding scheme loses quality by definition, with each pass through an encoder.

The key metric is, "Is the result acceptable to ME?" We aren't you, so our opinion isn't that relevant.

Also, the handbrake forum is a better place to discuss handbrake topics.
MakeMKV Frequently Asked Questions
How to aid in finding the answer to your problem: Activating Debug Logging
majstrzvasi
Posts: 3
Joined: Mon Oct 28, 2019 11:36 am

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by majstrzvasi »

Link of the clips is removed i gues even 30 seconds is too much for a copyright.
I must say only one thing today i tried the new x265 version 3.2 For 4k video on medium preset and rf 22 it realy does some amazing results at realy small filesize. Best is the riping time it is much faster it is as fast as x265 version 2.9 on fast settings.
Woodstock
Posts: 9912
Joined: Sun Jul 24, 2011 11:21 pm

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by Woodstock »

Rule of thumb in US copyright law is "up to 10 seconds" will often (but not always) be overlooked by courts in the US.

Other parts of the world? I cannot say, because I don't live there.
MakeMKV Frequently Asked Questions
How to aid in finding the answer to your problem: Activating Debug Logging
majstrzvasi
Posts: 3
Joined: Mon Oct 28, 2019 11:36 am

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by majstrzvasi »

Now i compresed like 10 4k hdr movies and decided to use the crf 20 at medium preset because at 22crf i noticed some minor color banding in realy demanding slow scenes and some loss of detail in large similar color areas.
Problem is the thing needs like 15-20 hours of work. I would go to the slow preset at crf 20 but then i am getting to 40+ hours.
My intel i7 realy has a hard time. I am considering a new cpu something like ryzen 9 3950x but i dont know how well the h265 10bit scales will it use all the cores does anione know?
Woodstock
Posts: 9912
Joined: Sun Jul 24, 2011 11:21 pm

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by Woodstock »

How many cores are useful varies, depending on choice of encoder and filters. You can find more information about this on the handbrake forum, where it has been discussed many times.

Generally, if you have more than 8 cores, and certainly with more than 12, the only speed-up you'll see is if you run multiple encodes at the same time. And some encoders have reduced quality if there are too many threads running.

Remember, you do not need to encode a complete video to test different parameters.
MakeMKV Frequently Asked Questions
How to aid in finding the answer to your problem: Activating Debug Logging
troyBORG
Posts: 18
Joined: Wed Mar 23, 2016 4:47 am

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by troyBORG »

I've been using ffmpeg to reduce mine.

This script will convert it from HDR to SDR, and make it 1080p, and cropping it to 2.35:1 aspect ratio..:

Code: Select all

ffmpeg -i "Cold Pursuit-FPL_MainFeature_DV_t00.mkv" -c:v hevc_nvenc -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,scale=1920:-1,crop=1920:800:0:140 -rc constqp -qp 24 -b:v 6000K -maxrate 12000K -max_muxing_queue_size 1024 -acodec copy -scodec copy "Cold Pursuit (2019).mkv"
It brought the file down to 4.5 GiB from its 55.6 GiB RAW version.
kfreeb
Posts: 102
Joined: Mon Aug 16, 2010 3:43 pm

Re: Reducing MKV size with Handbrake without loosing too much quality

Post by kfreeb »

In terminal on a Mac, using troyBorg's script I got this error message:

Just for kicks, I plugged in to terminal, one of my test 4K files, with the script troyBorg suggested on MakeMKV forums and this is the result:

PLUGGED IN: ffmpeg -i "Cars 2 4K 10-bit 33 Sec test.mkv" -c:v hevc_nvenc -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,scale=1920:-1,crop=1920:800:0:140 -rc constqp -qp 24 -b:v 6000K -maxrate 12000K -max_muxing_queue_size 1024 -acodec copy -scodec copy "Cars 2 4K 10-bit 33 Sec final.mkv"

Got this: ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Unrecognized option 'rc'.
Error splitting the argument list: Option not found

GOT RID OF: “-rc constqp” and got this:

ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, matroska,webm, from 'Cars 2 4K 10-bit 33 Sec test.mkv':
Metadata:
title : Cars 2
encoder : libebml v1.3.0 + libmatroska v1.4.0
creation_time : 2020-08-30T23:22:36.000000Z
Duration: 00:00:32.90, start: 0.000000, bitrate: 61620 kb/s
Chapter #0:0: start 0.000000, end 32.865000
Metadata:
title : Chapter 01
Stream #0:0(eng): Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc
Stream #0:1(eng): Audio: truehd, 48000 Hz, 7.1, s32 (24 bit) (default)
Metadata:
title : Surround 7.1
Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
Metadata:
title : Surround 5.1
BPS : 640000
BPS-eng : 640000
DURATION : 01:46:15.200000000
DURATION-eng : 01:46:15.200000000
NUMBER_OF_FRAMES: 199225
NUMBER_OF_FRAMES-eng: 199225
NUMBER_OF_BYTES : 510016000
NUMBER_OF_BYTES-eng: 510016000
SOURCE_ID : 001100
SOURCE_ID-eng : 001100
_STATISTICS_WRITING_APP: MakeMKV v1.15.2 darwin(x64-release)
_STATISTICS_WRITING_APP-eng: MakeMKV v1.15.2 darwin(x64-release)
_STATISTICS_WRITING_DATE_UTC: 2020-08-30 22:51:27
_STATISTICS_WRITING_DATE_UTC-eng: 2020-08-30 22:51:27
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
Stream #0:3(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 512 kb/s
Metadata:
title : Surround 5.1
BPS : 512000
BPS-eng : 512000
DURATION : 01:46:15.168000000
DURATION-eng : 01:46:15.168000000
NUMBER_OF_FRAMES: 199224
NUMBER_OF_FRAMES-eng: 199224
NUMBER_OF_BYTES : 408010752
NUMBER_OF_BYTES-eng: 408010752
SOURCE_ID : 001101
SOURCE_ID-eng : 001101
_STATISTICS_WRITING_APP: MakeMKV v1.15.2 darwin(x64-release)
_STATISTICS_WRITING_APP-eng: MakeMKV v1.15.2 darwin(x64-release)
_STATISTICS_WRITING_DATE_UTC: 2020-08-30 22:51:27
_STATISTICS_WRITING_DATE_UTC-eng: 2020-08-30 22:51:27
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
Unknown encoder 'hevc_nvenc'


ANY IDEAS ON HOW TO FIX THE SCRIPT?
2 x 3.46 GHz 6-Core Intel Xeon (mid 2012)
64GB Memory
Mac OS X 10.14.6
Post Reply