ffmpeg. Extract images from the video file.

Lets take a look of the reverse process described in this post. To destructure video file to an array of still images the following needs to be done:

# input.mp4 is the video file to extract images from
# %04d.jpg is the pattern of naming the image files. Currently means that the
# file names will be zero-padded sequential numbers, eg. 0001.jpg,
# 0002.jpg,, etc.

$ ffmpeg -i input.mp4 %04d.jpg

ffmpeg uses frame rate from the file so no reason to care about this.


For example you need to extract images from specific time:

# start desctructure process from 00:04s
$ ffmpeg -ss 00:00:04 -i input.mp4 %04d.png

If you need just one image at a given time time:

# extract image at 00:04s
$ ffmpeg -ss 00:00:04 -i input.mp4 extracted_image.png

Next example allow to extract images at every second by specifying frame rate to 1 by using video filter ‘-vf fps=1’:

$ ffmpeg -i input.mp4 -vf fps=1 %04d.png

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *