Mass conversion using ffmpeg

ffmpeg is a wonderful multimedia conversion tool. It supports most of the multmedia file formats.

to convert a mp3 file to ogg format

ffmpeg -i song.mp3 song.ogg

This command itself take care of the conversion.

Mostly, I use ffmpeg to convert all the AVI files from my Digital Camera to MPEG format so that I can play all the videos in VCD or DVD player.

ffmpeg -i video.avi -target ntsc-vcd video.mpg

This command converts the video.avi to video.mpg in NTSC VCD format.
other targets are pal-vcd,pal-dvd,ntsc-vcd,ntsc-dvd.

I think NTSC is for India.

Eventhough, ffmpeg works on a single file at a time, I neede to convert all the AVI files in a folder into MPG.

Here is a scipt to do mass bulk conversion using ffmpeg.

$for f in `ls *.AVI`; do FILE=$(basename $f .AVI) ;ffmpeg -i $FILE.AVI -target ntsc-dvd $FILE.mpg; done

f the filenames contains space, then

$IFS=$’\n’ ;for f in `ls *.AVI`; do FILE=$(basename $f .AVI) ;ffmpeg -i $FILE.AVI -target ntsc-dvd $FILE.mpg; done

Thats all. Now all the files in a directory are converted into another file format.

Thanks for Fabrice Bellard for his wonderful tool

Powered by ScribeFire.

2 thoughts on “Mass conversion using ffmpeg

  1. Thank you for this it is really useful.
    However I came across a bit of a rough spot in music conversion. This is my modification so far:
    $IFS=$’\n’ ;for f in `ls *.ogg`; do FILE=$(basename $f) ;ffmpeg -i $FILE $FILE.mp3; done

    Will you please help me with it?
    My music is structured as – .ogg

    I have been trying to remove the .ogg from the filename in place of .mp3.

    So far ffmpeg cuts off the filenames at ‘n’. For example, “Reel Big Fish – Tre” and “ndy” are two unsuccessful ffmpeg conversion attempts.

    This command also provides a lot of mass ffmpeg possibilities such as renaming artists or comments or albums. I’m am very excited.
    Thank you very much.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s