Home > How-Tos > FFmpeg

FFmpeg

January 11th, 2009

FFmpeg is an open-source command line utility for performing audio/video file conversions. It can be used to simply convert straight from one video format to another, or to crop, pad, rescale, change bit-rates, merge or split out audio and video, and so on…

The projects website is at http://ffmpeg.mplayerhq.hu/. Here’s a few links to some of the most useful parts of the project’s own documentation:

The simplest command format is ‘ffmpeg -i inputFile outputFile’, but it can be made as complex as required, in order to specify every single parameter of the conversion process.

To obtain the encoding details from an existing audio or video file, just run the command with only an input file specified, e.g.: ffmpeg -i somefile.avi

I’ll now list some commonly used parameters. These may do exactly what you need first time, but don’t be surprised if you have to tweak the parameters slightly for them to work on your system, with your files:

Convert AVI video to MPEG:

ffmpeg -i inputFile.avi outputFile.mpg

Convert MPEG video to AVI:

ffmpeg -i inputFile.mpg outputFile.avi

Convert FLV to MPEG:

ffmpeg -i inputFile.flv -ab 56k -ar 22050 -b 500k -s 320x240 outputFile.mpg
Audio bit-rate: 56kbps
Audio sampling frequency: 22050Hz
Video bit-rate: 500kbps
Video size: 320 x 240

 
Convert MPEG or AVI to FLV:

ffmpeg -i inputFile.avi -acodec mp3 -ar 22050 -f flv outputFile.flv
Audio sampling frequency: 22050Hz

 
Convert AVI to MPEG-2 for DVD
Note that you will probably need to change the ‘target’ and ‘aspect’ to match your needs:

ffmpeg -i inputFile.avi -target pal-dvd -aspect 16:9 outputFile.mpg

Convert sequence of JPEGs to MPEG:
Note that the image files in this example would named ‘pic-001.jpg, pic-002.jpg, etc…

ffmpeg -f image2 -i pic-%d.jpg outputFile.mpg

Convert MPEG or AVI to sequence of JPEGs:

ffmpeg -i inputFile.mpg pic-%d.jpg

Convert MPEG or AVI to time-lapsed sequence of JPEGs, one per second:

ffmpeg -i inputFile.mpg -r 1 pic-%d.jpg
Video frame-rate: 1fps

 
Convert MPEG or AVI to animated GIF:

ffmpeg -i inputFile.avi outputFile.gif

Convert MP3 to WAV:

ffmpeg -i inputFile.mp3 outputFile.wav

Convert WAV to MP3:

ffmpeg -i inputFile.wav -ab 256k outputFile.mp3
Audio bit-rate: 256kbps

 
Remove the audio from MPEG or AVI:

ffmpeg -i inputFile.avi -an outputFile.avi

Remove video from MPEG or AVI, and convert to MP3:

ffmpeg -i inputFile.avi -an -ab 256k outputFile.mp3
Audio bit-rate: 256kbps

 
Add audio and video together, and convert to MPEG:

ffmpeg -i audioFile.wav -i videoFile.avi outputFile.mpg
Categories: How-Tos Tags: , , , ,
Comments are closed.