How to Extract Every 100th Frame with FFmpeg

Extracting specific frames from a video is a common task in video processing, and FFmpeg makes this process highly efficient using its expression evaluation filters. This article provides a straightforward guide on how to use the FFmpeg select filter to extract exactly every 100th frame from a video file, explaining the command-line syntax and key parameters needed to achieve this result.

The FFmpeg Command

To extract every 100th frame from a video, use the following command in your terminal:

ffmpeg -i input.mp4 -vf "select='not(mod(n,100))'" -vsync vfr output_%04d.png

How the Command Works

Each component of the command plays a specific role in selecting and saving the correct frames:

Selecting Frames Starting From 1

If you want to skip the very first frame (frame 0) and instead start your extraction exactly at frame 100, frame 200, and so on, modify the expression slightly to ensure n is greater than 0:

ffmpeg -i input.mp4 -vf "select='gt(n,0)*not(mod(n,100))'" -vsync vfr output_%04d.png

This adjustments adds gt(n,0)* (greater than zero multiplied by the modulo logic), ensuring that the initial frame index of 0 is ignored.