[Ffmpeg-devel] How to get the current bitrate?

Måns Rullgård mru
Fri Jul 29 10:28:27 CEST 2005


Luca Abeni said:
> Hi M?ns,
>
> On Thu, 2005-07-28 at 16:42 +0100, M?ns Rullg?rd wrote:
>> 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
> 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





More information about the ffmpeg-devel mailing list