Convert a video (avi, mpg, wmv, …) to flv with ffmpeg on Linux

If you want to publish a video on the Internet you will probably want to reduce the size of your video.
A full HD video in avi format will be too heavy and totally inappropriate for streaming, this is where the Flash technology shows its power.

Flash is used all over the place on the Internet for audio & video streaming, you keep good video quality and a significant reduce on files’ size. Of course you will need a tool or a software to convert your video. If you are a GNU/Linux user you will most likely end up using FFmpeg.

FFmpeg is a command-line program who gives you the ability to record, stream, encode audio & video. You have a large amount of options to perfectly match your needs (consult the man for that).

The first step is to install FFmpeg. It will depend of your operating system, if you are running a Debian based distribution you can use the apt command line:

# apt-get install ffmpeg

If you are on Archlinux (my current distribution) use the pacman tool an so on:

# pacman -S ffmpeg

Now you need a simple command to encode your video into a Flash video (.flv extension), here is an example:

$ ffmpeg -i my-video.avi -f flv -b 768 -ar 22050 -ab 96 -s 720x576 my-video.flv

Lets take a look at the options:

-i it is the input file, the video we want to convert in another format
-f the output format of our video
-b it defines the bit rate of the output video (768kbit/s in our case)
-ar the audio frequency of the output video 22050 Hz in this example
-ab the audio bit rate of the output video
-s the dimension of our output video

Yes it is that simple, after the execution of the command you have your .flv video.

Of course, you can use this tool to convert video or audio in other formats (wmv to avi, avi to mpeg, whatever you want). I choose the .flv because it is such a lost of time to find a reliable solution to encode it properly.

One thought on “Convert a video (avi, mpg, wmv, …) to flv with ffmpeg on Linux

Leave a Reply

Your email address will not be published. Required fields are marked *