Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

is it possible to convert mp4 and m4v to webm via command line?

I'd like to just in a bulk swoop convert my mp4 and m4v files to web so i can play them in firefox without any issues.

share|improve this question
It probably goes without saying, but this will reduce video quality (even if you use the same or higher bitrate as the original). – thomasrutter May 6 '15 at 2:05
up vote 3 down vote accepted

Yes, with ffmpeg and bash this is not only possible, but very easy.

Here is the command for variable bit-rate conversion for .mp4 -> .webm:

ffmpeg -i input.mp4 -c:v libvpx -b:v 1M -c:a libvorbis output.webm

You can then use the command in a bash script to batch covert your files. Here is an example of how you could do that:


for FILE in *.mp4 ; do
    OUTNAME=`basename "$FILE" .mp4`.webm
    ffmpeg -i $FILE -c:v libvpx -b:v 1M -c:a libvorbis $OUTNAME

Keep in mind that depending on your computer, this may take a very long time.

And of course, this can be done for the m4v files as well. I won't guarantee everything will work since I don't have ffmpeg installed on this machine to test it, so you may need to modify the script and/or the conversion settings to suit your needs.

Documentation for the webm encoder can be found here:

share|improve this answer
The basename is superfluous when you can use bash parameter expansion instead: for FILE in *.mp4; do ffmpeg -i "$FILE" -c:v libvpx -b:v 1M -c:a libvorbis "${FILE%.mp4}.webm"; done – LordNeckbeard Oct 2 '13 at 20:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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