Best VP9 cpu-used Value for Real-Time Streaming
Selecting the correct cpu-used parameter in the
libvpx-vp9 encoder is critical for maintaining stable frame
rates and preventing lag during live broadcasts. This article explains
the recommended cpu-used values for real-time VP9
streaming, how this setting impacts encoding speed and video quality,
and how to configure it for optimal performance.
The Recommended Value: 5 to 8
For real-time streaming applications (such as WebRTC, live
interactive broadcasting, or low-latency streaming), the recommended
cpu-used value is between 5 and 8, with
6 being the most common sweet spot for modern
hardware.
To use these values effectively, you must also set the encoder
deadline to realtime (using -deadline realtime or
-quality realtime in FFmpeg).
Here is how the recommended values perform in practice:
cpu-used=5: Offers the highest visual quality possible within the real-time budget. It requires a relatively powerful, modern CPU to encode without dropping frames, making it ideal for high-end server environments.cpu-used=6: The industry-standard default for real-time VP9 encoding. It provides an excellent balance between compression efficiency, visual quality, and CPU utilization.cpu-used=7andcpu-used=8: These values prioritize encoding speed over quality. They are recommended for resource-constrained systems, mobile devices, or high-frame-rate streams (like 1080p at 60fps) where the CPU cannot keep up with lower settings.
Why Lower Values are Unsuitable for Real-Time
In libvpx-vp9, the cpu-used parameter
ranges from 0 to 9 (when in real-time
mode).
- Values 0 to 4 prioritize video quality and compression efficiency. They require massive computational power and will cause the encoder to fall behind the live video source, resulting in dropped frames, stuttering, and massive latency.
- Values 5 to 9 trigger optimized, fast-encoding algorithms designed specifically to keep encoding times below the duration of a single video frame (e.g., under 33 milliseconds for a 30fps stream).
Recommended FFmpeg Configuration
When streaming live using FFmpeg and libvpx-vp9, you
should pair the cpu-used setting with a constant bitrate
(CBR) configuration. This prevents bitrate spikes that could congest the
viewer’s network.
Below is an example of an optimized real-time VP9 encoding command:
ffmpeg -i input_source \
-c:v libvpx-vp9 \
-s 1280x720 \
-b:v 2000k -minrate 2000k -maxrate 2000k -bufsize 1000k \
-deadline realtime \
-cpu-used 6 \
-static-thresh 0 \
-frame-parallel 1 \
-f rtp rtp://destination_addressKey Parameter Explanations:
-deadline realtime: Forces the encoder to prioritize speed to ensure real-time delivery.-cpu-used 6: Balances CPU load and video quality.-static-thresh 0: Ensures the encoder does not skip blocks, which maintains consistent quality in low-motion scenes.-frame-parallel 1: Enables parallel frame processing to better utilize multi-core CPUs.