Configure libaom AV1 Partition Limits in FFmpeg
This article explains how to configure partition limits in the
libaom AV1 encoder using FFmpeg. By adjusting these limits,
you can balance encoding speed and compression efficiency, allowing for
faster encodes or higher-quality video output depending on your system’s
capabilities.
Understanding AV1 Partitions
The AV1 codec compresses video by dividing frames into blocks called partitions. These partitions can range in size from \(128\times128\) pixels down to \(4\times4\) pixels.
- Smaller partitions (\(4\times4\), \(8\times8\)) allow the encoder to capture fine details and complex motion, improving compression efficiency but significantly increasing encoding time.
- Larger partitions (\(64\times64\), \(128\times128\)) speed up the encoding process because the encoder has fewer blocks to analyze, though this may result in a slight loss of detail in complex scenes.
By default, libaom dynamically chooses partition sizes.
However, you can manually restrict these limits to optimize for speed or
quality.
Configuring Partition Limits in FFmpeg
To set the minimum and maximum partition sizes in FFmpeg, you must
pass the min-partition-size and
max-partition-size parameters to the
libaom-av1 encoder using the -aom-params
flag.
The syntax for this flag is:
-aom-params min-partition-size=WxH:max-partition-size=WxHValid block sizes include: 4x4, 8x8,
16x16, 32x32, 64x64, and
128x128.
Configuration for Faster Encoding
If you want to speed up your encoding process, you can restrict the
encoder from analyzing very small partitions. For example, setting the
minimum partition size to 16x16 and the maximum to
64x64 prevents the encoder from spending time on ultra-fine
details:
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 30 -cpu-used 4 -aom-params min-partition-size=16x16:max-partition-size=64x64 output.mkvConfiguration for Maximum Quality and Efficiency
If encoding speed is not a concern and you want to achieve the
highest possible compression efficiency, you can allow the encoder to
use the full range of partition sizes from 4x4 up to
128x128:
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 30 -cpu-used 2 -aom-params min-partition-size=4x4:max-partition-size=128x128 output.mkvRecommended Best Practices
While manual partition configuration gives you precise control, it is
highly recommended to pair these settings with the
-cpu-used parameter (typically set between 0
and 8). The -cpu-used setting acts as a
general speed/quality preset that automatically scales partition search
depth. Manually defining partition limits with -aom-params
should be used when you need to enforce strict constraints that the
default presets do not satisfy.