Skip to content [Tab]
~/posts/software/ffmpeg-extract-image-from-the-video-file.md
$ stat -x ffmpeg-extract-image-from-the-video-file.md POSIX filesystem
Access Mode: -rw-r--r-- (0644)
Author: uid:1000(@f7234bv9s8)
File Size: 1.9 KB (157 words)
Modified:
Flags: --cat="software" --tags="ffmpeg"

ffmpeg. Extract images from the video file.

attachment://featured-image.webp

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

@f7234bv9s8 maintainer

Software engineer and writer at notes:own:vision:com.