Monday, December 01, 2008

Converting Flash to MPEG with ffmpeg

I was playing around with converting files between different formats. I downloaded some creative-commons licensed videos off of youtube and then was trying to convert to MPEG video or MP3 audio formats. As is often the case, I found both good and bad advice on the internet. As a note to self, and perhaps of help to others, here are the things that worked for me:

CONVERTING FLASH VIDEO (flv) to MPEG (mpg)

ffmpeg -i my_file.flv -acodec copy -b 500 -s 640x480 my_file.mpg

This advice came from from here. The bad advice suggested using an -ab and -ar 22050; that give me an animation with no sound.

CONVERTING FLASH VIDEO (flv) to MP3 (mp3).

ffmpeg -i my_file.flv -ab 128 -ar 44100 my_file.mp3
This advice came from here.

BATCH OPERATIONS WITH BASH

for k in *.flv; do ffmpeg -i $k -ab 128 -ar 44100 "${k%.flv}.mp3"; done

This advice came from the #bash channel on irc. Basically what this does is process a bunch of files which end in flv. It converts it to mp3's. Note the syntax with brackets at the end. This allows me to keep the filenames constant from flv file to mp3 file, in that foo_bar.flv becomes foo_bar.mp3.

Hope this helps someone else out there.

No comments: