Extract Single Frame as High-Quality PNG with FFmpeg
This article demonstrates how to use the FFmpeg command-line tool to extract a single, frame-accurate image from a video at a specific timestamp. You will learn the exact command structure required to output a high-quality, lossless PNG image, along with an explanation of how each parameter works to ensure the best possible visual quality.
The Standard Command
To extract a single frame at a specific timestamp, use the following FFmpeg command:
ffmpeg -ss 00:01:30 -i input.mp4 -frames:v 1 output.pngParameter Breakdown
-ss 00:01:30: Specifies the timestamp of the frame you want to extract. You can format this asHH:MM:SS(hours, minutes, seconds) or as a number of seconds (e.g.,90). Placing this before the input file (-i) enables fast seeking.-i input.mp4: Defines the path to your input video file.-frames:v 1: Instructs FFmpeg to export exactly one video frame.output.png: The name of the output file. Using the.pngextension automatically tells FFmpeg to export the frame as a lossless PNG image.
Ensuring Frame Accuracy
Placing the -ss parameter before the -i
parameter is highly efficient because it skips to the timestamp quickly.
However, this can sometimes result in a slightly inaccurate frame
capture depending on the video’s keyframe placement.
If you need absolute, frame-accurate precision, place the
-ss parameter after the input file:
ffmpeg -i input.mp4 -ss 00:01:30 -frames:v 1 output.pngNote: This method is slower because FFmpeg must decode the video from the beginning up to the specified timestamp, but it guarantees you get the exact frame requested.
Optimizing for Maximum Quality and Color Accuracy
Because PNG is a lossless format, FFmpeg will preserve the source
quality by default. However, video files and image files often use
different color spaces (YUV vs. RGB). To prevent color degradation or
shifting during conversion, force FFmpeg to output a high-quality RGB
pixel format using the -pix_fmt flag:
ffmpeg -ss 00:01:30 -i input.mp4 -frames:v 1 -pix_fmt rgb24 output.png-pix_fmt rgb24: Standard 8-bit RGB color depth. This ensures the output PNG uses standard, widely-compatible RGB colors.-pix_fmt rgb48be: (Optional) If your source video is 10-bit or high-dynamic-range (HDR), use this to export a 16-bit PNG and preserve the extended color depth.