Handbrake/ffmpeg: What free video codec to use for 720p videos?

I have a lot of old movies, most will barely be 720p.

I ripped them off DVDs with MakeMKV and have sometimes 7GB files for 1,5h.

I want to convert them to something below 300MB, I often see more modern torrented movies below that size, so this should totally be possible.

They will only ever be played with VLC (Windows) or Celluloid/MPV (Linux) with hardware decoding.

But what codec to use? h264 and h265 are nonfree, arent they? But Videolan has some free variant of it and Cisco also offers their free version for h264?

Never heard of VP8 and VP9. Then there is AV1 but that seems to only have "264K 360° Surround sound 3D VR" options.

Man I just want to encode normal movies 🥲

What about webm? That is under "web" but probably also good?

I suppose I should use h264 for compatibility, but the web stuff will also be compatible. I would like the best and fanciest algorithms to have least dataloss.

Also, what to use for the audio? I think opus is best.

Thanks!

Majestic ,

DVD's max out at about 580p (for PAL, NTSC is 480p), resolutions are measured by the number of horizontal lines of pixels (counted from top to bottom of video/screen), not vertical which at 4:3 square aspect ratio on dvds does tend to be 720 pixels (by contrast full resolution HD video's number of vertical lines is 1920 while it's horizontal lines are of course 1080, hence 1080p). You're not the first person to be confused by this.

Professional encoders who fully understand the encoders and the schemes in use and care about not seeing artifacting or low quality would never intentionally go as low as 300mb for a feature length movie of even an hour. Yes there are people who do such things but they're not well regarded and it won't look even passable on anything larger than a phone screen.

Recognized quality groups that seek low sizes might get an animated feature (less bitrate needed due to lack of fine detail in animation vs real film) in SD quality down to around that. But for most live action content the sizes I see from the best of the best concerned with smaller release sizes are in the 900mb to 1.5GB range for 60-90 minute features.

300mb for a 90 minute live action feature even in SD is just not going to look good, some of the groups who get those sizes make them look even half-passable by running pre-filters in virtualdub that smooth, reduce grain and detail, etc before passing to the encoder. That kind of thing is way beyond anything you're going to learn in a few youtube videos though, that's advanced stuff with scripting.

Think about it this way, if you shoot for 1GB encodes with 265 or AV1 you can store over 900 movies on a 1tb drive which can be had for well under a hundred dollars.

I would like the best and fanciest algorithms to have least dataloss.

There is no magic that will get you where you want. If you want detail preserved you need more bitrate which translates to larger sizes. Modern codecs like HEVC and AV1 mean you need as much as 1/5th the bitrate you needed with old MPEG2/4 encoding schemes used on DVDs, that's darn good savings but it has its limits.

Do as you will but anything live action (non-animated) significantly under 1000kbps average bitrate is going to look awful on a 1080p screen and much worse than what it would look like if you popped your dvd in the disc drive and played it from there.

Opus is fine if you're not worried about compatibility and just playing on a computer.

UnfortunateShort , (edited )

I encode everything with AV1 and Opus, although, as others have pointed out, there is the disadvantage that older (as in "not new") devices won't have hardware acceleration for those. I don't care about that tho, because 1080p runs just fine on decent CPUs and I want to encode for the future, not yesteryear.

For AV1 I use 10bit, VFR, RF25. If you want, you can play around with the performance profile to trade file size for encoding speed.

For Opus I use 320 kbit/s fixed Bitrate and 7.1 downmix. Note that when dealing with audio and subtitles, you absolutely should include tracks of 'unknown' language! Otherwise they are just thrown away. And of course you should include every other language you care about. You can also choose to pass through Opus encoded tracks automatically.

I prefer MKV as container format, because from all I hear it's flexible and robust. Pretty much everything else is set to default. I'd advise to safe your settings to a preset and to briefly verify encoded videos actually work and contain the desired tracks.

rotopenguin , (edited )
@rotopenguin@infosec.pub avatar

I believe h.265 has particular handling for "film grain". And it has hardware decoding on just about every chip out there. And you probably already have a hardware encoder, so you can do something like QSV in a reasonable time frame.

300MB for a half-hour is a pretty reasonable bitrate, for one and a half hours it is quite dire.

MangoPenguin ,
@MangoPenguin@lemmy.blahaj.zone avatar

I'd say it depends on what your hardware supports for encoding and for playback.

Best quality at small size = AV1

Good with decent support = h265

Best support = h264

digdug ,

The viewing options OP listed should all work with AV1, I think they were just worried by the preset names. Plus, hardware support should only get better.

OP, you should be able to adjust settings after you select a preset, so you can pick different dimensions/frame rates/audio codecs/etc.

Side note, I've found that the matroska container is the easiest one for me to use if I want better subtitle support.

the16bitgamer ,
@the16bitgamer@lemmy.world avatar

Look at the compatibility of the device you are running it on. Older hardware like the PlayStation Vita, will only work with H.264 AAC.

Handbranks is able to convert this for you with no issues (even on Linux flatpak ftw), and web playback on a Apache2 server is great. But if your planning on watching it on more modern devices, then don't worry too much about it.

exu ,
@exu@feditown.com avatar

If you want hardware decoding, first check what your gpu actually supports. vainfo can be used on Linux for example.

If you have a very new gpu, it might support av1 decoding. This is currently the best codec and alsi free.

Otherwise I'd prefer hevc and then avc, in that order. Vp8 or vp9 might also be supported, but they never caught on much so encoders and decoders are generally worse for them than the equivalents for other codecs.

I don't know any private person who was prosecuted for using hevc or avc. Most likely your hardware manufacturer and other companies already paid for the license to use hevc/avc. If you live in the EU it's even less of a problem as software patents are not a thing here, i.e. you can't patent a way to do things.

Foe audio opus is the best codec at the momenr.

Please make sure to compare the quality before and after decoding. Even using a more efficient codec I'd be wary of a 300mb sized movie.

boredsquirrel OP ,

Yes I do. Quality level 50 is for sure too low, but AV1 had 80MB, h264 had 120MB, quite nice.

I will try further and see what is best. Using AV1, opus and mkv

DaGeek247 ,
@DaGeek247@fedia.io avatar

Gpu encoding is terrible for anything that isnt fast encoding speeds. Best to use the cpu since this isnt for a live environment.

exu ,
@exu@feditown.com avatar

Totally agreed, but you'd still want gpu decoding.

Frederic ,

I'd use HEVC/H265 anyway, always, the best quality for its size. And AAC for audio

boredsquirrel OP ,

Why AAC and not opus for Audio? AAC takes away a ton of content, may not be relevant for these specific movies, but very relevant for music.

db2 ,

https://en.m.wikipedia.org/wiki/X265

Don't overcomplicate things.

stevestevesteve ,

AV1 and VP9 are likely going to be your highest efficiency "free" codecs. AV1 is the way to go if you mean free as in free open source. It's not very likely to be implemented in many TVs or set-top-boxes, but VLC/ffmpeg will be able to decode any of these. Webm uses vp8 or VP9 which are "free"(made by Google) but it's just more specific settings for sharing online/viewing in browser.

H264/H265 has license fees for non-free software and hardware, but they will be your most widely supported option. H265 is approximately twice as efficient as h264 (meaning you can get the same quality of encode from half the file size).

Regardless of preset I think you can get handbrake to encode something reasonable from any of these codecs. Especially with DVD video you'll be able to crank through videos with modern high efficiency codecs

just_another_person , (edited )

Well pretty much every DVD maxes at 480p for storage constraint purposes, so that might be your first issue. Ripping and encoding at a higher resolution than the source nets you nothing but wasted space.

That being said, HEVC is going to be the smallest file size for your rips, with reasonable encoding times and compatibility mostly not an issue.

AV1 is new-ish, so depending on your hardware, could take anywhere from 5x-10x longer, and only net you an average of 15% difference in size reduction, and then you have compatibility to worry about.

RmDebArc_5 , (edited )
@RmDebArc_5@sh.itjust.works avatar

I’d use AV1, there should be a normal option somewhere. It has higher quality to size ratio, but requires more performance. Webm mainly uses V9, which is not very efficient. Important for the size is also the setting, one codec can have different levels of compression.

Peter1986C ,
@Peter1986C@lemmings.world avatar

.webm is but a container, so it cannot be considered (in)efficient on its own, only when considering the video and audio "formats" (no expert on the terminology) within (probably VP8 or 9 for video).

leopold , (edited )

VP9 is AV1's predecessor and VP8 is VP9's predecessor. Dunno what the “264K 360° Surround sound 3D VR” thing is about, but AV1 is a good general purpose video codec and I recommend using it, with Opus audio.

EDIT: I should add, h264 and h265 are non-free because of software patents, for which there are licensing fees. There are free implementations and there always have been, but the extent to which these implementations can actually freely be used legally is limited by this. Cisco's OpenH264 is an exception, because there is a cap to the licensing fee and Cisco is already paying the max amount. This allows them to freely distribute binaries for their h264 implementation without having to pay additional licensing fees for every user. It's a clever loophole, but there are still limitations, namely that you have to be using Cisco's pre-built binaries. If you want to use the source code, you still need to pay for the licensing fee.

Because patents last twenty years and the initial release of h264 was made in August 2004, the key h264 patents should all expire within the next few years, which will eliminate the problem. h265 however was introduced in 2013 and its patents still have a good decade left in them.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • kbinchat
  • All magazines