Monday, April 25, 2011

Converting flash video to mpg using ffmpeg in linux ubuntu

Converting flash video to mpg using ffmpeg in linux ubuntu.. I posted a script recently to extract flash videos from your web browsers cache in linux, sometimes flvs can be missing parts that stop you from skipping forward etc but ffmpeg converts most video formats easily so we just need to apt-get it:
sudo apt-get install ffmpeg
I'm not going to into too much depth with ffmpeg here other than to convert an flv to an mpg, I recommend checking out the ffmpeg documentation for anything specific, you can also google it from here:

Another option is, if your looking for the GUI way to convert videos in Linux, to use WinFF which you easily install by adding a repository in ubuntu: http://code.google.com/p/winff/wiki/UbuntuInstallation

What I wanted to be able to do was convert all of the flv's I had in a directory to mpg's, to do this using ffmpeg simply:
ffmpeg -i input.flv output.mpg
ffmpeg's clever enough to figure the rest out for itself, there are many options you can us, I decided just to set the frame size to 800x600 for simplicity (-s 800x600) so my final ffmpeg command was:
ffmpeg -i input.flv -s 800x600 output.mpg
In another post I posted a script to extract flash videos from the web browser cache and put them into a separate directory for storage (click here to read this post) so this script is an extension of that script to convert all flv's into mpeg and put them into a video directory:
#!/bin/bash
INPUTDIR=~/Videos/flvs
OUTPUTDIR=~/Videos

for f in $INPUTDIR/*.flv
do
    a=$(basename $f | cut -f1 -d '.')
    ffmpeg -i "$f" -s 800x600 "$OUTPUTDIR/$a.mpg"
done
This may take some time to complete depending on how many flash flv files you have the input directory.. I generally use my cache flash extractor bash script then sift through the flvs directory deleting what I don't want, then convert the videos I want to keep.

If you find it useful let me know..

No comments:

Post a Comment