[x264-devel] Re: Multipass encoding with CBR

Loren Merritt lorenm at u.washington.edu
Tue Feb 21 18:01:41 CET 2006


On Tue, 21 Feb 2006, Josef Zlomek wrote:

>>> I want to create a h264 stream for streaming by multipass encoding.
>>> Because the video will be streamed, the bitrate can't be more than
>>> few percent greater than requested value.
>>>
>>> I am using 3-pass encoding (1st pass creates log, 2nd pass reads and write it
>>> and 3rd pass reads it).
>>> Although I have set following parameters controlling bitrate, the output
>>> bitrate is much higher in some small parts of the stream than the requested
>>> bitrate (wanted 1500, reached 2650 on one 1 second interval).
>>>
>>> The params (FPS is 25):
>>>   params->rc.b_cbr = TRUE;
>>>   params->rc.i_bitrate = 1500;
>>>   params->rc.i_vbv_max_bitrate = 1500;
>>>   params->rc.i_vbv_buffer_size = 1500;
>>>   params->rc.f_rate_tolerance = 0.05;
>>>
>>>
>>> Is it possible to make x264 create a h264 stream that uses multipass
>>> encoding and that does not overflow the wanted bitrate (by more than
>>> few percent) ?
>>
>> The instantaneous bitrate may very well be much larger than the average for
>> a short period, provided the vbv buffer doesn't underflow.  The numbers you
>> mention are well within the limits.  If you need less variation, try
>> reducing the vbv_buffer_size.
>
> If I understand the meaning of vbv_buffer_size correctly, the vbv_buffer_size
> is just for 1 second in 1500 kbit/s. I have of course tried to set it to
> smallest possible value (10 * bitrate / FPS) but that did not help.

Consider:
at time T, the vbv buffer is full (1500 kbit).
at time T+1, the vbv buffer is empty (0 kbit).
in that 1 second interval, the codec has used 1500 kbit of vbv_maxrate + 
1500 kbit taken from the buffer, for a total of 3000 kbit/sec.

Consider: (assuming 30fps)
at time T, the vbv buffer is full (1500 kbit).
at time T+1/30, the vbv buffer is empty (0 kbit).
in that 1 frame interval, the codec has used 50 kbit of vbv_maxrate +
1500 kbit taken from the buffer, for a total of 46500 kbit/sec.

For most purposes, including streaming, this behaviour is what you want. 
vbv_maxrate = your bandwidth, vbv_buffer_size = the buffer on each client.
Of course if you don't control the clients you don't know what buffer size 
they use, but you just have to assume something.

--Loren Merritt

-- 
This is the x264-devel mailing-list
To unsubscribe, go to: http://developers.videolan.org/lists.html



More information about the x264-devel mailing list