Skip to content


How to convert a video to OGV/MP4/WebM

I recently had to use the jquery.videoBG plugin for a site I work on. It is quite convenient as it does all the handling of various browser compatibility with different video formats so as to display a video in the background of the body or a div. However, of course, you have to provide it with the appropriate video formats, and that’s where things get a little bit more complicated.

My source file was .mov. For the various browsers, I needed an mp4 file, and ogv file, and a webm file.

MP4 is easy, my usual video compressing software, Handbrake, supports it (although I usually use it to obtain MKV).

Ogv and WebM are a bit less obvious, Handbrake doesn’t support them and apparently it’s easy to get lost in the jungle of video converters. I eventually settled for ffmpeg, which is command-line based but otherwise great (NB: as mentioned on the download page, “if you are confused about what build type you need just download a static build”).
A nice trick in ffmpeg is that you can demux and remux without re-encoding the streams. The syntax for this is, for instance:

ffmpeg -i inputfile.mkv -codec copy outputfile.mp4

So, all I need now is some video streams accepted by ogv and webm.
Ogv requires a Theora stream. And luckily Handbrake can provide that, so I can create an mkv file with a Theora video stream in it and then remux it to ogv with ffmpeg.
WebM requires a VP8 or VP9 stream. Handbrake can provide VP8 (sadly not VP9 yet), so again I can create an mkv file with VP8 video and then remux it to webm with ffmpeg.

Well, that’s all, problem solved. Here are what the commands would look like in ffmpeg although that’s probably obvious:

ffmpeg -i inputfile-with-theora-vid.mkv -codec copy outputfile.ogv
ffmpeg -i inputfile-with-vp8-vid.mkv -codec copy outputfile.webm

Posted in multimedia, open source.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA