Sometimes I take AVI videos with my Canon PowerShot, and I process some
of them with a video editor and export them as MPEG. However, those
video formats can’t be streamed, and so I like to convert them to FLV
to enable a YouTube-like streaming in web galleries by a flash video
player.
For convenience, I wanted to use a context menu entry for Nautilus, where I could right-click on a video file and select “Convert video to FLV”. Luckily, Nautilus supports to execute arbitrary scripts from the context menu if you simply place them into ~/.gnome2/nautilus-scripts/. The only disadvantage is that it doesn’t check the file type in advance, thus also showing the video conversion entry for non-video files. However, you can include that logic into the script itself.
The script is a little more complicated, as I didn’t know how to better parse the file names. Probably I should have used Perl. Here is my ~/.gnome2/nautilus-scripts/Convert\ video\ to\ FLV:
#/bin/bash
zenity --question --title “Convert video to FLV” --text “Really?” || exit
IFS=$’\n’
for file in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS; do
ext=$(echo $file | awk ’BEGIN {FS=“.”}; {print $NF}’)
filebase=$(basename “$file”)
path=$(echo $file | sed -e “s/$filebase//”)
filebase=$(basename $filebase .$ext)
if file -i “$file” | grep -i video >/dev/null; then
ffmpeg -y -i “$file” -ar 22050 -ab 32 -b 564k -f flv -s qvga “$path$filebase.flv” &
else
zenity --error --title “Not a video” --text “Hey, $filebase.$ext is not a video!”
fi
done