Wednesday, January 11, 2012

FFMpeg, video converter for Iphone / Nokia / PSP and other devices

FFmepg is a command line utility to convert audio/video, resize it, manipulate frame and bit rate, etc etc. I use it to convert .avi videos to .mp4, which are watchable on my phone.

Get it with this command in Terminal:

sudo apt-get install ffmpeg

(*Note for writtings bellow: INPUT.avi is the movie name you wish to convert, so name it accordingly, OUTPUT.mp4 can be named as you see fit.)

To check video information do the following command:

ffmpeg -i INPUT.avi

To change video bitrate:

ffmpeg -i INPUT.avi -b:v 64k OUTPUT.avi

To force the frame rate of output file to 30 fps, do the following:

ffmpeg -i INPUT.avi -r 30 OUTPUT.avi

If you wish to turn a number of images to video:

ffmpeg -f image -i image%d.jpg VIDEO-OUTPUT.mpg

Or vice versa, turn a video into a number of pictures:

ffmpeg -i VIDEO-INPUT.mpg image%d.jpg

For Iphone users that wish to convert from .avi to .mp4:

ffmpeg -i INPUT.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X OUTPUT.mp4

PSP and Nokia owners, use this to convert from .avi to .mp4:

ffmpeg -i INPUT.avi -f mp4 -vcodec mpeg4 -b 2200k -r 30 -s 640x360 -acodec libfaac -ar 32000 -ab 128k -ac 2 -threads 8 OUTPUT.mp4

If this does not work for you (libfaac errors), check this extensive guide on installing and setting ffmpeg up manually:
http://ubuntuforums.org/showthread.php?t=786095

3 comments: