Configure VP9 Drop Frame Parameter in FFmpeg

This article explains how to configure and use the drop-frame parameter in FFmpeg when encoding video with the libvpx-vp9 encoder. You will learn the correct FFmpeg syntax, how the parameter functions to manage buffer levels, and the best practices for setting threshold values during real-time streaming or low-latency encoding.

Understanding the Drop-Frame Parameter

In the libvpx-vp9 encoder, the drop-frame parameter is controlled using the -drop-frame-threshold option. This setting is primarily used in real-time encoding and streaming scenarios (such as WebRTC) to prevent encoder lag and buffer underruns.

When network bandwidth drops or the CPU cannot encode fast enough to maintain the target bitrate, the encoder can drop frames to catch up. The -drop-frame-threshold parameter defines the buffer fullness percentage below which the encoder is allowed to drop a frame.

FFmpeg Syntax and Values

The parameter accepts an integer value from 0 to 100:

Basic Command Example

To set the drop-frame threshold in FFmpeg, use the -drop-frame-threshold flag:

ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 1M -drop-frame-threshold 25 output.webm

In this command, if the encoder’s buffer fullness drops below 25%, FFmpeg will drop frames to maintain the 1 Mbps bitrate target and keep the encoding pipeline running smoothly.

To make effective use of frame dropping, you should pair the threshold parameter with real-time encoding options. This includes setting the deadline to realtime and utilizing a high CPU usage preset.

Here is an optimized command for low-latency, real-time VP9 streaming with a 30% drop-frame threshold:

ffmpeg -i input.mp4 -c:v libvpx-vp9 -quality realtime -speed 5 -b:v 1.5M -drop-frame-threshold 30 output.webm