The video file is composed of the frames that can be saved into the image files with one command, the number of resulting images is a product of the video frame rate and its duration in seconds. For example, if the clip.avi file have a 1-minute duration and its frame rate is 25 fps, then the following command will produce 60×25=1500 images, 25 for each second
ffmpeg -i clip.avi frame%d.jpg
The output directory will contain 1500 files named like frame1.jpg, frame2.jpg, etc. To keep the same length for all file names, we specify the number of appended digits with a number after the % sign:
ffmpeg -i clip.avi frame%4d.jpg
Resizing, cropping and padding images
Images can be resized in a similar way as videos, for example the output of the color video source has 320×240 pixels resolution and can be enlarged to VGA resolution in 2 ways:
- using the s or size parameter of the color video source
- using the -s option for the output
For example the next two commands have the same result, orange rectangle of a CIF (352×288) size:
ffmpeg -f lavfi -i color=c=orange:s=cif orange_rect1.png
ffmpeg -f lavfi -i color=c=orange -s cif orange_rect2.png