Configure libvpx Speed Parameter in FFmpeg

This article explains how to configure the speed and quality trade-offs in FFmpeg when encoding video with the libvpx (VP8) and libvpx-vp9 (VP9) encoders. You will learn how to use the key parameters -deadline and -cpu-used to balance encoding times and output file quality, along with practical command-line examples.


Understanding the Speed Parameters

To control encoding speed in the libvpx library, FFmpeg relies on two primary parameters that work together: -deadline (also referred to as -speed in newer FFmpeg versions) and -cpu-used.

1. The -deadline / -speed Parameter

This parameter sets the overarching quality-to-speed guideline. It accepts three main string arguments:

2. The -cpu-used Parameter

Once the deadline is set, -cpu-used fine-tunes the speed within that mode. The behavior of this parameter depends on whether you are using VP8 (libvpx) or VP9 (libvpx-vp9).

For VP9 Encoding (libvpx-vp9):

For VP8 Encoding (libvpx):


Command Examples

This command uses the standard good deadline with a -cpu-used value of 2, which provides excellent visual quality without taking an unreasonable amount of time.

ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -deadline good -cpu-used 2 -c:a libopus output.webm

Example 2: Fast / Real-time VP9 Encoding

If you need to process a video quickly or are setting up a live stream, change the deadline to realtime and increase the -cpu-used value.

ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -deadline realtime -cpu-used 5 -c:a libopus output.webm

Example 3: Standard VP8 Encoding

For legacy compatibility using the VP8 codec, use the following configuration:

ffmpeg -i input.mp4 -c:v libvpx -b:v 2M -metadata:s:v:0 alpha_mode=1 -cpu-used 0 -c:a libvorbis output.webm