Converting FLV to MPEG in Linux

  • July 26, 2007
  • Avatar for chris
    Van Patten

This article was originally posted on YouMakeMedia, however it is suitable for FOSSwire readers as well so we decided to post it. Some of the things referenced in the article are slightly old - it was written in October 2006, but the tutorial is timeless.

Be sure to check your local laws and regulations before you continue!

Linux users are often slighted when it comes to media tools. Macromedia/Adobe's shameful implementation of Flash 7 is one example (though Flash 9 is due out in January). When trying to watch a YouTube video this makes for some very difficult viewing, because the video and audio become out of sync.

Fortunately, we have a fantastic tool in FFMPEG. FFMPEG is a collection of free software for recording, transcoding, and streaming digital video and audio. It is a fantastic tool for Linux users who need to convert.

Of course, being able to convert to MPEG only works if you have an FLV. If the video is natively in SWF form (e.g. it doesn't use an FLV embed) you are out of luck, Linux users. To download your FLV, use a site such as VideoDownloader. You can also usually tell if the video is an FLV if it uses a player similar in style to the one available at Jeroen Wijering's site.

I'm on Ubuntu Linux (6.06) and FFMPEG is already installed. It's best to check again though. You can open up the Synaptic Package Manger and search for "FFMPEG". If it's checked, you've got it. If not, install it! While you're there, you'll want to install nautilus-open-terminal as I reference this in the tutorial.

Now navigate to your home folder (using Places > Home) and create a new folder for "My Videos" (or whatever you want to call it). This is important because Nautilus-open-terminal won't pick up your standard home folder. Move your downloaded FLV into this folder, and make sure it has a good name (I recommend video.flv for ease). Note that YouTube videos always are named get_video.htm, but you'll want to change this to an flv extension!

Now right click somewhere in the folder and select "Open in Terminal". This will launch a terminal specific to that folder. Edit the below code to suit your needs, paste into Terminal, and press enter.

Ubuntu users might need Sudo, might not. I usually use it out of habit so I'm not positive if it's required or not.

ffmpeg -i video.flv -ab 56 -ar 22050 -b 500 -s 320x240 test.mpg

The script, in this order:

  1. Launches FFMPEG
  2. Opens your FLV (change to suit yours)
  3. -ab : Sets the audio bitrate. Without this, it'll be set to the default of 64kbps
  4. -ar : Sets the audio samplerate. Default is 44100hz
  5. -b : Sets the video bitrate. Default is 2000kbps
  6. -s : Sets the size. Default is 160x128px
  7. Outputs to the filename you enter (change to suit your needs)

When I tried this, I changed nothing and got fairly decent video quality but the audio lacked. I'd definitely recommend tweaking the settings a bit to improve quality. You'll probably want to at least double the audio bitrate, although the samplerate is fine by default.

Avatar for chris Chris Van Patten

Home » Articles »