How to convert an .ogv movie to .avi with MEncoder

Converting .ogv (Theora) movies to the AVI format allows easy uploading to sites such as YouTube and playback on devices that might not have supported The OGV format.

MEncoder is a useful movie format converter that is included with MPlayer, but also as its own package in some Linux distributions. You'll need to install this first before continuing with this how to. With Ubuntu this can be done simply with the following command:

sudo apt-get install mencoder

Next, a simple bash script can be created to simplify the running of MEncoder with the required arguments. Copy the following into a new file titled ogvtoavi.sh:

#!/bin/bash
set -e
if [ "$1" ]; then
   filename=${1%.*}
   mencoder "$1" -ovc xvid -oac mp3lame -xvidencopts pass=1 -o $filename.avi
else
   echo "Usage: $0 <ovg file>"
   exit 1
fi
exit 0

Make sure to set this new script executable with the command:

chmod +x ogvtoavi.sh

To run the script and start the movie conversion, use the following:

./ogvtoavi.sh yourmovie.sh

This will display its progress and output the AVI movie in the current directory to a file with the same name as what was given but with a .avi extension.

Last updated: 25/09/2012