Page 1 of 1

I get a 20 sec lag on an rtsp stream from aircam dome

Posted: Wed Jan 23, 2013 7:20 pm
by marcmerlin
I have ZM with 5 cameras, 4 are mjpeg in 640x320 (wansview and foscam). I get lag of maybe 1-2 seconds in live view at most.

Then, I have a single 720p camera, an aircam dome, and get its video like so (from the source tab):
rtsp://aircam1:554/live/ch00_0
24 bit colour
1280
720
do not preverve aspect ratio
orientation: normal

ZM works ok with it, well kind of, there is this bug: http://www.zoneminder.com/forums/viewto ... 67&p=78931
but overall video works.

But, when I look in live view, I get a 1-2sec delay at most, so the 20sec delay isn't coming from the camera.
For my own sanity, I tried using the camera at 640x368 instead of 1280x720, and it made no difference in the delay, so the problem looks like it's not linked the resolution.

I see this in my logs in case it helps:
Jan 23 11:17:17 gargamel zms[27657]: WAR [Unable to store frame as shared memory invalid]
Jan 23 11:17:17 gargamel zmc_m2[27947]: ERR [Got unexpected memory map file size 138241272, expected 35329272]
Jan 23 11:17:18 gargamel zmc_m2[27947]: INF [Starting Capture]
Jan 23 11:17:18 gargamel zmc_m2[27947]: INF [Priming capture from rtsp://aircam1:554/live/ch01_0]
Jan 23 11:17:18 gargamel zms[27657]: WAR [Unable to store frame as timestamp invalid]
Jan 23 11:17:18 gargamel zma_m2[25156]: INF [Got signal 1 (Hangup), reloading]

I've already raised my shared memory as per the FAQ:
gargamel:~# grep . /proc/sys/kernel/shm???
/proc/sys/kernel/shmall:234217728
/proc/sys/kernel/shmmax:234217728
/proc/sys/kernel/shmmni:4096

Any idea what else I might be missing or what's causing the huge delay?

Thanks,
Marc

Re: I get a 20 sec lag on an rtsp stream from aircam dome

Posted: Wed Jan 23, 2013 7:34 pm
by marcmerlin
Just for the hell of it, I upped my shared memory from 220MB to 500MB and restarted zoneminder.
Is there a way to know exactly how much shared memory ZM is using and how short I am, or how much I oversubscribed?

For now, starting ZM gives me the following. No errors for zmc_m2/aircam1, but I still get a 20 second delay for live view through ZM, but almost no delay for live view from the camera itself.

Jan 23 11:28:33 gargamel zmc_m1[7220]: INF [Starting Capture]
Jan 23 11:28:33 gargamel zma_m1[7225]: WAR [Waiting for capture daemon]
Jan 23 11:28:33 gargamel zmc_m2[7230]: INF [Starting Capture]
Jan 23 11:28:33 gargamel zmc_m2[7230]: INF [Priming capture from rtsp://aircam1:554/live/ch01_0]
Jan 23 11:28:33 gargamel zma_m2[7235]: WAR [Waiting for capture daemon]
Jan 23 11:28:33 gargamel zmc_m3[7240]: INF [Starting Capture]
Jan 23 11:28:33 gargamel zma_m3[7245]: WAR [Waiting for capture daemon]
Jan 23 11:28:34 gargamel zmc_m5[7250]: INF [Starting Capture]
Jan 23 11:28:34 gargamel zma_m5[7256]: WAR [Waiting for capture daemon]
Jan 23 11:28:34 gargamel zmc_m4[7262]: INF [Starting Capture]
Jan 23 11:28:34 gargamel zma_m4[7268]: INF [In mode 3/1, warming up]
Jan 23 11:28:34 gargamel zma_m1[7225]: WAR [Waiting for capture daemon]
Jan 23 11:28:34 gargamel zma_m2[7235]: WAR [Waiting for capture daemon]
Jan 23 11:28:34 gargamel zma_m3[7245]: INF [In mode 5/1, warming up]
Jan 23 11:28:35 gargamel zma_m5[7256]: INF [In mode 5/1, warming up]
Jan 23 11:28:35 gargamel zma_m1[7225]: INF [In mode 5/1, warming up]
Jan 23 11:28:35 gargamel zma_m2[7235]: INF [In mode 3/1, warming up]
Jan 23 11:28:39 gargamel zma_m5[7256]: INF [kitch-fmr: 026 - Opening new event 3623, section start]
Jan 23 11:28:41 gargamel zma_m1[7225]: INF [patiocam1: 026 - Opening new event 3624, section start]
Jan 23 11:28:42 gargamel zma_m3[7245]: INF [frontdoorcam1: 026 - Opening new event 3625, section start]
Jan 23 11:30:00 gargamel zma_m5[7256]: INF [kitch-fmr: 426 - Closing event 3623, section end]
Jan 23 11:30:00 gargamel zma_m5[7256]: INF [kitch-fmr: 426 - Opening new event 3626, section start]
Jan 23 11:30:00 gargamel zma_m1[7225]: INF [patiocam1: 209 - Closing event 3624, section end]
Jan 23 11:30:00 gargamel zma_m1[7225]: INF [patiocam1: 209 - Opening new event 3627, section start]
Jan 23 11:30:00 gargamel zma_m3[7245]: INF [frontdoorcam1: 153 - Closing event 3625, section end]
Jan 23 11:30:00 gargamel zma_m3[7245]: INF [frontdoorcam1: 153 - Opening new event 3628, section start]

Re: I get a 20 sec lag on an rtsp stream from aircam dome

Posted: Thu Jan 24, 2013 7:48 pm
by marcmerlin
Scratch that, it looks like the delay gets bigger over time to values of minutes, or maybe even hours.

Is RTSP known to have issues in zoneminder, or just the aircam stream? or did I configure it wrong?

Thanks

Re: I get a 20 sec lag on an rtsp stream from aircam dome

Posted: Thu Jan 24, 2013 11:46 pm
by theforce
I had an issue like that a long time ago but it was just grabbing jpg's from a remote zoneminder box. I think it had something to do with the maximum fps and alarm fps along with frame skipping. Maybe even settings in the buffers. Its been so long I dont remember exactly what it was or how I fixed it. You might want to play around with those settings to see if that makes a difference.

Re: I get a 20 sec lag on an rtsp stream from aircam dome

Posted: Fri Jan 25, 2013 12:46 am
by marcmerlin
theforce, I owe you a big thank you.

I don't know exactly what the bug was, but I had my camera setup at 15fps and told ZM to take 5fps and switch to 15fps when the zone was alarmed.
I think there is a bug with RTSP where if there are more frames sent by the stream than ZM is consuming, it gets further and further behind because it doesn't know how to drop frames.
Actually, I found out that even putting 15fps causes it to get behind a bit, but if I put 16fps, then things are ok.

In other words, ZM cannot restrict FPS on RTSP coming from ffmpeg it seems.
Can I file a bug somewhere? I'm not finding a link for bugs on the zoneminder main page.