Converting MP4 to WebM

Recently I wanted to convert some files and put them on my 'Own Cloud' app so I can access them on the fly. But the problem was sometimes some videos can't be played on my firefox browser so I thought of converting them to WebM format before putting them on my web app.

A lot of application give you option to convert files to MP4 easily but sometimes not in WebM format.

Quick and easy options:

  1. FireFrog - A firefox extension Its not a good option for batch conversion of WebM.
  2. Miro player - Gives the batch conversion option but doesn't give fine settings to play with your files.  

What I choose finally: FFmpeg

FFmpeg is an open source and cross platform command line utility that actually serves as the engine for the applications noted above. FFmpeg is fast, powerful, and extremely flexible, but it can be difficult to understand and use.

Install FFmpeg

Mac: Use HomeBrew

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aacc

If you’re on Linux, find the appropriate FFmpeg package for your distribution and install it with support for the libraries mentioned above.

How to use:

Here I am converting  a file called humpi.mp4 to a file called humpi.webm.

ffmpeg -i humpi.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis humpi.webm

This is basic. If you want to play with your conversion settings (and there a lot to explore) read the FFmpeg documentations.

Batch converting files:

Well FFmpeg doesn't really give batch conversion but let's remember its a powerful . tool. You can combine it with bash script and achieve this.

Here is a small script that converts all the MP4 files from my 'Humpi_videos' directory to shiney new WebM files.



find "$Humpi_vid" -name '*.mp4' -exec sh -c 'ffmpeg -i "$0" -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis "${0%%.mp4}.webm"' {} \;

Now run the script:


Grab some coffee and relax, it may take awhile ...

P.S Almost forgot ... WebM is HTML5 compatible. ;)