Author Topic: BASS_Encode_ServerInit delay on listener  (Read 515 times)

axisdj

  • Posts: 46
BASS_Encode_ServerInit delay on listener
« on: 3 Feb '19 - 19:09 »
Hello,

Looking for some guidance on what would cause about a seven second delay when a listener opening the listen URL and it starting to play.
What are the factors that change that delay.
I have tried setting buffer and burst to 0 no change
I have tried BASS_SetConfig(BASS_CONFIG_ENCODE_QUEUE, 1000)
I have tried BASS_SetConfig(BASS_CONFIG_ENCODE_CAST_TIMEOUT, 1)
I have tried all bitrates and the delay changes but at 128k its around 7 second
my upload and download speeds are 100mb per second

Any suggestions?

Code: [Select]
encoder = BASS_Encode_Start(record1, com, (BASS_ENCODE_NOHEAD), 0, 0)
argSend = MakeLong(BASS_ENCODE_SERVER_META, 4)
theReturn = BASS_Encode_ServerInit(encoder, thePort, 40000, 40000, argSend, AddressOf ENCODECLIENTPROC, 0)

Ian @ un4seen

  • Administrator
  • Posts: 21949
Re: BASS_Encode_ServerInit delay on listener
« Reply #1 on: 4 Feb '19 - 15:31 »
Besides the network latency, there are several buffers that can be contributing to the delay: the recording buffer/period, the encoder's buffer(s), the server's buffer, the client's download buffer, the playback buffer.

The recording buffering is controlled by the "period" setting in the BASS_RecordStart call (default 100ms). You may not have much control over the encoder's buffering but check if it has a "flush output" option, and enable it if so. You can avoid encoder output buffering by using the BASSenc add-ons (eg. BASSenc_MP3) instead of an external encoder. The server's buffering is controlled by the BASS_Encode_ServerInit "buffer" and "burst" parameters. The client's download buffering is controlled by its BASS_CONFIG_NET_BUFFER and BASS_CONFIG_NET_PREBUF settings. The playback buffering is controlled by the BASS_CONFIG_BUFFER setting (and BASS_ATTRIB_BUFFER). Please see the documentation for details on the mentioned functions/options.

I would suggest starting with disabling any encoder output buffering and setting BASS_Encode_ServerInit "burst" to 0 on the server side, and setting BASS_CONFIG_NET_PREBUF to 0 on the client side.

axisdj

  • Posts: 46
Re: BASS_Encode_ServerInit delay on listener
« Reply #2 on: 7 Feb '19 - 02:10 »
Thanks Ian,

I tried what you suggested with no change.

Here is the strange part, I set the buffer and burst to 130000 + and now it starts instantly using an HTML5 audio player.

If I lower those values below that there is a 5-7 delay before the music starts..

Any thoughts?

Ian @ un4seen

  • Administrator
  • Posts: 21949
Re: BASS_Encode_ServerInit delay on listener
« Reply #3 on: 7 Feb '19 - 14:01 »
Ah, you're just talking about a delay in playback starting, rather than the delay between the live sound on the server side and when it's heard on the client side. In this case, it is probably just that the client is pre-buffering an amount of data before starting playback. The server sending a burst of buffered data will allow the client's pre-buffering to be completed more quickly.

axisdj

  • Posts: 46
Re: BASS_Encode_ServerInit delay on listener
« Reply #4 on: 8 Feb '19 - 02:00 »
Thank you Ian!