<div dir="ltr">Wow. This has been helpful to me to really understand what is going on. I'd suspected the 'audio_bitrate' was just for show. So, to again make sure I'm understanding, I assume I can get the actual (average) transfer rate of data to a particular user for a particular session by taking the access.log BYTES = total bytes of data sent (other than headers) and dividing by TIME = seconds that the connection lasted. This varies depending on many of the factors you mention, particularly the amount of information in the signal. And for those reasons, it can be misleading if measured in a very short window.<br><br>I just looked at one of my logs and saw a huge spread for the 1 second duration... Don't know how to post pictures though...</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 21, 2021 at 5:40 PM Philipp Schafft <<a href="mailto:phschafft@de.loewenfelsen.net">phschafft@de.loewenfelsen.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Good evening,<br>
<br>
On Tue, 2021-12-21 at 14:33 -0800, Milton Huang wrote:<br>
> Philipp,<br>
> <br>
> Thank you for your detailed and enlightening answers.<br>
<br>
you're very welcome.<br>
<br>
<br>
> Just to make sure I understand how 'bitrate' works here. Assuming we<br>
> are just working with audio to keep it simple. Let's also ignore<br>
> metadata,<br>
<br>
Ok. Just a word of warning to the general audience: This is a very<br>
limited view on the problem and might not apply to real deployments or<br>
fail to be valid at random.<br>
<br>
<br>
> as my use case is that I am generating an electronic music stream<br>
> from ffmpeg and broadcasting that using Icecast, so I can<br>
> control/calculate that.<br>
<br>
<br>
> I presume that if we specify `audio_bitrate` for a particular mount,<br>
> that is a 'target' rate that Icecast will attempt to transmit audio<br>
> data at.<br>
<br>
No, see below.<br>
<br>
<br>
> You mentioned that the actual rate can vary. Am I right to assume<br>
> this is because it is dependent on the source (ffmpeg) rate for<br>
> filling the 'queue', which in turn is used to fill each buffer of<br>
> each connected client?<br>
<br>
No. The bitrate depends on the codec, the encoder parameters, and the<br>
audio. E.g. bitrate can drop to virtually (or actually) zero for<br>
moments of silence as there just is no entropy to encode.<br>
<br>
<br>
> If so, wouldn't it generally be best for the mount `audio_bitrate` to<br>
> be set to the same bitrate that the source is generating/sending at?<br>
<br>
It is generally recommended to set as few options on the Icecast side<br>
as possible. Also see below.<br>
<br>
<br>
> I have the option of generating and compressing my mp3 stream at<br>
> either a fixed bitrate or to use a LAME VBR setting, and from what I<br>
> am now understanding it seems that using a fixed bitrate could be<br>
> better to avoid leading or lagging the queue buffer.<br>
<br>
Generally encoding with fixed bitrate tends to harm the quality of the<br>
signal. How much error is introduced depends again on the codec, the<br>
encoder parameters, and the signal.<br>
<br>
A quality based encoding is normally best as this results in the<br>
encoder trying to keep the signal on the same quality level. Bitrate is<br>
approximately a function of entropy*quality. The more constant you try<br>
to keep it the more quality of the signal will change with changes in<br>
entropy. Change of the amount of entropy per time in a signal is a very<br>
common event. E.g. you have a radical change between voice and music,<br>
but also between different kinds of music/compositions (fade-<br>
in/intro/fade-out/outro, instrumental-only, instruments+voice,<br>
simpler/more complex parts of a track, ...).<br>
<br>
With flexible transports such as IP based networks I see little use of<br>
constant or semi-constant bitrate modes. The main applications that<br>
comes to mind are fixed bitrate transports channels such as radio<br>
channels (e.g. GSM slots).<br>
<br>
<br>
Back to Icecast:<br>
Ignoring bursts and format specific headers, as well as syncing for a<br>
moment (which is exactly what happens once a listener is fully<br>
connected) Icecast sends data out as soon as it receives it.<br>
Icecast does not implement any bitrate control. There are no delays<br>
(which would be the only way for Icecast to do this, as it can not send<br>
data before it received it). All bitrate related options are cosmetic<br>
only (e.g. for user friendly display in directory services).<br>
<br>
Please note that this holds true for all official Icecast versions.<br>
Forks or custom versions may differ here.<br>
<br>
<br>
> Thanks for educating all of us!<br>
<br>
Again, just happy if this helps anyone. :)<br>
<br>
With best regards,<br>
<br>
<br>
> On Thu, Dec 16, 2021 at 9:28 AM Philipp Schafft <<br>
> <a href="mailto:phschafft@de.loewenfelsen.net" target="_blank">phschafft@de.loewenfelsen.net</a>> wrote:<br>
> > Good afternoon,<br>
> > <br>
> > On Wed, 2021-12-15 at 13:40 -0800, Milton Huang wrote:<br>
> > > Hi all,<br>
> > > I just want to make sure I understand what the `queue-size`<br>
> > setting<br>
> > > does in icecast.xml. My understanding is that for each<br>
> > mountpoint, a<br>
> > > buffer of that size (default 0.5 MB) is maintained for serving to<br>
> > all<br>
> > > connected clients. Each client is fed from that buffer, and if<br>
> > their<br>
> > > connection lags so they can't keep up with the queue contents,<br>
> > they<br>
> > > get kicked with a 'client has fallen too far behind' message in<br>
> > the<br>
> > > log.<br>
> > <br>
> > That is basically right. However I would like to add that the<br>
> > default<br>
> > queue size is fine for audio streaming and may need to be adjusted<br>
> > for<br>
> > video streaming. If you see a lot of said messages in logs and you<br>
> > are<br>
> > using the default the problem is likely not the value but something<br>
> > else (e.g. the network being saturated). Or: If you think changing<br>
> > this<br>
> > value will help you, rethink as it likely is not.<br>
> > <br>
> > <br>
> > > I assume if we divide the queue-size by the mount's bitrate we<br>
> > would<br>
> > > get the duration of how slow a connection can be which is a limit<br>
> > on<br>
> > > possible latency of clients.<br>
> > <br>
> > This is wrong. Sadly a common myth.<br>
> > <br>
> > The 'bitrate' of a stream is generally 0) not constant, 1) only<br>
> > applies<br>
> > to the audio data, not the stream.<br>
> > <br>
> > as for 0) it can easily jump between 0.1% and 200% of the nominal<br>
> > value<br>
> > for many codecs.<br>
> > <br>
> > as for 1) the stream consists of more than just the audio data.<br>
> > E.g. it<br>
> > contains of framing, setup headers, and metadata. Metadata can<br>
> > easily<br>
> > account for the same amount of data than several seconds, sometimes<br>
> > minutes of audio data.<br>
> > <br>
> > Keeping this in mind a useful value of a bitrate for a stream needs<br>
> > to<br>
> > be calculated over at least an entire segment (track/song/title)<br>
> > including all of it's metadata and format overhead. Also as<br>
> > metadata<br>
> > may be very different for different tracks the value may still be<br>
> > 'jumping around' a lot.<br>
> > <br>
> > <br>
> > All of that said it is surely possible to create a stream with a<br>
> > more<br>
> > constant or foreseeable bitrate. But this is NOT the general case.<br>
> > <br>
> > <br>
> > So you calculation above may at best give a very rough estimation.<br>
> > <br>
> > <br>
> > > On the client side, there is an input buffer to help with poor<br>
> > > connections.<br>
> > <br>
> > The input buffer needs to be there independent on the connection<br>
> > quality, but what a good size for it is, depends mostly on the<br>
> > quality<br>
> > of the connection.<br>
> > <br>
> > <br>
> > > This will be filled at the initial connection with a burst-on-<br>
> > connect <br>
> > > if enabled in the icecast settings. There will be an initial<br>
> > delay in<br>
> > > play while the buffer is filled, which the burst should help<br>
> > reduce. <br>
> > <br>
> > This is perfectly correct.<br>
> > <br>
> > <br>
> > > Obviously, the burst-size has to be smaller than the queue size,<br>
> > or<br>
> > > you will defeat the purpose of the burst.<br>
> > <br>
> > This is not really true. The burst-size is a request to Icecast.<br>
> > However Icecast will not send exactly this amount of bytes as it<br>
> > needs<br>
> > to adhere external constrains. One of them is how much data it has.<br>
> > So<br>
> > setting this to an overly large value will just let Icecast send as<br>
> > much as possible.<br>
> > <br>
> > Other such constrains are format specific aspects such as setup<br>
> > headers<br>
> > and metadata, but also framing/syncing.<br>
> > <br>
> > <br>
> > As a small addition:<br>
> > Similar holds true for the queue-size. E.g. if Icecast has not yet<br>
> > got<br>
> > a full queue-size of data from a source the buffer is smaller.<br>
> > Depending on how the data is chunked (this depends on the version<br>
> > of<br>
> > Icecast, the format, the operating systems, the sources, the<br>
> > network,<br>
> > ...) the size might be slightly smaller or larger.<br>
> > <br>
> > Generally those values should be considered as requests and Icecast<br>
> > tries to work with them as good as possible.<br>
> > <br>
> > <br>
> > > Do I have this all right? Any comments or clarifications?<br>
> > <br>
> > Please see my comments inline. :)<br>
<br>
<br>
-- <br>
Philipp Schafft (CEO/Geschäftsführer) <br>
Telephon: +49.3535 490 17 92<br>
<br>
Löwenfelsen UG (haftungsbeschränkt) Registration number:<br>
Bickinger Straße 21 HRB 12308 CB<br>
04916 Herzberg (Elster) VATIN/USt-ID:<br>
Germany DE305133015<br>
_______________________________________________<br>
Icecast mailing list<br>
<a href="mailto:Icecast@xiph.org" target="_blank">Icecast@xiph.org</a><br>
<a href="http://lists.xiph.org/mailman/listinfo/icecast" rel="noreferrer" target="_blank">http://lists.xiph.org/mailman/listinfo/icecast</a><br>
</blockquote></div>