ScannerCast feed latency question

Status
Not open for further replies.

scanpprcn

Member
Premium Subscriber
Joined
Sep 6, 2009
Messages
76
Location
Colorado Springs, CO
I use ScannerCast on two Pro-197s. Typically when I am on the same network (subnet) as the machines hosting the audio stream, the connected clients receive the stream with the audio delayed about a five seconds. Is this latency due to the LAME encoding/decoding? Are there any ideas on how to reduce the delay time?

Thank you,

Mike B.

P.S. To avoid a possible misunderstandings from the general audience, "LAME" is the MP3 encoding scheme not a personal jab at the author ;-) The program is a superior product!
 

PeterGV

K1PGV
Joined
Jul 10, 2006
Messages
754
Location
Mont Vernon, NH
Typically when I am on the same network (subnet) as the machines hosting the audio stream, the connected clients receive the stream with the audio delayed about a five seconds. Is this latency due to the LAME encoding/decoding? Are there any ideas on how to reduce the delay time?

The delay time is built-into ScannerCast. It's a deliberate part of the design that contributes to ScannerCast's smooth operation (ScannerCast uses a circular buffer for data between the scanner and the clients -- if anybody cares for the technical reason why this is a good thing, just ask and I'll be happy to explain in a separate post).

When I wrote ScannerCast, I didn't imagine anybody would care about even 10 or 20 seconds of audio delay. Since then, one or two people have asked about reducing the latency... If the latency is a problem, I'd like to understand why. Because it COULD be (optionally) eliminated or reduced drastically, though it would take some re-work.

P.S. To avoid a possible misunderstandings from the general audience, "LAME" is the MP3 encoding scheme not a personal jab at the author ;-) The program is a superior product!

LOL... that was nice of you to add.

Oh, BTW... there IS some built-in latency through LAME that (given the buffering in and out) can amount to as much as a couple of seconds. That's probably NOT the majority of the latency that you're experiencing in ScannerCast, however.

Peter
K1PGV
 

gmclam

Member
Premium Subscriber
Joined
Sep 15, 2006
Messages
6,341
Location
Fair Oaks, CA
The delay time is built-into ScannerCast. It's a deliberate part of the design that contributes to ScannerCast's smooth operation (ScannerCast uses a circular buffer for data between the scanner and the clients -- if anybody cares for the technical reason why this is a good thing, just ask and I'll be happy to explain in a separate post).
I'd love to hear it. I imagine it is done so that there are no buffer overflows or underflows and there is always another packet to send. Or on the receiving side, there is always something to output, even if packets have not been received in a timely manner.

When I wrote ScannerCast, I didn't imagine anybody would care about even 10 or 20 seconds of audio delay. Since then, one or two people have asked about reducing the latency... If the latency is a problem, I'd like to understand why. Because it COULD be (optionally) eliminated or reduced drastically, though it would take some re-work.
I have two separate issues with this. The first issue has to do with streaming at least two scanners that functionally receive the same audio. One might be receiving from a TRS (800 MHz) and the 2nd from VHF; or both might be receiving VHF but separate frequencies that are the same audio. If I listen to both scanners directly (no computers involved), the audio is identically enough in time with itself to sound good. However, when I listen to both scanners streamed (separate streams and on a local net), the audio delay (or "skew") between the two is so annoying that I have to stop one stream to hear what is being said.

The second issue simply has to do with the delay itself. I often listen to many many scanners simultaneously in addition to several streams. While the intent is for the scanners to be receiving "local" stuff, and the streams to be receiving from afar, a local scanner will often stop on a channel from afar (I have great reception here). So I'll hear the audio from the scanner, then several seconds later hear it via the stream. When the stream is over a VPN it can still be more than 30 seconds later (typical for me is about 45 seconds). Waaay too much.

Thanks.
 

SRSP2282

Member
Premium Subscriber
Joined
Nov 29, 2008
Messages
144
Location
Alachua County, FL
When I wrote ScannerCast, I didn't imagine anybody would care about even 10 or 20 seconds of audio delay. Since then, one or two people have asked about reducing the latency... If the latency is a problem, I'd like to understand why. Because it COULD be (optionally) eliminated or reduced drastically, though it would take some re-work.

An option to reduce or better yet eliminate latency would be great.

I like to to pipe my scanner audio to different computers and devices. Since the system I monitor is a P25 system I also run unitrunker 24/7 in addition to ID Tracker III. I played around with ScannerCast but abandoned it because the latency meant that my unitrunker/control display (which I control remotely with a VNC connection) was not synced with my audio. Kinda defeated the purpose...

In the meantime for those interested, I ended up using skype (It has about a 0.5 to 1.0 sec latency) with two accounts. The first account is dedicated for the broadcasting task and runs all the time on my computer which is connected to the scanner. It is configured to automatically accept incoming calls from my regular account.
 

PeterGV

K1PGV
Joined
Jul 10, 2006
Messages
754
Location
Mont Vernon, NH
I'd love to hear it. I imagine it is done so that there are no buffer overflows or underflows and there is always another packet to send. Or on the receiving side, there is always something to output, even if packets have not been received in a timely manner.

Yes, exactly. The circular buffer serves a number of different purposes.

One issue is that we have a constant input stream, which will generate source data at a steady rate, irrespective of what's happening on the computer that's running ScannerCast. We don't want to lose any of that input, even when the computer gets busy.

So, ScannerCast retrieves small blocks of digitized audio data and combines them into larger blocks. These blocks are placed in a ring-buffer that holds about 10 seconds worth of data (depending on the audio bandwidth). The idea here is to create a reservoir of data for clients (which we'll discuss next). This reservoir allows disruptions to occur in ScannerCast's audio retrieval subsystem, without impacting outgoing audio to the clients.

ScannerCast Std Edition supports multiple client connections: A (practically) unlimited number of directly-connect clients plus up to one "push" client (the optional outgoing connection to an Icecast server such as RR). These clients all connect and disconnect at will.

So, different clients connect at different times and experience different latencies. But we have a constant source-data rate. The solution is to use some sort of buffering between the source and the sync to "smooth out" the transitions.

Of course, network connections between clients and servers are subject to all SORTS of disruptions in timing. Packets sent from ScannerCast can arrive at a client at different rates, with delays, and even out of order (this is just TCP/IP we're talking about here). We don't want these inevitable network delays/glitches to cause break-ups in the audio stream at the client

To help eliminate audio playback glitches, many playback (direct-connect) clients support "pre-load" buffering -- that is, accumulating some audio data locally (at the client) before playback. On connection, these clients attempt to retrieve audio data from the server as quickly as possible until their "pre-load" buffer size is reached. To facilitate this preload, ScannerCast uses its internal circular buffer. Thus, when a client connects ScannerCast quickly provides it with blocks of audio data to fulfill the pre-load requirement. This usually gets the user listening faster.

That's just a really quick overview. Hope it didn't cause you to fall asleep :)

I have two separate issues with this. The first issue has to do with streaming at least two scanners that functionally receive the same audio. One might be receiving from a TRS (800 MHz) and the 2nd from VHF; or both might be receiving VHF but separate frequencies that are the same audio. If I listen to both scanners directly (no computers involved), the audio is identically enough in time with itself to sound good.

Wow. I'm jealous. You're listening to a GREAT system. On a local TRS/VHF system near me, operating exactly as you described, the latency between the TRS transmission and the VHF "simulcast" (NOT!) transmission is at least 1 and probably closer to 2 seconds. Very annoying.

Having expressed my jealousy, I DO see your point.

... So I'll hear the audio from the scanner, then several seconds later hear it via the stream. When the stream is over a VPN it can still be more than 30 seconds later (typical for me is about 45 seconds).

Yeah, I understand that point, too.

Just to be clear: We're talking about a DIRECT connection to ScannerCast, right? Not via RR?

I need to think some more about a low-latency or lower-latency mode. If I were to spin-up a special test build of ScannerCast with a low-latency feature, would you be willing to try it out and comment??

Peter
K1PGV
 

N2JDS

Member
Joined
Dec 20, 2007
Messages
378
Location
St. Peters, Mo
I'm seeing not more than 1 second delay. My only thing I see delayed is the ID tag lags a few seconds and gets longer with time . Are they connected? If I stop sending tags, and restart, that fixes it for a few days.
 

gmclam

Member
Premium Subscriber
Joined
Sep 15, 2006
Messages
6,341
Location
Fair Oaks, CA
ScannerCast

Wow. I'm jealous. You're listening to a GREAT system. On a local TRS/VHF system near me, operating exactly as you described, the latency between the TRS transmission and the VHF "simulcast" (NOT!) transmission is at least 1 and probably closer to 2 seconds. Very annoying.
There are several different instances around me where one signal is VHF and the other is trunked and the difference in time between the two signals is small enough that it only sounds like an echo, or nearly simultaneous when listened to solely with radios. But there are also cases near me where the same audio ends up on two separate (VHF) conventional frequencies as well (not trunked at all).

Just to be clear: We're talking about a DIRECT connection to ScannerCast, right? Not via RR?
Yes. I have been privately streaming audio since about the first of this year. Some streams are remote from me and some are local. So I do end up hearing some over a LAN and some over a WAN. Ironically, just yesterday I started streaming to RR.

I need to think some more about a low-latency or lower-latency mode. If I were to spin-up a special test build of ScannerCast with a low-latency feature, would you be willing to try it out and comment??
I think there are a lot of us here that would be willing to do so, me included. Thanks.
 

PeterGV

K1PGV
Joined
Jul 10, 2006
Messages
754
Location
Mont Vernon, NH
Thanks all: When I get some time, I'll look at implementing a "low latency" option for you (plural) to test. I'll appreciate whatever feedback you can provide. I know how to DO it, I just need to write it so that it works, you know :)

@mo1dmat: Hmmm... What you're describing (low latency audio, but tags that get out of sync) is a VERY odd circumstance. One of the key design points for ScannerCast was a (attempt to) sync the audio and tags as closely as possible. For a long, boring, list of reasons maintaining tag sync is rather challenging -- and absolute tag sync via silence detecting is something I'll be looking at for ScannerCast V2.0 -- but the sync between that tags and the audio shouldn't "get longer with time", that's definitely a bad thing and it's a bug.

Do you have anything else running on your machine? I *do* know that ScannerCast will fall behind if the machine gets busy...

Peter
K1PGV
 

dannas

Member
Joined
Mar 30, 2010
Messages
5
Location
Pleasant Garden, NC
Our volunteers are in need of a real time solution to hear the
scanners and I want to setup a server they can directly connect to for
real time instead of the delayed feeds they receive from radio
reference.

I set your software up on the LAN; however, I am receiving quite a bit
of delay even locally. I assume this is related to
buffering/trans-coding.

With out starting at square one and putting together a SIP based
Asterisk solution, are there any options to completely remove the
delay from your application by changing the buffering/transcoding?

The program is fantastic and very easy to use; however, we need
something to fill our real time audio needs.

Thank you for your time.
 
Status
Not open for further replies.
Top