Convert Video Frames to AVIF Using FFmpeg
This guide explains how to convert video frames into high-efficiency AVIF images using FFmpeg. You will learn the exact command-line parameters required to extract single frames, export image sequences, and optimize output quality and encoding speed using the AV1 codec.
Basic Command to Extract a Single Frame to AVIF
To extract a single frame from a video at a specific timestamp and save it as an AVIF image, use the following syntax:
ffmpeg -ss 00:00:10 -i input.mp4 -frames:v 1 -c:v libaom-av1 -still-picture 1 output.avifEssential Command-Line Parameters
-ss [timestamp]: Seeks to the specified position in the video (e.g.,00:00:10for 10 seconds or12.5for 12.5 seconds). Placing this before-iensures fast seeking.-frames:v 1(or-vframes 1): Limits the video output to exactly one frame.-c:v libaom-av1: Specifies the AV1 video codec library required to produce AVIF files.-still-picture 1: Instructs thelibaom-av1encoder to output a compliant AVIF still picture rather than a video sequence.-crf [value]: Sets the Constant Rate Factor for quality. The range is0to63, where lower values mean higher quality. A value between18and28offers an optimal balance between visual fidelity and file size.-b:v 0: Disables the target bitrate, forcing the encoder to rely entirely on the-crfvalue for constant quality encoding.-pix_fmt [format]: Defines the pixel format. The standard choice isyuv420pfor maximum web compatibility, oryuv444pto preserve full color resolution for graphics and high-fidelity photos.-cpu-used [0-8]: Adjusts the encoding speed preset forlibaom-av1. Lower numbers yield better compression at slower speeds; values between4and6provide the best balance for general use.
High-Quality Single Frame Extraction
To obtain an archival-quality still frame with balanced compression speed, combine the parameters as follows:
ffmpeg -ss 00:01:30 -i input.mp4 -frames:v 1 -c:v libaom-av1 -still-picture 1 -crf 20 -b:v 0 -cpu-used 4 -pix_fmt yuv420p frame.avifExporting Multiple Frames or an Image Sequence
To export multiple frames across the entire video or a specific
segment, omit -still-picture 1 (as it is restricted to
single-frame files) and define an output pattern:
Extracting Every Frame:
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 24 -b:v 0 -cpu-used 6 frame_%04d.avifExtracting at a Set Frame Rate (e.g., 1 frame per second):
ffmpeg -i input.mp4 -vf "fps=1" -c:v libaom-av1 -crf 24 -b:v 0 -cpu-used 6 frame_%04d.avifThe %04d placeholder creates zero-padded sequential
numbers (frame_0001.avif, frame_0002.avif,
etc.) for each exported image.