How to Configure libaom cpu-used in FFmpeg
This article provides a straightforward guide on how to configure the
cpu-used parameter when encoding AV1 video using the
libaom encoder in FFmpeg. You will learn what this
parameter does, the range of values you can use, and how to apply it in
your FFmpeg command-line workflows to balance encoding speed and
compression efficiency.
What is the cpu-used Parameter?
In the libaom-av1 encoder, the -cpu-used
parameter controls the trade-off between encoding speed and visual
quality (compression efficiency).
- Lower values instruct the encoder to use more intensive compression algorithms, resulting in smaller file sizes and better quality, but at the expense of extremely slow encoding speeds.
- Higher values disable complex compression features, leading to much faster encoding speeds, but resulting in larger file sizes or lower visual quality at a given bitrate.
Valid Value Range
The -cpu-used parameter accepts integer values ranging
from 0 to 9 (and up to 11 in newer experimental
versions of libaom):
- 0 to 3: Extremely slow. Recommended only for archival purposes where encoding time is not a constraint.
- 4 to 6: The sweet spot. Offers a good balance of speed and compression efficiency for standard encodes. 4 or 5 are widely recommended as default starting points.
- 7 to 9: Fast/Real-time encoding. Best used for live streaming, quick drafts, or testing purposes.
How to Use cpu-used in an FFmpeg Command
To set this parameter, append -cpu-used followed by your
desired value in your FFmpeg command.
Here is a standard example using Constant Rate Factor (CRF) mode:
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 30 -b:v 0 -cpu-used 4 -c:a libopus output.mkvIn this command: * -c:v libaom-av1 specifies the libaom
AV1 video encoder. * -crf 30 sets the quality target (lower
is better quality, standard range is 20-35). * -b:v 0 is
required when using CRF mode with libaom to enable constant quality. *
-cpu-used 4 sets the speed/quality preset to a balanced
level of 4. * -c:a libopus transcodes the audio to Opus,
which pairs well with AV1.
Recommended Settings for Different Use Cases
Depending on your hardware and time constraints, use these configurations:
For maximum quality (Slow):
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 26 -b:v 0 -cpu-used 2 output.mkvFor everyday encoding (Balanced):
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 28 -b:v 0 -cpu-used 4 output.mkvFor fast testing/streaming (Fast):
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 32 -b:v 0 -cpu-used 8 output.mkv