Configure libaom AV1 Drop Frame in FFmpeg

When encoding video with the AV1 codec using the libaom library in FFmpeg, managing bitrate spikes is crucial for streaming and low-bandwidth scenarios. This guide provides a straightforward explanation of how to configure the drop-frame parameter in libaom-av1 using FFmpeg, helping you prevent buffer underflows by allowing the encoder to drop frames when necessary.

The drop-frame feature in the libaom-av1 encoder is controlled via the -drop-threshold option in FFmpeg. This parameter is used in rate-controlled encoding (such as Constant Bitrate, or CBR) to drop video frames when the encoding buffer fullness drops below a specified percentage.

The -drop-threshold Parameter

The -drop-threshold option accepts an integer value from 0 to 100:

  • 0 (Default): Disables frame dropping. The encoder will attempt to encode every frame, even if it causes bitrate spikes or violates buffer constraints.
  • 1 to 100: Enables frame dropping. The value represents the buffer fullness percentage threshold. If the virtual buffer level falls below this percentage, the encoder drops the current frame to conserve bits and preserve the target bitrate.

FFmpeg Command Example

To use this parameter, you must define a target bitrate (-b:v) and a buffer size (-bufsize) along with the -drop-threshold value. Below is an example of a Constant Bitrate (CBR) configuration with frame dropping enabled:

ffmpeg -i input.mp4 -c:v libaom-av1 -b:v 1M -maxrate 1M -bufsize 2M -drop-threshold 30 output.mkv

Parameter Breakdown:

  • -c:v libaom-av1: Selects the AOM AV1 encoder wrapper.
  • -b:v 1M: Sets the target bitrate to 1 Mbps.
  • -maxrate 1M: Restricts the maximum bitrate to 1 Mbps to enforce CBR limits.
  • -bufsize 2M: Sets the receiver buffer size to 2 Megabits.
  • -drop-threshold 30: Instructs the encoder to drop frames if the buffer fullness drops below 30% (0.6 Megabits in this scenario).

By adjusting this threshold, you can balance video smoothness (fewer dropped frames) against strict bitrate compliance (more dropped frames during complex scenes).