Extract Frames from Video as Images Using FFmpeg

This article provides a quick overview and step-by-step guide on how to extract specific frames from a video file using FFmpeg on Linux. You will learn the exact commands to capture a single frame at a precise timestamp, extract frames sequentially at a specific interval, and export a high-quality batch of images from your video files. FFmpeg handles these tasks efficiently through the command line without the need for heavy video editing software.


Extracting a Single Frame at a Specific Timestamp

To pull a single, precise frame from a video, you use the seek (-ss) flag. Placing -ss before the input file ensures fast seeking, which allows FFmpeg to jump directly to the timestamp without reading the entire video from the beginning.

ffmpeg -ss 00:01:30 -i input.mp4 -vframes 1 output.jpg
  • -ss 00:01:30: Seeks to the 1 minute and 30 seconds mark. You can use the HH:MM:SS format or specify the time in seconds (e.g., 90).
  • -i input.mp4: Defines the path to your source video file.
  • -vframes 1: Tells FFmpeg to only export one single video frame.
  • output.jpg: The name and format of your output image. Changing the extension to .png will output a lossless PNG instead.

Extracting Frames Sequentially at Intervals

If you need to sample a video by saving a frame at regular intervals—such as one frame every second or one frame every minute—you can utilize the frame rate video filter (-vf fps=).

ffmpeg -i input.mp4 -vf "fps=1" thumb_%04d.png
  • -vf "fps=1": Applies a video filter that outputs 1 frame per second of video. To capture a frame every 10 seconds, you would use fps=1/10. To capture 5 frames per second, use fps=5.
  • thumb_%04d.png: Creates sequentially named files. The %04d is a placeholder that FFmpeg replaces with a four-digit padded number (e.g., thumb_001.png, thumb_002.png).

Extracting All Frames from a Specific Video Segment

When you need to dump every single frame from a specific scene for high-precision work, combine the seek time, duration, and sequential naming conventions.

ffmpeg -ss 00:02:15 -i input.mp4 -t 5 frames_%03d.png
  • -t 5: Restricts the operation to a 5-second duration starting from the -ss timestamp.
  • frames_%03d.png: Saves every frame within that 5-second window. Depending on the video's frame rate (e.g., 30 fps), this will generate roughly 150 images named sequentially from frames_001.png onward.

Managing Output Quality

By default, FFmpeg applies standard compression to JPEG outputs. If image quality is a priority, you can control the compression level using the -q:v (or -qscale:v) option.

ffmpeg -ss 00:05:00 -i input.mp4 -vframes 1 -q:v 2 high_quality.jpg
  • -q:v 2: Controls the video quality scale for JPEG. The scale ranges from 1 to 31, where a lower number represents higher quality and a larger file size. A value of 2 to 5 offers excellent visual quality. For absolute lossless quality, it is recommended to export to the PNG format instead.