Converting Video Formats with FFmpeg

FFmpeg allows Linux users to convert video files easily between a variety of different formats.

Today's affordable digital video cameras have placed the power of digital recording within most people's reach. Unfortunately, this has been accompanied with a corresponding increase in the variety of file formats and codecs available. Some of these formats are more efficient than others, and some are less encumbered by proprietary licensing restrictions. So, having the ability to convert from one format to another is a great help, as you can decide what format you are comfortable with and use that one instead of being restricted to a specific file format.

FFmpeg is a simple and straightforward application that allows Linux users to convert video files easily between a variety of different formats. In this article, I walk you through installing FFmpeg and provide a few instructive examples to demonstrate the range of applications for which it can be used.

FFmpeg Installation

FFmpeg is an open-source audio and video converter that supports most industry-standard codecs and can convert from one file format to another quickly and easily. It also lets you capture video and audio from a live source and process it.

The source code for FFmpeg is available for download from the project Web site ( and at the time of this writing, the latest version available at the site is 0.4.9-pre1.

Once you download the file, extract it using the following command:

tar -zxf ffmpeg-0.4.9-pre1.tar.gz

This creates a new directory containing the source code for FFmpeg. To install it with the default configuration options, run ./configure from within the FFmpeg source directory. Once the configuration script finishes, compile it by issuing make. Once the compile finishes without any errors, you can install FFmpeg by running make install as root.

On the other hand, if you like to have control over what is installed and prefer customizing software installs, you can pass some command-line parameters to the configure script. To see all the options available for the installer, run the following command:

./configure --help

This command gives you multiple screens of the various settings that can be modified, and you can choose any options you like. The on-screen display does a decent job of explaining what each option does, so I will not go into a lot of detail on this.

I suggest that you enable the following options, but this is not a requirement—feel free to experiment:

  • --enable-mp3lame: highly recommended—you won't be able to encode MP3s without this. Needs lame to be installed already.

  • --enable-a52: enables GPLed A52 support, needed for decoding some VOB files.

  • --enable-gpl: required for the previous component; otherwise, not needed.

As I didn't have lame installed on my system, I ran the following command to configure FFmpeg:

./configure --enable-a52 --enable-gpl

Once the configuration is complete, read through the output to make sure no errors were generated. Then, run make, and go have a drink or something as this might take a little while. Once the system finishes compiling FFmpeg, run make install as root to install FFmpeg, and you are done with the installation.

Basic Usage

Now that you have successfully installed FFmpeg, you can start experimenting with it. The first thing you have to do is choose a video file with which to experiment. As this is your first time with FFmpeg, making a backup copy of this file is highly recommended. You don't want to be responsible for ruining the only copy of a rare video.

This input file most probably has been encoded using a particular codec, but because FFmpeg supports most of the popular formats, we don't need to worry a lot about that. Formats supported by FFmpeg include MPEG, MPEG-4 (Divx), ASF, AVI, Real Audio/Video and Quicktime. To see a list of all the codecs/formats supported by FFmpeg, run the following command:

ffmpeg --formats

A detailed list of supported file formats is also available at the FFmpeg site.

FFmpeg supports a large list of command-line parameters that control various settings in FFmpeg. To get a listing of the various options available, run the following command:

ffmpeg --help

Don't let the multipage listing scare you from using FFmpeg, the basic usage is actually very simple. To convert a file with the default settings, run the following command:

ffmpeg -i InputFile OutputFile

The -i option tells FFmpeg that the filename immediately after it is the name of the file to be used as input. If this option is omitted, FFmpeg attempts to overwrite that file when it tries to create the output file. FFmpeg uses the extension of the output file to try to determine the format and codec to use, though this can be overridden using command-line parameters (more on this later).

The default settings create an output file that has radio-quality sound (64kbps bitrate) and very bad video quality (200kbps bitrate). Fortunately, these settings can be changed for each encoding, which allows you to choose the quality of each file depending on the need.

To change the audio bitrate, add -ab bitrate to the command used earlier, where bitrate is the bitrate you want to use. See for information on the sound quality the various bitrates represent. I prefer to encode files with a bitrate between 128–192kbps depending my needs, but you can put in a higher value if you so desire. Keep in mind, however, that the higher the bitrate you use, the larger the output file size will be. Also keep in mind that if your source file is encoded in a low bitrate, increasing the bitrate won't accomplish much other than increasing the output file size.

Now, getting a CD-quality audio track for the video doesn't really make sense if the video looks like it was taken using a five-year-old Webcam having a bad day. Thankfully, this problem also is easily solved by adding another parameter to the command line.

To change the video bitrate, add the -b bitrate option to the command line. The bitrate here can be any numeric value you like, and I have seen bitrates all the way up to 23,000 (DVD Rips). Although the quality of video encoded with a 23,000kbps bitrate is amazing, the resulting file size of that encoding is also very amazing (a 90-minute video is about 4GB). In my experience, most videos look pretty decent at bitrates between 1,000–1,400, but this is a personal preference, so play with the numbers until you figure out what works for you.

So, to encode a video with a 128kbps audio bitrate and 1,200kbps video stream, we would issue the following command:

ffmpeg -i InputFile.avi -ab 128 -b 1200 OutputFile.mpg

If you are creating a video CD or DVD, FFmpeg makes it even easier by letting you specify a target type. Then, it uses the target type to calculate the format options required automatically. To set a target type, add -target type; type can be vcd, svcd, dvd, dv, pal-vcd or ntsc-svcd on the command line. So, if we were creating a VCD, we would run the following command:

ffmpeg -i InputFile.mpg -target vcd vcd_file.mpg

FFmpeg also has support for encoding audio files. The command to convert audio files is the same as the command to encode video files. To convert a WAV file to a 128kbps MP3 file, issue the following command:

ffmpeg -i Input.wav -ab 128 Output.mp3

Now, the biggest selling point of FFmpeg is that you can customize it to a level that you are comfortable with. So, if all you want to do is convert from one codec to another, and you don't really care about the advanced features, you can stop reading here and still be able to encode/decode videos. On the other hand, if you like to have more control over the encoding, keep reading as we cover more of the advanced options available in FFmpeg.

There are far too many options available in FFmpeg for me to go over each of them here, so I cover some of the ones I found most interesting and leave the rest for you to explore.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


chelovek84's picture

video conversion

Anonymous's picture

Hi, I have a questions

Anonymous's picture


I have a questions about ffmpeg codification.

I want to encode foreman.avi with this configurations :

- I I I I I ...
- I B P B P B P B I ...
- I B B B B B B B I ...

I know that I have to use the commands -bf and -g...

Can you help me?



Anonymous's picture

This machine Convert FLV AAC H264???/ TO any other??


colix's picture

im tryin to convert a video to mp3 using command ffmpeg -i input filename -vn (ive tried -ab -b to 256 128 64 and also -sameq but nothing) output filename

i am using windows xp, dont

Anonymous's picture

i am using windows xp, dont know anything about linux

never too late to learn somethin beter

Anonymous's picture

Windows is for people who cannot think for themselves.
It is never too late to learn linux.

windows is ok for me

Anonymous's picture

i'm glad someone compiled ffmpeg for windows.

convert video to mp3

Anonymous's picture

i normally use like this:
ffmpeg -i dvd_file.vob -ac 2 -ar 44100 -ab 128k out_file.mp3

soz didnt finish it....:P

colix's picture

soz didnt finish it....:P yeah .... i gets me an error:
Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 29.97 (30000/1001)
Input #0, flv, from '123.flv':
Duration: 00:02:51.30, start: 0.000000, bitrate: 175 kb/s
Stream #0.0: Video: flv, yuv420p, 320x240, 111 kb/s, 29.97 tbr, 1k tbn, 1k tbc
Stream #0.1: Audio: mp3, 22050 Hz, mono, s16, 64 kb/s
WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
Output #0, mp3, to '123.mp3':
Stream #0.0: Audio: 0x0000, 22050 Hz, mono, s16, 64 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Unsupported codec for output stream #0.0


full command line please

Anonymous's picture

show the command line please

maybe it should be like

Anonymous's picture

maybe it should be like this:
ffmpeg -i infile.flv -ac 2 -ar 44100k -ab 128k outfile.mp3
or depends on some ffmpeg version,
ffmpeg -i infile.flv -ac 2 -ar 44100 -ab 128k outfile.mp3

and/or maybe send me that

Anonymous's picture

and/or maybe send me that .flv file to my email gianmhl @ yahoo . com

command for me to find

Anonymous's picture

command for me to find formats is ffmpeg -formats not --formats

I do not like it

ruby's picture

I do not like this software. it can not work for me.
I use iMedia Converter to convert DVD and Videos on Mac.
iMedia Converter for Mac can rip DVD and convert video to sorts of video formats including AVI, FLV, MKV, MP4, 3GP, MTS, M2TS, MOD, WMV, M4V etc. It can also extract audio from video to MP3, WMA, WAV, RA, M4A, AAC, AC3, OGG, MKA, etc.

ffmpeg can do the same thing.

Anonymous's picture

ffmpeg can do the same thing. i used the command line to do it.

i used ffmpeg command line, i

Anonymous's picture

i used ffmpeg command line, i can do the same thing.

mapping right audio languages

typxxi's picture

I don't have any unix linux knowledge, but from my point of view this shouldn't work
ffmpeg -i InputFile.mpg -map 0:0 -map 2:1 -b 1200 OutputFile.avi

the 0:0 is the leading stream, here the video stream
you want to here in future the english stream from 2
(mpeg calls them #0.1 ... where 0 means the inputfile as far as I understand)

You sync the the second stream to the videostream.

ffmpeg -i InputFile.mpg -map 0:0 -map 0:2 -b 1200 OutputFile.avi

if you want spanish a alternate language than this should work

ffmpeg -i InputFile.mpg -map 0:0 -map 0:2 -map 0:1 -b 1200 OutputFile.avi

but this won't work in mp4 (cause mp4 contains only 1 audio stream).

I hope it will work better, 'cause it took a huge amount of time to find these things out.

File Formats

Random Things's picture

Exactly which file formats is FFMPEG compatible with?

it can supports lot of

Anonymous's picture

it can supports lot of formats.

ffmpeg bitrate

ChrisC's picture


In my version of ffmpeg bitrate requires a following 'k' if it is kilobytes.
ffmpeg -i InputFile.avi -ab 128 -b 1200 OutputFile.mpg
ffmpeg -i InputFile.avi -ab 128k -b 1200k OutputFile.mpg


Syntax Error

Anonymous's picture

Where you have "--formats" it should be "-formats".


Anonymous's picture

Thanks a lot for the post. It helped me a lot.

I had 2 scenarios in mind and am wondering if those are possible using FFMPEG:

1) How I can output only part of a video using FFMPEG, example: the output video will start form 10 minutes into the source video and end 15 minutes before the end of the source video.

2) Whether it is possible to output 1 video from 2 source videos in the following manner: output video starts 10 minutes into the first source video and end 15 minutes before the second source video.

I hope you understand what I'm looking for.

I would appreciate any help, or suggestions.


answer to your question 2

Anonymous's picture

if you are using windows, copy the 2 files the use ffmpeg to encode again.

Question about FFMPEG

Anonymous's picture

Hey! Just saw your question about ffmpeg and figured I'd help with what I could. I don't know about part 2, but I know that for duration you do ffmpeg -i InputFile -ss StartTime -t Duration Outputfile. So for example, if the video was 1 hour long, you would do ffmpeg -i InputFile -ss 00:10:00 -t 00:35:00 OutputFile. Hope that was helpful!


Cygwin installation?

Ron Dotson's picture


I was trying to install FFmpeg under Cygwin, but the compilation fails with many, many warnings and a fatal error - a missing header file to define the macro "llrint" as I recall. I copied over the standard.h file from somewhere on the Cygwin installation, but the next fatal error was (as I recall) a missing library routine or something - so obviously my environment or PATH variable aren't set up correctly.

Any pointers as to where I can find out what type of libraries are supposed to be found in what locations in order to get a successful compile and link of FFmpeg?

If so I would appreciate a reply to:
[Note: The email address listed above will self destruct at the first sign of Spam. ;-]
Thank you,


an easier program ?

donate car's picture

I was wondering if there's a program with the basic transf. commands that can be used by those who haven't got experience with it.

there are

Anonymous's picture

here are some of them, mencoder, winff,