Here are a bunch of ffmpeg command lines that will do just about everything you need.
- Getting info from a video file
- Turn a sequence of images into video
- Turn a video into a sequence of images
- Encode video for Ipod/IPhone
- Encode video for PSP
- Extract audio from a video file and save it as mp3 format
- Convert a wave file to mp3
- Convert a avi video to mpeg
- Convert a mpeg video to avi
- Convert a avi video to uncompressed animated gif
- Add audio to an existing video-only file (mix audio and video)
- Convert a avi video to flv (flash video)
- Convert a flv video to mpeg
- Convert a avi video to dv
- Convert a avi video to mpeg specifically for DVD creation
- Compress a avi video to Divx
- Convert a Ogg Theora video to mpeg specifically for DVD creation
- Convert a avi video to mpeg2 for SVCD creation
- Convert a avi video to mpeg2 for VCD creation
ffmpeg -i video.avi
ffmpeg -f image2 -i image%d.jpg video.mpg
ffmpeg -i video.mpg image%d.jpg
ffmpeg -i source_video_file.avi -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv -trell 1 -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X output_file.mp4
ffmpeg -i source_video_file.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac output_file.mp4
ORffmpeg -i "OriginalFile.avi" -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 320x240 "OutputFile.mp4"
ffmpeg -i source_video_file.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output_file.mp3
ffmpeg -i original_audio_file.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output_file.mp3
ffmpeg -i original_movie.avi output_file.mpg
ffmpeg -i original_movie.mpg output_file.avi
ffmpeg -i original_movie.avi output_file.gif
ffmpeg -i son.wav -i original_movie.avi output_file.mpg
ffmpeg -i original_movie.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output_file.flv
ffmpeg -i myFile.flv -ab 56 -ar 22050 -b 500 -s 320x240 myFile.mpg
ffmpeg -i original_movie.avi -s ntsc -r ntsc -aspect 4:3 -ar 48000 -ac 2 output_file.dv
ORffmpeg -i original_movie.avi -target ntsc-dv output_file.dv
ffmpeg -i source_video.avi -target ntsc-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg
ffmpeg -i original_movie.avi -s 320x240 -vcodec msmpeg4v2 output_file.avi
ffmpeg -i original_movie.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 output_file.mpg
ffmpeg -i original_movie.avi -target ntsc-svcd output_file.mpg
ffmpeg -i original_movie.avi -target ntsc-vcd output_file.mpg
21 responses to “ffmpeg command line quickies…..”
One very important thing I just learned after two hours – I cannot write a .BAT file with “ffmpeg -i video.mpg image%d.jpg” and then run the batch file. If I do, I get the message “Unable to find a suitable output format for ‘imaged.jpg’. Instead, I must type that command on the actual command line prompt. At least, that’s how it works for me on Windows XP. Please let other people know about this potential pitfall.
use %%d in your batchfile and it will work.
These are very helpful. I have a question. When creating a slideshow from jpg files, is it possible to specify the duration each image will remain displayed? What are the other options for this feature, ie. crossfading, etc.
Thank you,
David Hudach
A big thank you from Canada!
@ first “Anonymous”:
I lost four hours!!!
Thanks to you, now it working fine.
Hi Many,
I hope you can help me out. I use ffmpeg to convert .avi to .mpg. I have created a movie in matlab, used movie2avi command to put it into .avi format, and then use the basic ffmpeg -i input.avi output.mpg. The .mpg file plays in mplayer, yet it has no color, is slanted, and has the effect of playing next to a reflective mirror. Its really weird. Any help is much appreciated. Thanks.
MB
Hi Mbb,
I would first of all try using vlc (www.videolan.org) to play both the avi file and the mpg file and see if that works. It might be the avi file that's flawed. Is there an option to output individual frames out of matlab. Because then you can use ffmpeg to "stitch" the frames directly to a mpg file. Sounds like movie2avi is using a avi codec that ffmpeg has trouble decoding.
TTYL
Many
Hope this helps….
TTYL
Many
Many,
Thanks, your idea worked out very well. I converted the frames to images, then to jpegs, then used ffmpeg to get the mpg file. ~mbb
Hi Many,
So, I have one more small (hopefully) issue. I need to lower the default fps (-r) from 25 to 4 fps. I know I have to also change the bit rate (-b), yet whatever I input, ffmpeg does not like the ratio. Shed some light? Thanks again.
~mbb
Mbb,
Hmmm, gald you got the other part working. About framerates I think you want to go the otherway. You see, you really want to use -r on input and set it to 4 and use -r on output and set it to 15 or 30. That way the encoder will "hold" a single image for 0.25sec in the encoder buffer (rather than 1/30th of a sec), but still encode it for 30 frame playback. In essence you'll be repeating the same input file for 0.25sec rather than 1/30th of a sec. Don't know if this makes sense.
I don't think you need to change the bitrate thisway.
Hope this helps…..
TTYL
Many
Mbb,
Failing that you can try the command from this youtube video……Just fast forward to 8:20 and have a look…..He explains it well…..
http://www.youtube.com/watch?v=ln9YgXt6gxw
TTYL
Many
Can ffmpeg write a 32bit avi from png/tga image sequence ?
ffmpeg -i Ball_%3d.tga -vcodec rawvideo -pix_fmt bgra ball.avi
The above cmd fails, And I could write mpg file, but no Alpha in that.
Can some one show me a successfull cmd line ?
Thanks
gaamaa
Sorry Gaamaa I have no idea……Maybe someone else can fill in the answer here…..
What a great resource! I have very little experience with FFmpeg, but using your site I managed learn quite a bit. For some reason i had an .avi that would not convert to an .mpg, so I cut it up into a bunch of jpegs, then reassebled the jpegs into an .mpg – worked like a charm, but i lost the audio, so i extracted the audio from the original .avi and added it to the new .mpg and it worked excpet the video and audio do not match up… Thanks for the great resource here.
Thank you very much, I wasn't realizing that creating an animated gif was that easy ffmpeg -i input.swf -r 1 output.gif
Thanks dude! your sequence of images example was exactly what I was looking for.
I have a gif animation. Any idea how to convert it to flash video or swf?
Hi Anonymous,
Making flash video out of a animated gif? Hmmm, not sure…..I will take a look around and see if I can figure it out…..check back in about a week or so to see if I've added something to this article.
TTYL
Many
does the -r flag for setting frame rate have a minimum value need? i tried using 0.044 but it not work
rafhelp,
Not sure what you mean. Minimum frame rate value would be 1, wouldn't it? what is 0.044 supposed to represent?
First place where I've been where the info is not only useful, but presented in a visually pleasing manner. Congrats!
I've tried to work with the ffmpeg command line ffmpeg -i filename.mpg filename.avi. Although it does the conversion, the ".avi" file video quality sucks. I've tried adding other parameters to no avail. I'm about to surrender.
Could anyone tell me how to improve my video quality? Any guidance appreciated. Thanks!!!