How to get the current bitrate?
Hi all, I need to stream some compressed audio/video over a network with limited bandwidth (there actually is a bandwidth shaper), so I am trying to understand how the rate control in libavcodec works... If I set rc_max_rate and rc_buffer_size, I see that the encoded stream "kind of respects" the maximum rate, but there sometimes are spikes over such limit (I am using MPEG4 video, single-pass encoding). I am trying to understand such spikes and to do this I am currently using tcpstat to monitor the actual bitrate streamed to the network. But I'd like to read the "current" bitrate (not the average one) directly from the codec... To respect the "maximum rate" constraint libavcodec needs some kind of estimation of the current bitrate, right? Is it possible to read it in some way? Also, does anyone know if it's possible to make the rate control more precise/effective by playing with the codec's parameters? (I see rc_buffer_aggressivity, rc_eq, bit_rate_tolerance, ... But I do not know how to use them). Thanks, Luca -- _____________________________________________________________________________ Copy this in your signature, if you think it is important: N O W A R ! ! !
Luca Abeni said:
Hi all,
I need to stream some compressed audio/video over a network with limited bandwidth (there actually is a bandwidth shaper), so I am trying to understand how the rate control in libavcodec works...
If I set rc_max_rate and rc_buffer_size, I see that the encoded stream "kind of respects" the maximum rate, but there sometimes are spikes over such limit (I am using MPEG4 video, single-pass encoding).
I am trying to understand such spikes and to do this I am currently using tcpstat to monitor the actual bitrate streamed to the network. But I'd like to read the "current" bitrate (not the average one) directly from the codec... To respect the "maximum rate" constraint libavcodec needs some kind of estimation of the current bitrate, right? Is it possible to read it in some way?
You should be streaming at a constant rate, no matter what the instantaneous rate of the video is. That's what the RC buffer is all about. -- M?ns Rullg?rd mru at inprovide.com
Luca Abeni said: [...]
I am trying to understand such spikes and to do this I am currently using tcpstat to monitor the actual bitrate streamed to the network. But I'd like to read the "current" bitrate (not the average one) directly from the codec... To respect the "maximum rate" constraint libavcodec needs some kind of estimation of the current bitrate, right? Is it possible to read it in some way?
You should be streaming at a constant rate, no matter what the instantaneous rate of the video is. That's what the RC buffer is all about. Yes, I know the theory... :) The problem is that the istantaneous rate of the encoded video becomes sometimes too high, and if I stream at a constant rate some packets will arrive "too late" and the receiver will drop the frame. (in other words, if I stream at the "expected bitrate", sometime I have to buffer more
Hi M?ns, On Thu, 2005-07-28 at 16:42 +0100, M?ns Rullg?rd wrote: than rc_buffer_size... Am I misunderstanding the RC buffer?) Thanks, Luca -- _____________________________________________________________________________ Copy this in your signature, if you think it is important: N O W A R ! ! !
Luca Abeni said:
Hi M?ns,
Luca Abeni said: [...]
I am trying to understand such spikes and to do this I am currently using tcpstat to monitor the actual bitrate streamed to the network. But I'd like to read the "current" bitrate (not the average one) directly from the codec... To respect the "maximum rate" constraint libavcodec needs some kind of estimation of the current bitrate, right? Is it possible to read it in some way?
You should be streaming at a constant rate, no matter what the instantaneous rate of the video is. That's what the RC buffer is all about. Yes, I know the theory... :) The problem is that the istantaneous rate of the encoded video becomes sometimes too high, and if I stream at a constant rate some packets will arrive "too late" and the receiver will drop the frame. (in other words, if I stream at the "expected bitrate", sometime I have to buffer more
On Thu, 2005-07-28 at 16:42 +0100, M?ns Rullg?rd wrote: than rc_buffer_size... Am I misunderstanding the RC buffer?)
Do you get messages about RC buffer underflow? If not, you should be fine. You just need to make sure the receiver pre-buffers the right amount. The amount to buffer before starting playback is the value of rc_initial_buffer_occupancy at the encoder. Of course, if the player has a lot of memory, you can always buffer more. -- M?ns Rullg?rd mru at inprovide.com
Hi! In case the bitrate with the specified rc_buffer_size exceeds rc_max_rate, you can specify vqcomp=0.1 (or other low value), and switch or comment out the ratetol part (or set a very high value, i.e. on the orders of the size of the whole stream). bye Denes cs?t?rt?k 28 j?lius 2005 16.27-kor Luca Abeni ezeket a bolcs gondolatokat fogalmazta meg:
Also, does anyone know if it's possible to make the rate control more precise/effective by playing with the codec's parameters? (I see rc_buffer_aggressivity, rc_eq, bit_rate_tolerance, ... But I do not know how to use them).
Thanks, Luca
-- - Use the Source Luke ! -
On Thu, 2005-07-28 at 18:21 +0200, Balatoni Denes wrote:
Hi!
In case the bitrate with the specified rc_buffer_size exceeds rc_max_rate, you can specify vqcomp=0.1 (or other low value), and switch or comment out the ratetol part (or set a very high value, i.e. on the orders of the size of the whole stream). Thanks, I'll have a look at these setting, and I'll do some experiments to test their effects.
Thanks, Luca -- _____________________________________________________________________________ Copy this in your signature, if you think it is important: N O W A R ! ! !
participants (3)
-
dbalatoni@programozo.hu -
lucabe72@email.it -
mru@inprovide.com