ffmpeg -i M2U00139.MPG -y -f avi -b 1150 -s 320x240 -r 29.97 -g 12 -qmin 3 -qmax 13 -ab 224 -ar 44100 -ac 2 1.avi
Using this command, you will get one image per second.
ffmpeg -i test.mpg -r 1 image%d.jpg
4. Extracting an audio track from a video
With ffmpeg, you can also mix video and audio, and extract an audio track from a video in mp3 format:
ffmpeg -i video.avi -f mp3 audio.mp3
In this example, we used the -f flag.
The -f flag forces the output format.
To achieve the same result, you can also disable video capture; to disable video recording, use the -vn parameter:
ffmpeg -i video.avi -vn audio.mp3
5. Creating screencasts
With ffmpeg, you can also create a simple video using screenshots from your desktop.
For this, we will use some of the flags shown in the first example:
ffmpeg -f x11grab -r 25 -s wxga -i :0.0 /tmp/outputFile.mpg
Note: 0.0 is the display.screen number for your X11 server, just as specified in the DISPLAY environment variable.
You can capture 25 frames per second from your wxga screen (or specify a resolution using the -s parameter, such as 1024 × 768) and save the mpg video to /tmp.
6. Converting images into a video
Suppose you have many images named "img001.jpg", "img002.jpg", and so on in sequence. You can convert them into a video using the following command:
ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg
7. Capturing video from a webcam
To record video, run ffmpeg with the following parameters:
ffmpeg -f video4linux2 -s 320x240 -i /dev/video0 out.mpg
To record both audio and video, use:
ffmpeg -f oss -i /dev/dsp -f video4linux2 -s 320x240 -i /dev/video0 out.mpg
These are just a few examples; ffmpeg can perform a wide variety of audio and video editing tasks, and there are many examples available online.
