How libvpx cpu-used Affects Encoding Performance
The cpu-used parameter in the libvpx encoder (used for
VP8 and VP9 video compression) is a critical setting that directly
balances encoding speed against visual quality and file size. This
article explains how adjusting this speed preset impacts CPU
utilization, encoding time, and compression efficiency, helping you
select the optimal configuration for your specific video processing
workflow.
Understanding the cpu-used Parameter
In libvpx, the --cpu-used (or -cpu-used in
FFmpeg) parameter acts as a speed preset. It controls the depth of the
encoder’s search algorithms, partition decisions, and motion
estimation.
The parameter accepts integer values within a specific range: *
For VP9: The range is typically 0 to
8 (and up to 9 in newer versions). *
For VP8: The range is typically -16 to
16.
Unlike other encoders where higher numbers might mean slower speeds, in libvpx, lower values result in slower encoding (higher quality/better compression), while higher values result in faster encoding (lower quality/worse compression).
Impact on Encoding Speed and CPU Utilization
As you increase the cpu-used value, the encoder disables
or simplifies complex compression tools to save processing time:
- Low Settings (0 to 2): The encoder performs exhaustive searches to find the most efficient way to compress the video. This fully utilizes CPU cores for complex mathematical calculations but results in very slow encoding speeds.
- Medium Settings (3 to 5): This is the sweet spot for standard video-on-demand (VOD) encoding. It balances CPU resource consumption with reasonable processing times.
- High Settings (6 to 8+): The encoder skips many deep-analysis steps. CPU utilization per frame drops significantly, allowing for high-speed encoding, which is essential for real-time live streaming or low-latency communication.
Impact on Video Quality and Bitrate Efficiency
The time saved by using a higher cpu-used setting comes
at a cost to compression efficiency:
- Compression Efficiency: Lower settings (e.g.,
cpu-used=1or2) allow the encoder to pack more visual data into a smaller file size. If you compare a video encoded atcpu-used=1with one encoded atcpu-used=8at the exact same target bitrate, thecpu-used=1version will have noticeably fewer compression artifacts, sharper details, and better color accuracy. - File Size: If you are encoding using a constant
quality mode (like CRF), higher speed presets (like
cpu-used=6) will result in a larger file size to achieve the same target visual quality compared to a slower preset.
Recommended Settings for Different Use Cases
To get the best performance out of libvpx, you should align the
cpu-used parameter with your specific application:
- Archiving and Premium VOD (
cpu-used=1or2): Use these settings when storage space and video quality are the highest priorities, and encoding time is not a constraint. Settings of0are rarely recommended due to diminishing returns in quality relative to the massive increase in encoding time. - Standard Web Video and General Encoding
(
cpu-used=3or4): This range offers the best compromise. It provides excellent VP9 compression efficiency while keeping encoding times within a practical, cost-effective range. - Real-Time Streaming and Video Conferencing
(
cpu-used=5to8with--rtmode): For live encoding, speeds must keep up with the incoming frame rate (e.g., 30 or 60 fps). Settings of5or higher—specifically combined with the real-time deadline flag—ensure the CPU can process frames fast enough to prevent lag and frame drops.