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.
- Low values (0–1): The encoder performs an exhaustive search of all possible compression tools, motion vectors, and block partitions. This yields the highest visual quality and the smallest file sizes (maximum compression efficiency), but encoding speed is extremely slow.
- Medium values (2–3): This range offers a balanced compromise, utilizing heuristic shortcuts to speed up the process while retaining most of the compression benefits.
- High values (4–5): The encoder skips more complex analysis passes to prioritize speed. Encoding is significantly faster, but you will experience a slight drop in visual quality or an increase in file size for a target quality.
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.
- Using
cpu-used 0or1provides the absolute best quality-per-bitrate ratio. This is ideal for archival purposes where encoding time does not matter. - Using
cpu-used 2or3results in a minimal quality penalty (often imperceptible to the human eye) while drastically reducing the time required to encode the video. - Using
cpu-used 4or5introduces a noticeable drop in efficiency. To maintain the same visual quality as a lower setting, the encoder will require a higher bitrate, resulting in larger file sizes.
Recommended Settings
To get the most out of libvpx-vp9, use the following guidelines based on your workflow:
- Archiving and Premium VOD: Use
-deadline goodand-cpu-used 1or-cpu-used 2. This ensures excellent quality and high compression efficiency for files that will be served to millions of viewers. - Standard Video-on-Demand (VOD): Use
-deadline goodand-cpu-used 4. This is widely considered the “sweet spot” for general web delivery, offering a great balance of fast encoding times and solid compression. - Live Streaming and Video Conferencing: Use
-deadline realtimeand-cpu-used 5to-cpu-used 8. This forces the encoder to prioritize low latency and consistent frame rates over raw compression efficiency.