[x264-devel] Re: Multipass encoding with CBR

Josef Zlomek josef.zlomek at xeris.cz
Wed Feb 22 09:32:20 CET 2006


> >>>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;
> 
> 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.

Thank you for detailed explanation.

However, it seems that x264 does not use VBV during 2nd pass (and later passes)
when using multipass encoding.
The code in rate_estimate_qscale() for b_2pass = TRUE looks like it is doing ABR
over the whole video.

I have also tried to set the VBV buffer size to the minimal allowed size
(10 * bitrate / fps), and even lower (1 * bitrate / fps) after removing the min
size check from code, but that did not help.
The bitrate was too high for quite a long time (more than 5 seconds) in some
parts of the video. This does not look like it was flushing the small buffer.

--
Josef Zlomek

-- 
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