I recently got a helmet camera for my motorbike and was able to make videos, however it stores it in Motion JPEG, which is very space inefficent. 30 minutes of 640x480 takes up 2GB. I can convert that to mpg, with this command:

ffmpeg -i myvideo.avi myvideo.mpg

Which is a good space saving. However is this the best video format? Should I use something new like AAC? If so, how? (ie what's the ffmpeg/mencoder/gstreamer/transcode command)


  • Convertable on linux using only open source tools
  • Must play on linux
  • Don't care about making it play on other devices (like ipods)
  • Should keep reasonably the same quality
  • Don't care about the audio, I'm tempted to remove it
  • I'm willing to use 'patent encumbered' formats like mp3, etc.
  • I'm not too interested in shaving miliseconds off treanscoding time or extreme file savings.


  • Ogg is great because it's open source and you can embed it in a web page with HTML 5 :) – Philippe Mongeau Aug 28 '09 at 14:29
  • No ogg on Macs thou.... If I remember correctly Apple made sure there was not Video support in HTML5 since they wanted h264... and not ogg :( Even thou I use h264 right now, ogg gives a better feeling since it is completely free. – Johan Aug 29 '09 at 7:08
  • That's not quite right - Apple's implementation of the video tag in HTML5 only uses h264, not ogg which violated the spec at the time. The spec was altered to drop any codec recommendation to avoid producing a spec which would never be implemented. – Rich Bradshaw Aug 29 '09 at 10:05
  • @Rich Bradshaw: A codec hadn't been decided - Apple's reason for not using .ogg have more to do with submarine patents than anything else. – Chealion Aug 29 '09 at 17:03

The newest 'standard' is h264. It is used everywhere from cell phones to Blueray to iPods. Plus, ffmpeg can encode/decode it nicely. I have used ffmpeg to squish full DVDs to a 120MB file to put on my iPod. Its a lower resolution, but it still looks great.

This site gives a quick guide to using ffmpeg to encode to h264. link text


How about Matroska and H264?

There are some potential problems with Apple and h264, but for now it seems to be ok.

As frontend when I rip and encode DVD:s I use Handbreak, however I don't know if you can use Handbreak for your need.

Update: And to play those mkv/h264 in Ubuntu I use the vlc player.

Update: You can use Handbreak to convert your video with something like this:

HandBrakeCLI -i my_vid.avi -E faac -B 128 -f mp4 -e x264 -o my_new_video.mp4

regarding the h264 suggestions, I agree h264 is a very nice codec. But if I'm not mistaken XviD (open source) yields better results for this resolution at the same file size as H264. Not to mention encoding in xvid is much faster than h264.

Even with ffmpeg you could encode it to using xvid, but using HandBrake would be simpler I guess. As container I would still suggest using mkv, much better thought out.

  • +1 for recommending Handbrake. The ffmpeg and mencoder command lines were never meant as actual interfaces, but rather things to build interfaces on top of. – Ryan C. Thompson Sep 7 '09 at 4:34
  • @Ryan thanks, I agreee, but sometimes your in a situation where you either want to batch encode a bunch of video's or a weird situation.. and then, ffmpeg/mencoder offers you the power :) but yeah, keep it simple use HandBrake. – Davy Landman Sep 7 '09 at 19:00
  • h.264 will almost always deliver better quality at a given bit rate than xvid. The x264 encoder is just as open-source as xvid, and using the faster presets it has similar encoding speeds. The only reason to use xvid is for use with older hardware devices and really ancient PCs. – evilsoup Jan 26 '13 at 19:31
  • @evilsoup The state of codecs in 2009 was different, at that time, benchmarks for that resolution rated xvid higher then x264. I've become slightly out of date on this, so it might be the case that x264 has been improved enough too excel at low resolutions. – Davy Landman Jan 26 '13 at 21:02
  • @Davy I'm aware of that. Sorry if I came across as aggressive in my comment, I was just pointing out the current state of things. – evilsoup Jan 26 '13 at 21:10

Use the most standard, the most available, the most accepted, the most likely to be supported, MPEG4-class codec around.

  • um? Which is? Sorry I don't know much about video codecs... – Rory Aug 28 '09 at 13:41
  • 1
    i know on Windows (DivX, XVid), but not on Linux. So whatever codec you do end up choosing, make sure it is one that is widely supported (i.e. not Ogg) – Ian Boyd Aug 28 '09 at 15:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.