FLV Encoding with FFmpeg



Last year I put together a video documenting my daughter’s first year of life. I created a couple of DVDs several months ago and have been meaning to get around to creating some web friendly versions of the video. In raw format the video is 720×480, 30 frames/sec, 15 minutes long, and right at 3GB. I’ve been wanting to create an FLV and dump it into a nice Flash video player.

This weekend I was able to run the raw video through FFmpeg and received some pretty astonishing results. When it was all said and done the file size was just shy of 30MB, while the quality was pretty decent. Here’s the command along with parameters:

ffmpeg -i ellas_first_year.avi -ar 22050 -ab 32 -f flv -s 320×240 ellas_first_year.flv

Here are the parameters explained:

-i = Input file name
-ar = Audio sampling rate in Hz
-ab = Audio bit rate in kbit/s
-f = format
-s = size

I’m playing around with the video bit rate options and will post what I find to be the optimal settings for the web. Here’s a screen of the FLV output:

It’s a little pixelated but looks decent when you watch it. There are a ton of settings that can be tweaked and there’s definitely room to play with in regards to the file size. 30MB for a 15 minute video is tough to beat. Here’s a screen of the same frame rendered in mov format:

The dimensions are a little different with the second video and you can see that the colors are more vivid. I’m not sure if this is an encoding issue or just the nature of Flash vs. the Quicktime player. At any rate, there’s a lot of possibilities here and I’m looking forward to more experimentation.



4 Responses to “FLV Encoding with FFmpeg”

  1. curt says:

    hi there.. thanks for the great article. I am somewhat of a newbie when it comes to server stuff but i was wondering if you could point me to the right direction to be able to set up my linux directory to run FFMPEG automatically whenever a file gets droped into it. thx ahead of time, curt

  2. dennis says:

    Curt,

    Thanks for the reply and not knowing all the details of your application here’s what I’d recommend. I would create a cron job that checks the directory on a regular interval (ie every 15 minutes). Then a task or script can be kicked off that queues up all the raw videos and converts them one by one to flv or any other format. I say one by one because it will reduce load on the server converting them serially. If you kick off a process each time a file gets dropped into it then there’s the chance of several files being dropped and encoded all at once, which could kill the server. Like I said, I’m not sure of the details of your application, but the cron approach may be worth looking into. I hope this helps.

    Regards,
    Dennis

  3. V Vivek says:

    I was just curious if you have tried to get frames out of FLASH videos ?
    What would you reccomend to do so ?
    cheers
    Vivek

  4. dennis says:

    Vivek,

    Thanks for the message. Check this post out when you get a chance: http://www.db75.com/new_blog/?p=211. I hope this helps. If not, let me know and I’ll see what I can do.

    Regards,
    Dennis

Leave a Reply