Export Frames in a Time Range Using FFmpeg

Extracting specific video frames within a defined timeframe is a common task in video processing. This guide demonstrates how to use FFmpeg’s powerful select filter to target a precise time range and export those matching frames as image files.

To extract frames within a specific time range, you use the select video filter with the between evaluation function. The filter checks the presentation timestamp (t) of each frame and only exports the frames that fall within your start and end times (measured in seconds).

The Command Syntax

Here is the standard command to extract frames between the 10-second mark and the 15-second mark of a video:

ffmpeg -i input.mp4 -vf "select='between(t,10,15)'" -vsync vfr output_%04d.png

Parameter Breakdown

Advanced: Selecting Frames by Frame Index

If you prefer to export frames based on frame numbers rather than timestamps, you can use n (the frame index) instead of t:

ffmpeg -i input.mp4 -vf "select='between(n,300,450)'" -vsync vfr output_%04d.png

This command exports frames starting from frame index 300 up to frame index 450.