How to export thumbnail images with FFmpeg

Extracting image with timecode

We can use the seek option to set a point in time to specify what we want a still image of.

ffmpeg -ss 00:07:35 -i input.mkv -vframes 1 00-07-35.png

The time code here (-ss 00:07:35) is hours:minutes:seconds. This is probably the fastest and easiest way to take a screenshot.

Extracting specific frame number

We can also export the same image by specifying the exact frame at a given time. Let’s calculate the frame number for 00:07:35, shall we? The point in the video is 7 minutes and 35 seconds, right? That equals to is 455 seconds in the video (60*7+35). Since the video is playing at 23.976 frames per second we need to multiply the seconds we have with the FPS. This gives us the frame number: 10909.

(7,35 minutes in seconds)*(frame rate of video)

You can also use a frame calculator if you think that is easier. So now we can easily export frame 10909 with:

ffmpeg -i input.mkv -vf select=gte(n\,10909) -vframes 1 frame-10909.png

-i is your video file input. -vf select=gte(n\,10909) tells FFmpeg to start at the 10909th frame. -vframes 1 sets the number of video frames to output. frame-10909.png generates the file name.

Extracting image every X point in time

You can extract a still image every given point in time for the video. The way you specify the time is by seconds. So if you want to export an image every 10 seconds you would use fps=1/10. If you want to export an image every 1 hour and 23 minutes you will have to calculate that in seconds which is 60+23*60=4980. Then you can use fps=1/4980.

ffmpeg -i input.mkv -vf fps=1/1800 %04d.bmp

Here are some time examples: Every second: fps=1 Evry ten seconds: fps=1/10 Evry minute: fps=1/60 Evry ten minutes: fps=1/600 Evry 15 minutes: fps=1/900 Note that this way of exporting images is very slow and I suspect that this is either a bug in FFmpeg or something that has not been paid much attention to.

Filename patterns

There are many ways you can name the output files. Here are some examples: image-%03d.png = image-000.png, image-001.png… image-%d.png = image-1.png, image-2.png… image-*.png = image-a.png, image-b.png…


FFmpeg Wiki: Seeking

FFMpeg Wiki: Create a thumbnail image every X seconds of the video

FFMPEG An Intermediate Guide/image sequence

Thumbnails (iframe / scene change) – 2018