In which format to store home made videos

6

3

TL;DR: my home videos are taking up too much space and are impractical to backup on Dropbox. Which format do you advice to convert them to?

Long version:
One year ago I bought a new compact camera (Canon SX230HS), so I could make nicer pictures and movies of my daughter. While the quality is a big improvement over my previous camera, the filesize of the resulting files also is a lot bigger, especially the movies. In the previous year I produced as much data as in the 8 years before. This is becoming a problem, because I’d like to backup everything on Dropbox, so I'd like to avoid having to backup several gigabytes a month.

I already configured my Canon to shoot in 1280x720 instead of 1920x1080, but this still results in 150 - 200Mb per minute in H.264.
Because those movies are only intended to be viewed by family and friends and posted on youtube/facebook, I'm thinking about converting them to another format. This will obviously lose some quality but I don't think this is a problem, afterall only 10 years ago people where still using tapes for this kind of recording with a lot less quality.

Which format would be best suitable for this? I was thinking WebM, since it seems the results are of rather good quality and because it is pushed by Google I would expect it to have a good change of survival and be recognized.
I'm a big fan of Open formats, so I would prefer the format to be open. But I'd also like it to be as portable as possible. It should be easily playable on most common devices, such as a tablet. (To my surprise this was not really the case on my Google Nexus 7 tablet. When I tried a webm-converted movie on the tablet it had serious problems playing it. I could only get it to play smoothly on the Nexus with the hardware decoder disabled in MX Player.)

Thank you for any advice!

jeroen

Posted 2013-02-23T23:41:52.837

Reputation: 435

1You'll probably get good advice on how to shrink your files, but there's no getting around the fact that video streams contain a lot of data. You can compress this data in various ways, but there's a limit to what you can do without destroying quality. Forget about storing them on Dropbox, unless you're willing to spend a lot of money. You should look at NAS devices or USB3 disks, which cost about $150/terabyte. – Isaac Rabinovitch – 2013-02-24T02:04:55.870

1While people will disagree with this comment, h264 is open enough for your purposes. You could transcode to a lower bitrate using Handbrake. As for backups, you're better off with Backblaze or one of the other dozen online backups, as it'll get everything, not just your videos. – emgee – 2013-02-24T02:46:19.453

I'm currently speaking about 30Gb of pictures and movies for 2012. So if I can reduce the video size to about 10% of their original size, I can already backup for a few years on the cheapest Dropbox account. I like Dropbox because it's easy to use on Android and Linux and I already use it. It makes it also very easy to share pictures. Backing up other stuff is not really an issue as most of my other data is already in Git repositories + I have a backup of everything on a NAS. But I want an off-site backup of my pictures as that is something you can never recreate if disaster strikes... – jeroen – 2013-02-24T21:19:29.333

Answers

7

What options do I have?

There are currently (as of 2017) three formats with which you could encode your home videos, if you want lossy compression at good file sizes and quality:

  • H.264 (MPEG-4 AVC) – the de-facto standard
  • H.265 (HEVC) – the H.264 successor
  • VP9 – Google's open WebM video codec

Here are some things to consider:

  • VP9 (encoded with libvpx) is better than H.264 (encoded with x264) in terms of quality versus file size. HEVC (encoded with x265) is even slightly better than VP9 but with diminishing returns for high resolutions. Netflix has done some extensive testing in this direction.

  • x264 is much faster than x265 or libvpx, so if encoding time is an issue, choose H.264.

  • All of these formats have good support in offline players on PCs.

  • HEVC is not supported in most browsers, and will likely never be, as it is patent-encumbered and the situation is not developing in a good way.

  • Mobile devices have best support for H.264. iOS does not support VP9. Android supports all these formats.

How should I do the encoding?

To archive your videos, you should use a constant quality encoding mode (called CRF in the popular x264 encoder). If you just set a constant bit rate, you will get worse quality overall at no real benefit other than knowing which file size you get.

While there are various encoders for H.264—even commercial ones—x264 should give you excellent quality, e.g. with FFmpeg like so:

ffmpeg -i input.mp4 -c:v libx264 -crf 18 -c:a aac -b:a 192k out.mp4

Notes about the settings:

  • CRF is set to 18, which will give you more or less visually lossless results. Lower values will give you better quality, and higher values worse quality. Sane values are from 18 to 28. The default is 23. You can use a higher CRF as long as you still like the video quality.
  • If the resulting bitrate is too high, some mobile phones / tablets might not be able to play the file. Choose a higher CRF value in this case.
  • You can use a different -preset setting to increase the compression efficiency at the expense of longer encoding times, e.g. by setting -preset slow or -preset slower.
  • I chose AAC encoding with the FFmpeg built-in encoder at 192 kBit/s. This should be good enough for keeping the audio quality transparent.

And that's all there's to it, really. No other settings needed if you're just in for reducing file size. Read the H.264 encoding guide and the AAC encoding guide for more options though if you're interested.

See also: What parameters should I be looking at to reduce the size of a .MOV file?

slhck

Posted 2013-02-23T23:41:52.837

Reputation: 182 472

Thank you for your excellent answer! After reading the answer by Jochem Kuijpers I started experimenting with ffmpeg and x264. I came to nearly the same conversion-command as in your answer. Except that I'm currently using the MKV container. While both MP4 and MKV play on my Nexus 7 and Samsung TV, I choose MKV so that at least the container is still an Open format. Are there any reasons not to do this? This is the bash command I use: ffmpeg -i $1 -vcodec libx264 -acodec libvo_aacenc -preset slower -crf 23 ${1%.*}.mkv Are there important differences between aac and libvo_aacenc? Thank you! – jeroen – 2013-02-24T21:09:55.480

1

No, MKV is absolutely fine if it works for you, but here the situation's similar to the codecs: MP4 is an MPEG standard and (still) has much wider support than MKV. This is likely to change I guess, but it takes time. As for FFmpeg AAC, both aac and libvo_aacenc work fine, however both of them offer bad quality when compared to libfdk_aac or libfaac. You might need to supply higher bitrates to achieve the same quality. For more info see this answer: FFmpeg command to convert MP3 to AAC

– slhck – 2013-02-24T21:23:17.097

I had indeed the impression that MP4 is still more widely supported. While I was considering MKV I did a quick test to convert to MP4 with ffmpeg -i foo.mkv -vcodec copy -acodec copy foo.mp4 which seems to work without any problems and only takes a second, because (if I understand it correctly) that simply copies the audio and video into a new container. – jeroen – 2013-02-24T22:06:49.130

I just tried the aac codec and to my surprise the resulting file was actually 100kb smaller, even with -b:a 192k. The output of ffmpeg still showed Stream #0.1: libvo_aacenc, 48kHz, stereo, s16, 200 kb/s. Not sure if that is correct. – jeroen – 2013-02-24T22:10:45.300

No that can only be if you copied the streams. You can't copy and choose another encoded—at least I gues that this is the issue. – slhck – 2013-02-24T22:42:33.297

slhck, I don't really understand your last comment. Are you referring to me copying to audio and video stream from an MKV file into an MP4 file? Since both containers use H264 and AAC, I would guess the streams can simply be copied?
Or are you referring to my following comment about using aac instead of libvo_aacenc? For that test I re-encoding my MKV from the original MOV file. Thx!
– jeroen – 2013-02-25T11:56:12.327

1Okay, then you got me confused. Yes, the streams can be copied. As for AAC: If your output shows libvo_aacenc, it'll obviously use that encoder. To use the FFmpeg-native aac encoder, you need -c:a aac -strict experimental. But I don't understand what the question is, maybe we're talking about different things? (You can also post a new question if you like) – slhck – 2013-02-25T12:13:18.333

apparently Ubuntu uses libav instead of the 'real' ffmpeg, which causes a slightly different behaviour and has slightly different codecs and cli-arguments, causing a lot of confusion. I'm now using the real ffmpeg and everything is clear now! Thanks a lot for your help! – jeroen – 2013-03-06T14:56:24.173

Yeah, Ubuntu switched to Libav and – at least for some time – supplied their avconv under the name ffmpeg, which caused a lot of confusion. Using the latest build is the way to go :) – slhck – 2013-03-06T15:02:59.367

2

H.264's being upgraded to H.265. This would allow even greater compression. However, I think that 150/200MB per minute is way too much. If you were to upload a video to YouTube in 720p, YouTube would compress it to about 10 to 15MB/s. Even though YouTube has some experts who tweak their compression so that it would cost them less bandwidth, you should be able to achieve similar quality with 20MB/s and not 200MB/s.

One simple way to convert video's to such a low bit rate but still high quality, would be to upload them to YouTube (and save as a private video). It would also make it easier to share it with your friends. Drawback is that you might experience long upload times...

Jochem Kuijpers

Posted 2013-02-23T23:41:52.837

Reputation: 383