Friday, November 14, 2008

Converting files with ffmpeg

I just read some interesting blog pages and copied the info here. Thanks to the original posters!

--Convert FLV file to MPEG using ffmpeg:
ffmpeg -i myFile.flv -ab 56 -ar 22050 -b 500 -s 320x240 myFile.mpg

--convert a video file to PSP format using ffmpeg. After converting, copy the OutputFile to the video folder in your PSP:
ffmpeg -i "OriginalFile.avi" -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 320x240 "OutputFile.mp4"

--FFMPEG command to mix an audio file with a video file to create a final video:
ffmpeg -vcodec flv -qscale 9.5 -r 25 -ar 22050 -ab 32k -s 320x240 -i 1.mp3 -i Meta.ogv final.flv

--This command uses ffmpeg to convert a regular video into 3gp format thats used in mobile phones:
ffmpeg -i input_video.mp4 -s 176x144 -vcodec h263 -r 25 -b 12200 -ab 12200 -ac 1 -ar 8000 output_video.3gp

--Getting infos from a video file
ffmpeg -i video.avi

--Turn X images to a video sequence
This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc...) to a video file named video.mpg.
ffmpeg -f image2 -i image%d.jpg video.mpg

--Turn a video to X images
This command will generate the files named image1.jpg, image2.jpg, ...
The following image formats are also availables : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.
ffmpeg -i video.mpg image%d.jpg

--Encode a video sequence for the iPpod/iPhone:
ffmpeg -i source_video.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 final_video.mp4

Explanations :
* Source : source_video.avi
* Audio codec : aac
* Audio bitrate : 128kb/s
* Video codec : mpeg4
* Video bitrate : 1200kb/s
* Video size : 320px par 180px
* Generated video : final_video.mp4

--Encode video for the PSP:
ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4

Explanations :
* Source : source_video.avi
* Audio codec : aac
* Audio bitrate : 32kb/s
* Video codec : xvid
* Video bitrate : 1200kb/s
* Video size : 320px par 180px
* Generated video : final_video.mp4

--Extracting sound from a video, and save it as Mp3:
ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

Explanations :
* Source video : source_video.avi
* Audio bitrate : 192kb/s
* output format : mp3
* Generated sound : sound.mp3

--Convert a wav file to Mp3
ffmpeg -i son_origine.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 son_final.mp3

--Convert .avi video to .mpg
ffmpeg -i video_origine.avi video_finale.mpg

--Convert .mpg to .avi
ffmpeg -i video_origine.mpg video_finale.avi

--Convert .avi to animated gif(uncompressed)
ffmpeg -i video_origine.avi gif_anime.gif

--Mix a video with a sound file
ffmpeg -i son.wav -i video_origine.avi video_finale.mpg

--Convert .avi to .flv
ffmpeg -i video_origine.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv video_finale.flv


sources:
FFMpeg par l’exemple (French)
19-ffmpeg-commands-for-all-needs
ffmpeg page on binnyva.com