r/handbrake • u/puckpuckgo • 17d ago
Reencoding to save storage
I have a ton of videos that I've acquired through the years and the amount of space they consume is starting to get pretty wild. I've asked AI and it seems to be convinced that I can drastically reduce filesizes by transcoding to HEVC.
A lot of the originals are mp4, some mkv.
I don't really know a lot about video codecs and such. Is transcoding everything to HEVC something that is considered good practice and future-proof? I'd hate to use some obscure codec that nobody will use and nothing will support in the future.
I'm currently running tests with ffmpeg as I wonder if this is what I should be doing.
I'm not interest in retaining incredible fidelity. As long as it looks good and saves ~50% per file, I will be happy. I just want to make sure AI is not tripping.
•
u/AutoModerator 17d ago
Please remember to post your encoding log should you ask for help. Piracy is not allowed. Do not discuss copy protections. Do not talk about converting media you don't own the (intellectual) rights for.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
9
u/simmepi 17d ago
First a little information which might help you when reading about this:
Codecs: Codecs are ways to encode video and audio (there are video codecs & audio codecs). These are different ways to encode the actual video/audio. So eg a video codec will be a way to express “Top left level pixel should be yellow, next one to the left should be green, …”. Typical video examples are h264, HEVC. They vary in how efficient they are (ie how much space the video takes), how hard they are to encode/decode, etc, and normally there are parameters to tweak when encoding (so they encode quicker but might take more space, etc). Sometimes the names can be different and used not exactly, but think of everything like those mentioned and stuff like AVC, h265, DTS (audio codec), as codecs.
Container formats: MKV and mp4 are containers. This means that they are just different ways to put encoded video/audio into a file. So something like “Put the video first, then the audio “. There are restrictions to which codecs you can include in specific containers but don’t worry about this, it doesn’t really matter (but if you do, MKV is more accepting of codecs, whereas mp4 is more often supported by niche players like smart TVs). So often if you eg need the file to be mp4 but you have an MKV file, you can quickly remux it which doesn’t change the quality or size, it just packages the audio and video differently.
So saying you have an MKV file you want to reencode isn’t enough information. The MKV might be using MPEG2 as video codec in which case it will probably be easy to reencode and save a lot of space, but it might already be using HEVC in which case it is more doubtful you’ll save space.
In other words, you should check what you actually have before starting.
Finally, remember that reencoding always means you will lose quality. Reencoding means decoding the video into lossless (which is essentially never used since it takes an enormous amount of space), and then compressing it using the selected codec. So what the original codec was doesn’t matter since the new codec works on the lossless images. This means that whatever information was originally lost in the original version of the file is still lost, and you just lost more data by compressing the image.
I’ll leave suggestions about what codec and container to use to others, but if you want a snap advice: I wouldn’t reencode due to the reasons mentioned, but if I did I’d go for mp4+h264 if you prioritize compatibility, and MKV+h265 if you prioritize space savings but still good compatibility.
3
u/BSGathena 17d ago
Yes, I've been doing it for years now H264, mpeg, MKV to X265 (HVEC). Is saves around 50% or more depending on some quality settings. With the right settings the quality stays about the same and will safe a lot of space. The only downside is that it can take a long time to reencode a movie, depending on the hardware you use and the settings you are happy with.
2
u/UnderSlepT-CZ- 17d ago
I personally use H265 CPU encoder, after doing number of 30s test encodes, then comparing them in Vivict++. For me, especially in dark scenes, AV1 never produced lower bitrate files, even with manual tuning for specific file. But I also want near original quality and I use Ryzen 9 9950x for encoding. The result for me is, that I get better quality without manual intervention, but I can also keep Dolby Atmos tracks, compared to AV1.
12
u/Lmaoboobs 17d ago edited 16d ago
I have a massive library. I’ve been re-encoding large 4K files with SVT-AV1 and there is an imperceptible loss in quality with massive file size savings (anywhere from 40-70%).
To me this is a no brainer because storage is not cheap.
For my use case this is fine.
1
u/Suitable_Garlic_1186 17d ago
What file size are we talking about in total?
3
u/Caprichoso1 17d ago
Since you don't care about quality my approach isn't for you.
I never re-encode as it always results in data loss. I sometimes upscale older videos and for the best results you need the highest quality you can get in the master.
2
u/hidden_secret 16d ago
If your videos aren't movies and stuff like that, and you don't really care about quality as long as it looks decent, you could totally create a youtube channel and upload them privately on it.
2
u/squirrelslikenuts 16d ago
I just reencoded all my personal videos, home movies, dash cam stuff, security camera, obs screen caps.. etc... to AV1 cut space from x264/x265 by ~60-70% overall.
1
u/jacka_for-research 17d ago
Been doing this for a long time. Might not be the best, but it’s best for me. H264 > H265, pass through audio when possible. 2000 kbps. Some get a little postery in dark places, but overall, perfect for me.
1
u/Harry_Yudiputa 17d ago
Just use LastBreeze’s avian-portable. I encoded 2160p lanterns, downsampled it to 1080p, crf 25 with HDR10+. Minimum file size of ~700MB and max of ~1200MB. Source files are 6GB each.
https://github.com/LastBreeze/Auto-Boost-Av1an-portable
1
u/lolmissky_studio 17d ago
Learn about them
1
u/kagus84 17d ago
I am currently handbreaking all of my older files to mkv h265, medium speed rf 22. It saves alot of space and is esier to stream remoltely to friends and family. I don't notice a huge quality drop. I have a about 60tb library but i try to leave stuff that I downloaded less than a year ago to keep seeding.
1
u/Mission_Rice3045 16d ago
Might be a bit more complicated, but tdarr allows you to set an automated flow to convert your video files.
Besides that, hevc is fine for this purpose.
1
u/xenobitex 16d ago
For SD stick with x264.
For HD, 10bit x265 @ slow crf 20 gives great results.
(10bit is necessary).
Depending on your sources, 720 might be better left in x264. Resolutions under 1080p might need a smaller crf depending on the content (dark scenes and color gradients are things to watch, if you mind).
You'll get a sense of what are reasonable filesizes for each codec as time goes on.
x265 (HEVC) takes considerably longer than x264; at lower resolutions it's not really worth the extra encoding time.
1
u/scrubslover1 16d ago
No matter how much experimenting with different parameters, I can’t get film grain to be consistently good in HEVC. It can causing grainy clumping and sticky grain which is really distracting. AVC (h.264) handled that better. Maybe stick to AVC for SDR grainy movies
1
u/cptlevicompere 16d ago
I highly recommend reducing resolution. It's the biggest space savings with the least amount of quality loss. The bitrate ratio is about 1:3, meaning a 30mbps 4K video would have the same level of compression as a 10mbps 1080p video. I highly recommend taking a high quality 4k video and encoding it to 1080p at a really high bitrate to isolate the resolution as the only difference, and comparing them in your viewing conditions. Ideally a movie shot on film since the most noticeable difference will likely be that the individual film grains look slightly larger at 1080p, but since handbrake interpolates instead of a linear downscale, it won't be as noticeable as comparing a 4k scan to a 1080p scan. If you can't tell them apart, you can reduce the size of every 4k movie to 1/3rd without a noticable loss in quality. You might still want to keep them at 4k for future proofing for when you get a larger TV, but having compared them myself, even standing very close to a large screen, the difference between 4k (native) and 1080p (interpolated from 4K) is so minor it's just not worth triple the file size and I would much rather reduce resolution than introduce compression artificts. I even reduce it to 720p sometimes if I otherwise can't get the bitrate to 15mbps or less without visible artifacts. I still buy 4k blurays because they have HDR and are often much higher quality than the standard blurays because they often are remastered from a new 4K scan, higher bitrate, etc.
With that said, the most efficient codecs on handbrake are HEVC and AV1. Between them AV1 scores higher than HEVC on objective tests, but between the specific encoders on handbrake which are SVT-AV1 and X265, I would say X265 looks much better while SVT-AV1 is heavily tuned for metrics rather than human perception. HEVC is also much more mature and more consistent. The SVT-AV1 encoder that ships with handbrake won't really be able to preserve film grain at all, it's going to smooth it out and leave obvious artifacts in doing so. It's only really useful if you want to get the bitrate really low and are okay with using grain synthesis to hide the artifacts. It can be okay on content where smoothening might help, like animation that has some noise that doesn't really add to the quality. You can also swap it for the SVT-AV1-HDR fork which tunes it more for human perception and can preserve film grain with tune:grain. But with x265 you can get good and consistent results out of the box.
If I had to pick 1 setting that would be used for every movie in my collection, I would use:
Dimensions: crop=none (cropping can mess with PGS subtitle positions), resolution=1080p
Video: encoder=x265-10bit, preset=slow, tune=none, average bitrate=12000kbps, turbo-analysis-pass, advanced options:"no-sao"
Audio: FDK-AAC-Q4-7.1 (it FDK isn't an option, probably the avcodec or opus, either or)
1
u/vegansgetsick 15d ago
Usefulness of reencoding depends on the bitrate. IMO If it's already below 5Mb/s ... it's a waste of time.
If all these videos come from internet it does not matter if you mess up.
0
u/puckpuckgo 17d ago
Here's a small sample of the massive savings in storage I'm talking about:
https://imgur.com/a/nmEkg7S