Optimizing VP9 Encoding Speed with CPU-Used

The cpu-used parameter is a critical setting in the libvpx-vp9 video encoder that directly controls the balance between encoding speed and compression efficiency. By adjusting this parameter, users can dictate how much computational effort the encoder exerts to compress video data. This article explains how the cpu-used parameter works, its impact on video quality and file size, and how to select the optimal value for your specific use case.

Understanding the cpu-used Parameter

In the libvpx-vp9 encoder, the cpu-used parameter accepts integer values that trade encoding speed for quality. The scale and behavior of this parameter depend on the encoding mode (deadline) being used: Good Quality (the default mode for file-based encoding) or Realtime (designed for low-latency live streaming).

Good Quality Mode (Standard Encoding)

In the default -deadline good (or -deadline best) mode, the cpu-used parameter accepts integers from 0 to 5.

Realtime Mode (Live Streaming)

When using -deadline realtime, the encoder is optimized for speed, and the cpu-used parameter expands to values between 5 and 8 (or negative values -5 to -8 in some FFmpeg configurations).

In this mode, higher numbers dramatically reduce CPU usage to ensure the encoder can process frames in real time without dropping them, though this comes at the expense of compression efficiency.

Impact on Encoding Speed

The relationship between cpu-used and encoding speed is non-linear. Changing the value from 0 to 1 can result in a massive speedup (often doubling the encoding speed) with negligible loss in visual quality.

As you move from 1 to 4, the encoding speed continues to increase rapidly. Beyond cpu-used 4, the speed improvements begin to plateau in Good Quality mode, as the encoder has already disabled the most CPU-intensive algorithms.

Impact on Compression Efficiency

Compression efficiency refers to how well the encoder can maintain high visual quality at a lower bitrate.

To get the most out of libvpx-vp9, use the following guidelines based on your workflow: