FFmpeg Select Filter: Export Frames by Time Range
This guide explains how to extract video frames within a specific
time window using FFmpeg's select filter. By evaluating the
presentation timestamp of each frame, the select filter
allows you to target an exact start and end duration and export matching
frames as an image sequence.
The Basic Command
To export frames between a start and end time, use the
between(t, start, end) expression inside the
-vf (video filter) option:
ffmpeg -i input.mp4 -vf "select='between(t, 10, 25)'" -vsync 0 output_%04d.pngHow It Works
-i input.mp4: Specifies the source video file.-vf "select='between(t, 10, 25)'": Theselectfilter evaluates each frame. The variabletrepresents the frame's presentation timestamp in seconds. Thebetween(t, 10, 25)function returns1(keep the frame) iftis between 10.0 and 25.0 seconds, and0(drop the frame) for all other times.-vsync 0(or-fps_mode passthroughin newer FFmpeg versions): Prevents FFmpeg from duplicating dropped frames to maintain the original frame rate. This ensures only the selected frames are written to disk.output_%04d.png: Defines the output naming pattern, generating sequential files such asoutput_0001.png,output_0002.png, and so on.
Selecting by Milliseconds
You can pass fractional seconds to target millisecond-level precision:
ffmpeg -i input.mp4 -vf "select='between(t, 12.5, 14.75)'" -vsync 0 output_%04d.jpgCombining Time Ranges with Frame Decimation
If extracting every frame in the target range generates too many files, combine the time filter with a frame-skipping expression. For example, to export only one frame per second between seconds 30 and 60:
ffmpeg -i input.mp4 -vf "select='between(t, 30, 60)*not(mod(n, 30))'" -vsync 0 frame_%04d.pngIn this expression, n is the frame number, and
not(mod(n, 30)) selects every 30th frame within the
30-to-60-second window.