Reducing file size while keeping features

MKV playback, recompression, remuxing, codec packs, players, howtos, etc.
Post Reply
Midwest Mike
Posts: 6
Joined: Tue Sep 21, 2021 6:43 pm

Reducing file size while keeping features

Post by Midwest Mike »

First I'd like to say that if these questions are basic, or have been asked and answered once or many times before, I apologize and appreciate links to the previous threads with answers. I have tried searching the forums but haven't come up with the answers and just the file processing and playback forum has over 1K topics, so trying to find the answers by browsing could take hours.

Like everyone here (I imagine) I have converted many (hundreds) of my DVDs & BluRay discs to .mkv files. I use that format as opposed to ripping to .mp4s, as .mkv files can keep multiple audio tracks as well as multiple subtitle / closed caption tracks that can be switched on and off when playing back with VLC or other software. Unfortunately the resulting .mkv files are usually huge, and will exceed 30GB for a longer movie. (Note, none of what I've converted is 4K content.) With extra features, some discs take up 50GB or more of drive space. I've long since filled my 4 and 6TB drives, and even a 14TB is starting to look crowded.

I would like to convert and compress my .mkvs to another format which can keep the multiple audio and subtitle tracks, but with significantly smaller file sizes. I am not obsessive about resolution. 720p (or for older stuff even 480p) is fine. I primarily would like to keep the option of switching to the creator audio commentary or turning subtitles on & off, etc. but do not know if any format besides .mkv natively supports this. Is there a way to embed the subtitles and extra audio into something much more compact, like .mp4? I know that .srt files can be paired up with video for subtitles, but then it seems there can be syncing issues, so you have to go into the player settings to adjust the subtitle timing. That hasn't happened with any of them embedded in the .mkv files.

I do have Handbrake as well as other video converters I've gotten from sites like GiveawayOfTheDay. In my case it's a matter of ignorance of what formats can do what I want, which programs can best accomplish that, and then how to actually do it.

Thanks in advance to anyone who knows the answers to these questions. Again, if it's been asked and answered before, please link to those threads and I'll read them. I simply haven't been able to find them on my own.
dcoke22
Posts: 2631
Joined: Wed Jul 22, 2020 11:25 pm

Re: Reducing file size while keeping features

Post by dcoke22 »

The .mkv format is what is known as a container. That means the video format that's inside of it can be all kinds of things. Blu-rays, for example, are generally either h.264 or VC-1. MakeMKV doesn't change what's on the disk when it goes into the .mkv container. 4K UHDs have h.265 video on them, and that's what will end up in a .mkv were you to rip one.

The program MediaInfo can show details like this about media files.

So, you can continue to use the .mkv container because it is well supported and has a lot of useful features. You can also transcode the audio and video from your rips into whatever you'd like to be able to save space.
dcoke22
Posts: 2631
Joined: Wed Jul 22, 2020 11:25 pm

Re: Reducing file size while keeping features

Post by dcoke22 »

Assuming you choose to use the .mkv container (I think you should; it is good default choice and if you're not using it, you should be able to articulate why), they key question then is what format to transcode a rip into and how to do it? Everyone here has an opinion, and there are all kinds of threads here on this topic.

The easy answer for how to do it is using Handbrake. It is well supported, it can output into a .mkv container (although I think it chooses .mp4 by default), and it can transcode from just about any format into any of the reasonable format choices. As you've discovered, there are all kinds of programs for this task, but sticking with Handbrake is a good place to start.

As for what format to transcode into, I think h.264 is a good choice. It isn't the newest or the most advanced. But it is well supported just about everywhere. Almost anything is powerful enough to play a h.264 video. Also, lots of things have hardware support for encoding h.264 video.

Other reasonable choices include h.265 video. This is what is used on 4K UHDs. The playback hardware requirements are higher than h.264, but support for it generally pretty good. I wouldn't choose this format until I was sure it would work everywhere. It is a lot more work to encode a video into this format than into h.264.

The final choice worth mentioning is AV1. YouTube is starting to use this format. There's a good chance that this format will be the future of video, but right now it is the Star Trek future. There's not a lot support for this codec either for encoding or playback.
dcoke22
Posts: 2631
Joined: Wed Jul 22, 2020 11:25 pm

Re: Reducing file size while keeping features

Post by dcoke22 »

What can you achieve with h.264? My rip of The Lego Movie (2014) is 22GB. The video portion of that 17.7 GB (in h.264 format) and the rest is audio and subtitles, etc.

I happen to use a Mac, an older one with an Intel CPU (a core i5 7600K). This is a 6 generation old Intel chip (the 13xxx series is current) but it supports Intel's hardware encode/decode stuff called Quick Sync Video. Handbrake also supports this. Using h.264 and a target bitrate of 9000 and hardware encoding (via Handbrake) I ended up with a 6.76 GB 1080p file. Of that 5.61GB is the video portion. To a casual viewer, that's probably indistinguishable from the original blu-ray. That took my 6-year-old computer 15 minutes and 6 seconds.

I also encoded the movie using a more advanced two-pass h.264 process using the software based encoder and a 5000 target bitrate. This runs only on the CPU. This output looks as good as or better than the hardware encoded version. The file is 4.24 GB, of which around 3.75GB is the video.

Finally, I have encoded the file into a 10-bit, h.265 format, using the software based h.265 encoder and a 4000 target bitrate. That file is 3.56 GB, of which about 2.8GB is video. That took 4 hours, 24 minutes. This is highest quality version, but watching this version and comparing with a critical eye to the hardware encoded version, I think most people wouldn't be able to tell them apart.

As you can see, there's diminishing returns from working to achieve smaller encoded file sizes. For most people most of the time, being able to transcode a blu-ray down into about ⅓ of the space with not much loss in quality and in not much time is a pretty good tradeoff.
dcoke22
Posts: 2631
Joined: Wed Jul 22, 2020 11:25 pm

Re: Reducing file size while keeping features

Post by dcoke22 »

I like to point out to people that one of the most time consuming parts of digitizing your movie library is getting all the bits off the disc. Once you've got those rips, you should consider keeping them, even if you also transcode them into a smaller format. Whatever choice you made for transcoding today, you'll likely make a different choice in the future. If you have your original rips (on an external HD in your closet maybe), you can relatively easily pull those out and transcode them again. If you had to rip them from the discs again, would you?
mattiswise
Posts: 11
Joined: Fri Jun 23, 2023 6:07 am

Re: Reducing file size while keeping features

Post by mattiswise »

dcoke22 wrote:
Tue Jun 13, 2023 2:16 pm
What can you achieve with h.264? My rip of The Lego Movie (2014) is 22GB. The video portion of that 17.7 GB (in h.264 format) and the rest is audio and subtitles, etc.

I happen to use a Mac, an older one with an Intel CPU (a core i5 7600K). This is a 6 generation old Intel chip (the 13xxx series is current) but it supports Intel's hardware encode/decode stuff called Quick Sync Video. Handbrake also supports this. Using h.264 and a target bitrate of 9000 and hardware encoding (via Handbrake) I ended up with a 6.76 GB 1080p file. Of that 5.61GB is the video portion. To a casual viewer, that's probably indistinguishable from the original blu-ray. That took my 6-year-old computer 15 minutes and 6 seconds.

I also encoded the movie using a more advanced two-pass h.264 process using the software based encoder and a 5000 target bitrate. This runs only on the CPU. This output looks as good as or better than the hardware encoded version. The file is 4.24 GB, of which around 3.75GB is the video.

Finally, I have encoded the file into a 10-bit, h.265 format, using the software based h.265 encoder and a 4000 target bitrate. That file is 3.56 GB, of which about 2.8GB is video. That took 4 hours, 24 minutes. This is highest quality version, but watching this version and comparing with a critical eye to the hardware encoded version, I think most people wouldn't be able to tell them apart.

As you can see, there's diminishing returns from working to achieve smaller encoded file sizes. For most people most of the time, being able to transcode a blu-ray down into about ⅓ of the space with not much loss in quality and in not much time is a pretty good tradeoff.
so do i use handbrake or the program you linked to encode video to smaller size? have a guide on this process by any chance?
dcoke22
Posts: 2631
Joined: Wed Jul 22, 2020 11:25 pm

Re: Reducing file size while keeping features

Post by dcoke22 »

Handbrake is probably the best place to start.

Everybody has their favorite way to use it. I'm not aware of any good tutorials off the top of my head, but undoubtedly there's a ton of them out there.

I'll tell you how I use it with a standard 1080p blu-ray.

Open Handbrake and load your .mkv rip from MakeMKV. Choose 'Open Source' in the upper left corner if necessary. (A side note, since I keep my rips, I make sure names and flags are correct in my .mkv rip since for a lot of tools, that stuff is 'pass-through' into the transcoded file.)

On the Summary tab, in the format section, pick MKV. It probably defaults to MP4.

On the Dimensions tab I leave the defaults.

On the Filters tab I leave the defaults. (Film grain is feature, not a bug in my view. If you feel the opposite, this tab will be different.)

On the Video tab, here's where things get interesting. For the video encoder, there are a lot of choices. Since I'm on a Mac, if I want to use hardware acceleration, I choose one that says 'VideoToolbox' since that's Apple's name for hardware accelerated encoding. On a Windows computer, it'll be named something else. The ones named 'x264' or 'x265' are not hardware accelerated and will only run on the CPU. Unless your CPU is particularly slow (or you're really impatient) I recommend a two-pass x264 setup.
H.264 (x264) for the Video Encoder. Framerate doesn't matter much as long as the radio button for Peak Framerate is selected. When this is the case, the frame rate in the box is the maximum frame rate that Handbrake will allow. If the movie's frame rate is lower, then the lower frame rate will be used. For 'Quality' I recommend Average Bitrate with a rate of 5000 kbps. Make sure 2-pass encoding and Turbo first pass are checked. For Encoder Options I leave it at the default: Tune none, Profile main, Level 4.0.

(The video tab settings can be a religious war for people. Lots of people will have a different view on the settings there and that's great. In my experience a 2-pass, x264 with an average bit rate of 5000 provides a good balance between speed, quality, and file size. To each their own.)

On the Audio tab, I usually set the codec to AC3, the mixdown to 5.1 channels, and the bitrate to 640 for the main audio track (assuming the main audio is a lossless TrueHD or DTS-HD track) since plain old 5.1 AC3 works best in my home theater. You might want passthrough audio or whatever. If there's a commentary track, I add that here.

On the Subtitles tab, I add the English subtitles. I don't generally watch movies with the subtitles on, but they can be in the resulting file so someone can turn them on if necessary. Forced subtitles are a topic all on their own, but by default if a track is marked as forced in the .mkv rip, I think Handbrake will 'burn' them into the transcoded output. This is a reasonable default, but not my preference. It depends on the needs of your playback setup.

On the Chapters tab I leave the defaults, which is just a passthrough of whatever is in the .mkv source file.

On the bottom of the screen, on the 'Save As:' line, make sure you like the name and the output folder.

I usually to Add To Queue and then start the queue.
Last edited by dcoke22 on Sat Jan 27, 2024 4:33 pm, edited 1 time in total.
dcoke22
Posts: 2631
Joined: Wed Jul 22, 2020 11:25 pm

Re: Reducing file size while keeping features

Post by dcoke22 »

Full disclosure, I rarely use Handbrake as I described above. I use Handbrake's CLI along with some Ruby code and a bash script to do exactly what I've described doing in the Handbrake GUI. If the previous sentence doesn't confuse or scare you, try Lisa Melton's More Video Transcoding.
Last edited by dcoke22 on Sat Jan 27, 2024 4:27 pm, edited 1 time in total.
Radiocomms237
Posts: 371
Joined: Mon Oct 18, 2021 12:23 am

Re: Reducing file size while keeping features

Post by Radiocomms237 »

One thing I've been meaning to experiment with but never seem to find the time...

You know how a movie might have a native aspect ratio of (let's say) 2.40:1 but the video track gets put on a Blu-ray at 16:9 (1.78:1), well, assuming everything else being equal, is there any saving (file size-wise) to be had by cropping the video back to 2.40:1 and letting the player add the black bars?

In it's native form the 2.40:1 frame size might be 1920x800px but off the Blu-ray it's 1920x1080px, based purely on my dodgy mathematics, I think that's 35% more pixels than we actually need.

Would that translate to an equivalent file size reduction?
Billycar11
Posts: 3820
Joined: Sun Aug 24, 2014 5:49 am

Re: Reducing file size while keeping features

Post by Billycar11 »

Radiocomms237 wrote:
Mon Jul 10, 2023 9:34 am
One thing I've been meaning to experiment with but never seem to find the time...

You know how a movie might have a native aspect ratio of (let's say) 2.40:1 but the video track gets put on a Blu-ray at 16:9 (1.78:1), well, assuming everything else being equal, is there any saving (file size-wise) to be had by cropping the video back to 2.40:1 and letting the player add the black bars?

In it's native form the 2.40:1 frame size might be 1920x800px but off the Blu-ray it's 1920x1080px, based purely on my dodgy mathematics, I think that's 35% more pixels than we actually need.

Would that translate to an equivalent file size reduction?
I would assume the difference is negligible there would be a savings but not worth the time to reencode all compression formats since mpeg 2 only look for a difference from 1 frame to the next if there is no change there is no size added.
Obviously this is not perfect the encode boxes splice up the picture so some of it maybe over lapping with moving parts of the frame every revision of compression is making these boxes smaller so less can be overlapping.
Buy a UHD drive from the guide and how to video maker: https://www.makemkv.com/forum/viewtopic ... 20&t=17831
UHD Drives Guide: https://www.makemkv.com/forum/viewtopic ... 16&t=19634
Auto flash kit $25 Email me for one Billycar5924@gmail.com
clenchdwarf
Posts: 10
Joined: Tue May 29, 2012 12:12 am

Re: Reducing file size while keeping features

Post by clenchdwarf »

Encoding black bars should take a negligible bandwidth, so I doubt you'd see any reduction in file size from recompressing after cropping.
Post Reply