The Importance of the Video Buffer Verifier (VBV)
When setting up a video encoding profile, one of the parameters that need to be set is the Video Buffer Verifier (VBV). The VBV ensures that the encoded video stream can be correctly buffered and played back at the decoder device without overflowing or underflowing the buffer.
Constant Bitrate Encoding vs Variable Bitrate Encoding
There are two main modes of video encoding: constant bitrate (CBR) and variable bitrate (VBR). In CBR, the encoder tries to maintain a constant output bitrate throughout the video, regardless of the complexity or motion of the scene. This mode is suitable for applications that require a predictable and consistent bandwidth usage, such as live streaming or broadcasting.
In VBR, the encoder adjusts the output bitrate according to the complexity or motion of the scene. This mode allows for higher quality and lower file size, as the encoder can allocate more bits to complex or fast-moving scenes and less bits to simple or static scenes. However, this mode also introduces more variability and unpredictability in the output bitrate, which can cause problems for some applications or devices that have limited bandwidth or buffer capacity.
The Crucial Role of the VBV
The VBV is a theoretical model of a video decoder’s buffer that simulates how the encoded video stream is received and consumed by the decoder. The VBV has a certain size (bufsize) that represents the maximum amount of data that can be stored in the buffer at any given time. The VBV also has a certain input rate (maxrate) that represents the maximum bitrate that can enter the buffer without causing overflow. The VBV monitors the size and rate of the encoded video stream and ensures that it complies with these constraints.
The VBV prevents overflow by limiting the maximum bitrate of the encoded video stream to maxrate. If the encoder produces a higher bitrate than maxrate, the VBV will lower the quality or drop some frames to reduce the bitrate. The VBV prevents underflow by ensuring that there is always enough data in the buffer to feed the decoder. If the encoder produces a lower bitrate than maxrate, the VBV will increase the quality or insert some filler data to increase the bitrate.
The VBV is important because it ensures that the encoded video stream can be correctly buffered and played back at any decoder device that has a buffer size equal to or larger than bufsize and an input rate equal to or lower than maxrate. This means that if you encode your video with a certain VBV setting, you can guarantee that it will play smoothly on any device that meets or exceeds those requirements.
The Bucket and Faucet Analogy
The VBV model can be explained with a simple analogy involving a bucket and a faucet. Imagine that you have an empty bucket that you want to fill with water from a faucet. The bucket represents the video decoder’s buffer, the water represents the encoded video stream, and the faucet represents the encoder’s output.
The size of the bucket (buffer size) determines how much water it can hold at any given time.
The rate at which the faucet delivers water to the bucket determines how fast the bucket fills up or empties out. Similarly, the rate at which the encoder delivers data to the buffer determines how fast the buffer fills up or empties out. The rate at which data enters the buffer is called maxrate and it is measured in bits per second.
A VBV overflow occurs when the faucet rate (maxrate) is higher than the input rate of the decoder device, and the bucket (buffer) becomes full and cannot store any more water (data). This means that some water (data) will spill out of the bucket (buffer) and be lost. This can cause quality degradation or playback errors in the decoded video.
A VBV underflow occurs when the faucet rate (maxrate) is lower than the input rate of the decoder device, and the bucket (buffer) becomes empty and cannot feed any more water (data) to the decoder device. This means that there will be a gap or pause in the water flow (data stream) and the decoder device will have nothing to play. This can cause stuttering or freezing in the decoded video.
The VBV model tries to prevent overflows and underflows by adjusting the faucet rate (maxrate) according to the water level in the bucket (buffer). If the water level is too high, the faucet rate (maxrate) will be lowered to avoid overflowing. If the water level is too low, the faucet rate (maxrate) will be raised to avoid underflowing. The VBV model also tries to keep the water level as stable as possible by smoothing out any sudden changes in the faucet rate (maxrate).
We have prepared a little animation clip to visualize this analogy, check it out here!
Guidelines for Choosing VBV Size
When building adaptive bitrate encoding workflows using software like vCoder, you need to choose different VBV settings for different output resolutions and bitrates. The general principle is to choose a smaller bufsize and a lower maxrate for lower resolutions and bitrates, and a larger bufsize and a higher maxrate for higher resolutions and bitrates. This way, you can optimize your video quality for each target device and bandwidth scenario.
However, there is no definitive formula or rule for choosing VBV settings, as they depend on many factors such as your source content, your encoding parameters, your target devices and platforms, your delivery method and network conditions. Therefore, you need to experiment with different values and test your encoded videos on various devices and scenarios to find the optimal balance between quality, size and compatibility.
Here are some general guidelines that may help you get started:
- For CBR encoding, you can set bufsize equal to maxrate. This means that your buffer will always be full and your output bitrate will always be constant.
- For VBR encoding, you can set bufsize equal to 1-2 times maxrate. This means that your buffer will have some room for variability and your output bitrate will fluctuate within a certain range.
- For low resolutions (e.g., 360p or 480p), you can set maxrate between 500 kbps and 1 Mbps, depending on your desired quality and file size.
- For medium resolutions (e.g., 720p or 1080p), you can set maxrate between 2 Mbps and 5 Mbps, depending on your desired quality and file size.
- For high resolutions (e.g., 4K or 8K), you can set maxrate between 10 Mbps and 50 Mbps, depending on your desired quality and file size.