Archive for January, 2012

FFMpeg tricks

Sunday, January 8th, 2012

Lets start off the topic by explaining some easy ways to getting media converted. I’ve been using ffmpeg to convert some WMV, FLV and AVI files into the same format (different containers and codecs means I had to use different players).

Now there are many end results here, so tweaking this the way you want. Start off by getting ffmpeg if you haven’t got it install already, it can be downloaded from http://ffmpeg.org/ (Windows and *nix). Ubuntu users can get it from “apt-get install ffmpeg”.

I’ve chosen MP4 as my default format, it works well with all the players I’m using, but this might different from person to person. To convert a file into MP4 simply do:

ffmpeg -i inputfile.ext -sameq outputfile.mp4

The trick here is ffmpeg figures out what codec you want based on the output file’s extension.

For converting multiple files at the same time, here’s little linux snippet:

for i in *.flv; do ffmpeg -i “$i” -sameq “$i.mp4”; done

And the windows version:

for %i in (*.flv); do ffmpeg -i “%i” -sameq “%i.mp4”

This will sadly result in the files ending up being named inputfilename.flv.mp4, but we can fix that!

Linux:  rename ‘s/\.flv//’ *.flv.mp4
Windows: gci *.flv.mp4|%{rename-item $_.fullname -newnam
e $_.fullname.Replace(“.flv.mp4”, “.mp4”)}
(Yes, that’s a Poweshell version,  DOS prompt suggestions are welcome in the comments :)).