Converting ogv videos to avi on Gnome


gnome2-plain-labelWe already learned how to convert videos into avi files using ffmpeg and mencoder. Now we will learn how to write a script that lets us convert many video files at the same time, and how to integrate it to Gnome, so when we select one or many files from the file manager it converts them all.

ogv2avi version 0.9

On this first version we just convert one file at the time, based on the example we saw with mencoder. Let’ s create the following script, called ogv2avi:

#!/bin/bash
mencoder "$1" -ovc lavc  -oac mp3lame -o "$(echo $1 | sed 's/ogv$/avi/')"

Here we telling to mencoder that ogv2avi script’s first parameter will be the input file name and to use the same file name as output but changing .ogv to .avi with the sed command. To check if it works we have to change files’s permissions in order to make it executable:

chmod +x ogv2avi

We can test it with any ogv file we have:

./ogv2avi NesterJ.ogv

We’ll see some messages that mencoder shows while coding the video file.

ogv2avi version 1.0

The previous example is a little limited, because it just convert one file at the time. To fix it we’ll use the bash’s arguments array in a for loop, by modifying the ogv2avi script as follow:

#!/bin/bash
for video in "$@"
do
echo "Encoding $video..."
mencoder "$video" -really-quiet -ovc lavc -oac mp3lame -o "$(echo $video | sed 's/ogv$/avi/')"
echo "Done!"
done

In the even the script is not clear enough, $@ is the arguments array which has the parameters passed in the command line. Then for each file, it will perform the mencoder command to convert it. The -really-quiet option avoid mencoder to display any message. We can test this script by passing to different ogv files in the command line:

./ogv2avi iRShell-Install.ogv NesterJ.ogv

At the end, ther will be to avi files: iRShell-Install.avi y NesterJ.avi

Integration with Gnome

To make it work with Gnome we can take advantage of the extension scripts feature by copying our ogv2avi program to the Nautilus’s script folder:

cp ./ogv2avi ~/.gnome2/nautilus-scripts/

Now we can select more than one file and right-click on the Sctips option to select our ogv2avi program, as is shown below:

ogv2avi

Script ogv2avi on Gnome

References


,

  1. #1 by Marko Kukovec on 07/08/2009 - 2:30 am

    Just a note…link at the start “convert videos into avi files” should be changed for this English manual to “http://lgallardo.com/en/2009/04/10/convirtiendo-videos-a-avi/”

    Otherwise, great info…it helped me a lot…thanx!

Comments are closed.