Introduction
Limiting the output bit rate to a certain range makes sense if you are live streaming or need to be constrained to a certain specification (such as Blu-ray encoding), where the decoder might not be able to handle large bitrate spikes.
There are several options you can use to steer the encoder's bitrate:
-
-b:v
: specifies the target (average) bit rate for the encoder to use
-
-minrate
specifies a minimum tolerance to be used
-
-maxrate
specifies a maximum tolerance. this is only used in conjunction with
bufsize
-
-bufsize
specifies the decoder buffer size, which determines the variability of the output bitrate
Note:
Constraining the bitrate might result in low quality output if the video is hard to encode. In most cases (such as storing a file for archival), letting the encoder choose the proper bitrate is the constant quality or CRF-based encoding.
In this case, you want to have a live stream with more/less constant bit rate (using the option
), to be able to control the bandwidth used.
We will instruct the libx264 encoder to simulate a stream transmission with a virtual buffer (just like the real buffer at the decoding side). The technique will constrain the bit rate in order not to exceed a certain threshold value which would take more time to transmit and would cause the decoding buffer to underflow waiting for the new data to arrive.
The typical example would be something like this: