This post contains a number of useful commands for ffmpeg, a tool for converting video file formats. This post shows how to convert AVI to MPEG, MPEG to FLV, how to extract sound from a video, and how to get still frames from a video.
You can have ffmpeg read a video file and show information about it like so:
This will tell you the video length, bitrate, and video and audio stream formats, e.g.
Getting a still from a video
In order to get a single frame from a video and save it as a JPEG so that you can use it as a preview, do:
This will record 1 frame (vframes=1) at a framerate of 1 (r=1), at position 1:15 , ignoring audio (-an). You can record multiple stills this way: set the number of frames (vframes) to the number of stills you want, and specify a framerate. If you set r=10, stills will be recorded every 10 seconds. You will need to specify a naming system for the output files:
You can specify the frame size (resolution) for your stills:
Or fiddle with the aspect ratio:
Extracting sound from a video file
If you want to extract the sound from a video file and save it off as an mp3, do:
Here, we use -vn to disable video. We set the audio sampling rate to ar=44.1 kHz, number of channels to ac=2, and the bitrate to ab=192 bps. The result is saved to mp3 (we force mp3 format using the -f flag).
Convert video formats
Nothing could be easier in ffmpeg (ignoring bags of flags to finetune the output). Converting AVI to MPEG is done like this:
And the other way around:
Or AVI to FLV:
The flag you’ll probably need is:
This will change the movie resolution to 320×240, which will be handy when you plan to show your video online.