Submit A Tip Alternative Tip Form

[How To] Quickly Convert ogv to avi Video Files in Ubuntu

YouTube hates Ogv. Seriously.

If you’ve ever taken the trouble to record a screencast of your desktop for a video tutorial; spent hours in PiTiVi editing a video of your hamster doing the macarena; or otherwise ended up with a video in the .ogv file format you’ll know that this is true.

YouTube, despite happily accepting .ogv video uploads doesn’t actually support the .ogv file format. Once an .ogv upload has been “processed” by YouTube the result usually ends up looking like this: –

Not cool.

Although there are a variety of methods for converting .ogv to .avi (other formats are available) the method below is the one I use, and the one I have always come back to. It’s not “user-friendly” but it does work well.

How to convert an .Ogv to .Avi in Ubuntu

First step is to install the ‘mencoder‘ package. This is available from the Ubuntu Software Centre. Click the button below to install.

Next we’re going to create a script that allow us to convert as many videos as needed in one batch using the command line.

Open a terminal and enter the following command carefully.

gksu gedit /usr/bin/ogv2avi

Paste the following script into the empty text document that has opened up: –

#!/bin/bash
 # ogv to avi
 # Call this with multiple arguments
 # for example : ls *.{ogv,OGV} | xargs ogv2avi
 N=$#;
 echo "Converting $N files !"
 for ((i=0; i<=(N-1); i++))
 do
 echo "converting" $1
 filename=${1%.*}
 mencoder "$1" -ovc xvid -oac mp3lame -xvidencopts pass=1 -o $filename.avi
 shift 1
 done

Hit ‘Save’ and close the window.

Ogv to avi using mencoder in Ubuntu

Now we need to give the file permission to run. Head back to the Terminal and enter:

sudo chmod +x /usr/bin/ogv2avi

Converting videos using Ogv2avi

Place your .ogv videos in your home folder, open a terminal and run: –

ogv2avi video1.ogv video2.ogv

You can convert as many videos as possible (though each are converted individually) using the command.

Chances are you have your own preferred way, so feel free to share it in the comments for other readers to use.