What is VBV (Video Buffering Verifier) in H.264?

25,366

Basically the VBV enables you to make sure the encoded stream doesn't overflow or underflow the decoder's buffer. If too much data comes in fast the buffer will overflow and you'll be forced to drop some of it. If data is coming in too slow the buffer will run out and the playback will stall.

It's a bit counter-intuitive but a VBV underflow signals an encoder rate buffer overflow (video bitrate larger than the input rate) while a VBV overflow signals an encoder rate buffer underflow (video bitrate lower than input the rate).

For ffmpeg the bufsize is the size of the buffer. minrate and maxrate are used in conjunction with bufsize to set the max and min bitrate change tolerance for VBR (variable bitrate).

minrate is typically used along with maxrate to achieve near-CBR (constant bitrate).

maxrate is not the peak bitrate, it's rather the maximum bitrate that can enter the buffer. If you have a large buffer, like in your second example, you can tolerate a higher bitrate for a greater amount of time until the buffer overflows. VBV makes sure your bitrate is lowered before that happens. That's why your stream can reach 800-900 kbps.

You can read more here: The relationship between --vbv-bufsize and --vbv-maxrate

Share:
25,366
Oleksandr
Author by

Oleksandr

Updated on August 05, 2020

Comments

  • Oleksandr
    Oleksandr almost 4 years

    I can't understand what is a VBV (Video Buffering Verifier) and what relations it have with a maxrate.
    When I use this command:

    ffmpeg -i input.mp4 -crf 21 -maxrate 750k -bufsize 750k -codec:v:0 libx264 -s 640x360 -r 30 output.mp4
    

    output.mp4 video have a bit rate about 730 kb/s
    But when I use this command (same command but with -bufsize 5000k):

    ffmpeg -i input.mp4 -crf 21 -maxrate 750k -bufsize 5000k -codec:v:0 libx264 -s 640x360 -r 30 output.mp4
    

    output.mp4 video have more bit rate than 750kb/s (about 800-900 kb/s).
    Why it happens? Why we need the the bufsize? What does the bufsize do?

  • vacing
    vacing over 3 years
    We use VBV as a hypothetical decoder with a constant input bitrate, but if encoder ouput bitrate decreases, how could decoder receive constant bitrate video and lead to buffer overflow?
  • aergistal
    aergistal over 3 years
    @vacing Based on my understanding the decoder will instantly remove data from the buffer to decode frames with a certain timing for display. Frame sizes are not constant even if the stream bitrate is (for CBR). If the frame data to be removed has a only a small size each time and the buffer keeps filling up at the same constant rate then it would eventually overflow. Larger frame sizes means a larger chunk of the buffer is used at once. Hence the need for padding which is simply discarded in the first case.