Sunday, October 24, 2010

How to convert mpg file to flv file using ffmpeg or mencoder?

Here are the steps those I once used :

I converted the video using ffmpeg command line as below.
ffmpeg -i lions.mpg lions-ffmpeg.flv

PS: input file name : lions.mpg

The video was converted fine.

Then I converted the video using mencoder using the command mentioned below.

mencoder lions.mpg -o lions-mencoder.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=450:400 -srate 22050

Then I generated a thumbnail using ffmpeg command mentioned below.

ffmpeg -i lions-ffmpeg.flv -ss 1 -t 00:00:01 -s 120x90 -r 1 -f mjpeg lions.jpg

Then I added meta data to the video.

flvtool2 -U -P lions-ffmpeg.flv
hasKeyframes: true
hasMetadata: true
duration: 9.976
audiosamplerate: 44000
audiodatarate: 63.0167957356935
datasize: 482188

Try :)


  1. Thanks,

    Any tips on cross server conversions i.e. ffmpeg installed on one server converts media on another server?

  2. Hello,

    Thanks for your comment. Yes it's possible to do the same. It'll will very difficult to do cross conversion if you do it manually. But if you use any script it'll make it easy to achieve the desired task. You can use "dolphin" or similar script which uses "ray media" server or RED5 server. The basic concept is these ray servers convert the video files to flash files and those flash files will be playing on the dolphin script site. Here ray server will be on one machine and your webserver will be on other machine. the script will call the ray server to convert the video files. You can put the video files anywhere(on webserver or ray server). This is the basic concept of most popular video site "youtube". Try :)

  3. thanks, i have a question: does ffmpeg supports converting mpg files to other format such as mp4 or xvid? i want to play them on my mp4 player.

  4. your solution works well on my pc. ffmpeg is a great software. it supports to convert video of nearly all the popular formats. finding free keylogger here.

  5. Post is nicely written and it contains many good things for me. I am glad to find your impressive way of writing the post. learn more about convert mpg to mov on mac at