Wednesday, October 13, 2010

Nautilus script to create mp3s from video files

Do you ever download a video off youtube and think "gee I wish I had an mp3 of that". Well here is a script for nautilus (the gnome file manager in linux) to help you create that mp3.

Create the file in $HOME/.gnome2/nautilus-scripts

I named it "Convert to MP3" and set the execute flags on the script (chmod a+x $HOME/.gnome2/nautilus-scripts/Convert\ to\ MP3)


out_file=`echo "$in_file" | sed 's/\.\w*$/\.mp3/'`

ffmpeg -i "$in_file" -f mp3 -ab 128000 "$out_file"

This script requires ffmpeg to be installed for it to work. Once you install this script you should see a new menu item on the context menu of the files named Scripts if it was not already there, and then you should see your "Convert to MP3" option.

Select any video file, choose the "Convert to MP3" option and after a few seconds (depending on the size of the file) an mp3 file will be created with the same name as the original file. 
Hope you found this useful.


Giorgio said...

This is very useful, thanks. Just a note, I think you should use "-ab 128000", because otherwise you get:

WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s

Kevin said...


Thanks for the comment, I'll make a note.

Tormak said...

Ubuntu users reading this should note that they will need to install the ffmpeg and libavcodec-extra-52 packages from medibuntu first.

shrey said...
This comment has been removed by the author.
wolsonjr said...

out_file=`echo "$in_file" | sed 's/\.\w*$//'`
out_file=`echo "$out_file" | sed 's/$/\.mp3/'`

suggest above mod for files w/o extensions