Transcoding AVI to FLV with ffmpeg
I recently needed to convert from XviD AVIs ripped from a DVD to Flash Video format (FLV), which my Gallery software has better embedded player support for. Initially I tried ripping the DVD again with ImTOO DVD Ripper Platinum, which also supports ripping directly to FLV. However, no matter how high I cranked up the bitrate the resulting video was very blocky and shitty looking.
Next, I tried using MediaCoder, which is supposed to be a solid open-source transcoder, but damned if I could get it to work with Flash; it would just hang. I think the FLV support in the version of ffmpeg used by MediaCoder is broken, since I couldn’t even get FLV conversion working with the ffmpeg command line below.
Finally I tried getting ffmpeg running on my Ubuntu Feisty box.
Initially I used the ffmpeg version obtained with sudo apt-get install ffmpeg. I ran the following:
ffmpeg -i in.avi -y -b 800 -r 25 -f flv -vcodec flv -ab 128 -ar 44100 out.flv
That worked great, except for one thing. out.flv had no audio.
After some Googling about I ran across a helpful post by someone else with the problem. Like me, he wasn’t able to get an audio stream in the output file.
I suspected the ffmpeg binary from the Ubuntu package was missing the MP3 encoding support, hence no audio. Using instructions on this page I built the latest ffmpeg from code, then used the following command line:
ffmpeg -i in.avi -y -b 800 -r 25 -f flv -vcodec flv -acodec mp3 -ab 128 -ar 44100 out.flv
And that did the trick. I can’t believe what a pain in the ass video work is. Seriously, is the command line parser from hell really the best we can do?
August 29th, 2008 - 08:59
im sure theres a gui out there. You could write a script using the line that worked and pass the input and output files as arguements if the other settings are always the same
Nice work dude, glad you got it sorted
October 12th, 2008 - 01:10
Online video is a train wreck thanks to the jerks who run the corporate fleecing mills. Everybody is trying to force users into their own proprietary standard and the result is CHAOS. If this had hapened to television, we’d still be listening to radio.
Open source is late to the party. The folks at Videolan have a good cross-platform GUI based open source player/transcoder/streamer (VLC), but it’s still beta and they keep breaking it.
http://www.videolan.org/vlc/
Only certain versions work well (0.8.6i is one but doesn’t support FLV) the latest VLC binary as I write this is 0.9.4 which does support FLV but unfortunately the project has made extensive changes to the VLC application and the transcoder isn’t working well. MAC users also report the video player opperates erratically. It will undoubtedly work better as the kinks are ironed out. This little machine is spare yet powerful. I have no doubt that it will become very popular once it reaches the post beta stage.
In the meantime – good luck finding a decent transcoder. It probably doesn’t exist.
July 21st, 2009 - 07:04
@ANelson: Thanks! I modified the line so that it would work for me too:
ffmpeg -i SDC10247.AVI -y -r 25 -f flv -vcodec flv -s qvga -an out.flv
The original .AVI was 30 FPS 640×480 with bad sound.
I used Avidemux to grab a screenshot of the .flv for my Flash-player.