How to Set libaom AV1 Static Threshold in FFmpeg
This article provides a straightforward guide on how to configure the
static threshold parameter when encoding AV1 video using the
libaom-av1 encoder in FFmpeg. By adjusting this setting,
you can optimize your encoding efficiency, reduce CPU usage, and control
file size by skipping the processing of blocks that experience little to
no motion between frames.
What is the Static Threshold?
The static threshold in the libaom AV1 encoder is a
setting that determines whether a block of pixels has changed enough
from the previous frame to warrant being re-encoded.
If the change in a block falls below the specified threshold, the encoder treats it as static and skips encoding that block, reusing the data from the previous frame instead. This is highly beneficial for videos with low motion, such as screencasts, presentations, or talking-head interviews, as it saves significant processing time and reduces bitrate.
Configuring
-static-thresh in FFmpeg
To configure this setting, use the -static-thresh
private option in your FFmpeg command.
The syntax is: -static-thresh <value>
- Value Range: Typically, this value ranges from
0to1000. - Default Value: The default value is
0, which disables the feature and forces the encoder to analyze every block, ensuring maximum visual quality at the expense of encoding speed. - Higher Values: Increasing the value (e.g.,
100to500) allows the encoder to skip more blocks. This speeds up encoding and reduces file size but can introduce blocky artifacts in areas with subtle motion, such as slow gradients or shadows.
Example FFmpeg Command
Below is an example of an FFmpeg command that applies a static
threshold of 100 using the libaom-av1
encoder:
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 30 -b:v 0 -static-thresh 100 output.mkvIn this command: * -c:v libaom-av1 selects the Reference
ADK AV1 encoder. * -crf 30 -b:v 0 sets the quality target
using Constant Rate Factor. * -static-thresh 100 tells the
encoder to skip processing blocks with motion changes below a score of
100.
Recommended Settings
- For High-Motion/Movie Content: Keep
-static-threshat0(disabled) or set it to a very low value (under50) to avoid loss of detail in complex scenes. - For Desktop Recording/Screencasts: Use a higher
value between
200and1000. Because large portions of the screen remain completely static, this will dramatically speed up your encoding times and significantly lower the output file size without a noticeable loss in quality.