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.avif

Essential Command-Line Parameters

  • -ss [timestamp]: Seeks to the specified position in the video (e.g., 00:00:10 for 10 seconds or 12.5 for 12.5 seconds). Placing this before -i ensures 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 the libaom-av1 encoder to output a compliant AVIF still picture rather than a video sequence.
  • -crf [value]: Sets the Constant Rate Factor for quality. The range is 0 to 63, where lower values mean higher quality. A value between 18 and 28 offers an optimal balance between visual fidelity and file size.
  • -b:v 0: Disables the target bitrate, forcing the encoder to rely entirely on the -crf value for constant quality encoding.
  • -pix_fmt [format]: Defines the pixel format. The standard choice is yuv420p for maximum web compatibility, or yuv444p to preserve full color resolution for graphics and high-fidelity photos.
  • -cpu-used [0-8]: Adjusts the encoding speed preset for libaom-av1. Lower numbers yield better compression at slower speeds; values between 4 and 6 provide 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.avif

Exporting 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.avif

Extracting 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.avif

The %04d placeholder creates zero-padded sequential numbers (frame_0001.avif, frame_0002.avif, etc.) for each exported image.