Using Remote ZM streams as a source for a central zm server

Support and queries relating to all previous versions of ZoneMinder
somepdguy
Posts: 43
Joined: Thu Jun 24, 2004 8:35 am

Using Remote ZM streams as a source for a central zm server

Post by somepdguy »

Hi All,

I am on Slackware 9.1, NO video card drivers cause I am trying to use remote cameras (zm streams) only. V4L and sound are both in as modules. Hardware is PIII 2 gig with 256 meg ram. I have installed ZM successfully (like i have a few times with wired cams) and set up a remote monitor with the following info:

cctv.fp.co.uk
port 80
/cgi-bin/zms?mode=jpeg&monitor=3&scale=100&maxfps=10&user=admin&pass=adminpass

When I look at a monitor i get a broken image, if i go to still view I get a black screen.

I want to stream 4 ZM streams out down and ADSL line to a remote server so that if someone walks in and steals the box they will be captured and recorded.

I have this setup working on my home slackware 9.1 box from the same remote ZM streams but when I have tried to roll it out to the main server it hasn't worked.

Here is some useful stuff from the box that does NOT work.

lsmod
soundcore 3812 0 (unused)
i2c-algo-bit 7752 0 (unused)
i2c-core 13316 0 [i2c-algo-bit]
videodev 6592 0
8139too 14536 1
crc32 2880 0 [8139too]
agpgart 36992 0 (unused)

also this is the result of tail -f /var/log/messages and tail -f /tmp/zm* when I restart Zm on the server.

root@brian:~#
==> /tmp/zmpkg.log <==
Command: restart
Executing: /usr/local/bin/zmdc.pl check
Executing: /usr/local/bin/zmdc.pl shutdown

==> /tmp/zmdc.log <==
'zmc -m 3' stopping at 05/06/09 21:10:29
'zmc -m 3' died at 05/06/09 21:10:29
'zmfilter.pl ' stopping at 05/06/09 21:10:29
'zmfilter.pl ' died at 05/06/09 21:10:29, signal 14
'zmc -m 2' stopping at 05/06/09 21:10:29
'zmc -m 2' died at 05/06/09 21:10:29
'zmwatch.pl ' stopping at 05/06/09 21:10:29
'zmwatch.pl ' died at 05/06/09 21:10:29, signal 14
'zmaudit.pl -d 900 -y' stopping at 05/06/09 21:10:29
'zmaudit.pl -d 900 -y' died at 05/06/09 21:10:29, signal 14
Jun 9 21:10:29 brian zmc_m3[18009]: INF [Got TERM signal, exiting]
Jun 9 21:10:29 brian zmc_m3[18009]: ERR [Select error: Interrupted system call]
Jun 9 21:10:29 brian zmc_m2[17998]: INF [Got TERM signal, exiting]
Jun 9 21:10:29 brian zmc_m2[17998]: ERR [Select error: Interrupted system call]
Can't find child with pid of '18057'
Server shutdown at 05/06/09 21:10:39
Server starting at 05/06/09 21:10:40
tail: /tmp/zmdc.sock: No such file or directory

==> /tmp/zmpkg.log <==
Removing shared memory
Executing: /usr/local/bin/zmdc.pl check
Removing shared memory
Executing: /usr/local/bin/zmfix
Executing: /usr/local/bin/zmdc.pl status
tail: /tmp/zmdc.sock: No such device or address
Executing: /usr/local/bin/zmdc.pl start zmc -m 3
Jun 9 21:10:43 brian zmc_m3[18096]: INF [Debug Level = 0, Debug Log = <none>]

==> /tmp/zmdc.log <==
'zmc -m 3' starting at 05/06/09 21:10:43, pid = 18096
'zmc -m 3' started at 05/06/09 21:10:43
'zmc -m 2' starting at 05/06/09 21:10:43, pid = 18100
'zmc -m 2' started at 05/06/09 21:10:43
'zmfilter.pl' starting at 05/06/09 21:10:44, pid = 18104
'zmfilter.pl' started at 05/06/09 21:10:44

==> /tmp/zmpkg.log <==
Executing: /usr/local/bin/zmdc.pl start zmc -m 2
Executing: /usr/local/bin/zmdc.pl start zmfilter.pl
Executing: /usr/local/bin/zmdc.pl start zmaudit.pl -d 900 -y
Jun 9 21:10:43 brian zmc_m3[18096]: INF [Starting Capture]
Jun 9 21:10:43 brian zmc_m2[18100]: INF [Debug Level = 0, Debug Log = <none>]
Jun 9 21:10:43 brian zmc_m2[18100]: INF [Starting Capture]

==> /tmp/zmdc.log <==
'zmaudit.pl -d 900 -y' starting at 05/06/09 21:10:44, pid = 18108
'zmaudit.pl -d 900 -y' started at 05/06/09 21:10:44
'zmwatch.pl' starting at 05/06/09 21:10:45, pid = 18113
'zmwatch.pl' started at 05/06/09 21:10:45

==> /tmp/zmpkg.log <==
Executing: /usr/local/bin/zmdc.pl start zmwatch.pl

==> /tmp/zmwatch.log <==
Watchdog starting at 05/06/09 21:10:45
Watchdog pausing for 30 seconds

==> /tmp/zmfilter.log <==
Scanning for events


This
ERR [Select error - various things...
seems to point to a problem - i have done the dumb thing and checked mysql and that seems to be working OK. Any clues?

I can't think why one box works and one doesn't. Well I can think - it is because something is setup/installed differently, but what?

Thanks


Pete
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Following the recent threads the problems that come to mind that may be preventing it from working are:
Depending on your settings in ZM even if your are capturing in B/W zm may colorize the picture so the settings for the remote server may need to be set to color.
Also if you have autentication turned on you need to add a user and password to the end of the host path. This path is for the fedora core 3 RPM. (/cgi-bin/zm/zms?mode=jpeg&monitor=2&scale=100&maxfps=1&user=remote&pass=remotepassword)
I create a limited login just for this so that all that user can do is veiw streams in case it's compromized.
Now the axis cameras have the login info as part of the host name because the method of authentication is different. If you require authentication to access your camera then add this onto the host name in the form <username>:<password>@<hostname>.com.

The other thing to pay attention to is if you have a router you need to forward the port to the server so that it can be seen. Always check that you can see the remote server from a browser is a good check to make sure that you have your router/firewall setting correct.
Last thing is the capture size has to match what the remote server is sending.
It may be possible to read the headers to see what size the picture that are served are and have zm detect this but I could be wrong. I've been meaning to study more but work has been keeping me really busy (which means the more video capture devices out there the better).
Just few few things I've noticed people strugling with.
Also check your apache logs. You might find the error there.
Regards,
Cordel
somepdguy
Posts: 43
Joined: Thu Jun 24, 2004 8:35 am

thanks for that.

Post by somepdguy »

Hi thanks,

as I said I can get the stream working to my home ZM box but not a central server.

If I wget/lynx the stream from the server that isn't working
http://cctv.fp.co.uk//cgi-bin/zms?mode= ... =adminpass
I get the stream OK, i don't think there is a f/w port forwarding issue.

From Wget:
HTTP request sent, awaiting response... 200 OK
Length: unspecified [multipart/x-mixed-replace]

[ <=>
162,253 17.79K/s

When I setup the camera i leave the settings as default, like I do on my home box that works.

I am still getting a black screen though when I view.

When i netstat -tanu I can see a connection from ADSL box to server and can see data going through.

Because the server doesn't actually have a camera attached I don't know if it will display any images....

Any ideas from here (bearing in mind it works ok from ADSL to my home box but not to a central server)?

Thanks
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Phil had pointeed out the other day that using nph-zms may also help.
somepdguy
Posts: 43
Joined: Thu Jun 24, 2004 8:35 am

no difference with nph-zms

Post by somepdguy »

Hi All

Still no luck.

To recap - the slave ZM installation cctv.fp.co.uk is working fine and I can stream to my home ADSL box with no problems using the settings below
cctv.fp.co.uk
80
/cgi-bin/zms?mode=jpeg&monitor=3&scale=100&maxfps=10&user=admin&pass=yeahbaby

BUT I cannot stream to a central server (that is slackware 9.1 I think setup the same as my home box)

On the slave cctv.fp.co.uk if I strace zms (streaming) daemon i can see it sending out frames:

root@forestpark-cctv:~# strace -p 17585
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
write(1, "Content-Length: 16803\r\n", 23) = 23
write(1, "Content-Type: image/jpeg\r\n\r\n", 28) = 28
write(1, "\377\330\377\340\0\20JFIF\0\1\1\0\0\1\0\1\0\0\377\333\0"..., 16803) = 16803
write(1, "\r\n\r\n--ZoneMinderFrame\r\n", 23) = 23
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
nanosleep({0, 33333000}, NULL) = 0
write(1, "Content-Length: 16763\r\n", 23) = 23
write(1, "Content-Type: image/jpeg\r\n\r\n", 28) = 28
write(1, "\377\330\377\340\0\20JFIF\0\1\1\0\0\1\0\1\0\0\377\333\0"..., 16763) = 16763
write(1, "\r\n\r\n--ZoneMinderFrame\r\n", 23) = 23

If I strace the capture daemon (zmc) on the central server box I (think) I see data going in:
root@brian:/usr/local/src/zm-1.20.1# strace -p 20905
Process 20905 attached - interrupt to quit
select(7, [6], NULL, NULL, {1, 780000}) = 1 (in [6], left {1, 730000})
ioctl(6, FIONREAD, [65]) = 0
read(6, "17 \r\nContent-Length: 16248\r\n\r\n1c"..., 65) = 65
old_mmap(NULL, 24133632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40cfe000
munmap(0x42402000, 24133632) = 0
select(7, [6], NULL, NULL, {2, 500}) = 1 (in [6], left {2, 10000})
ioctl(6, FIONREAD, [1448]) = 0
read(6, "1000\r\n\377\330\377\340\0\20JFIF\0\1\1\0\0\1\0\1\0\0\377"..., 1448) = 1448
old_mmap(NULL, 24137728, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x42402000
munmap(0x40cfe000, 24133632) = 0
select(7, [6], NULL, NULL, {2, 500}) = 1 (in [6], left {2, 10000})
ioctl(6, FIONREAD, [2656]) = 0
read(6, "\254\356\327\26\361M\345LCy\254\304\375\335\207;O@8j\336"..., 2656) = 2656
old_mmap(NULL, 24137728, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x43b07000
munmap(0x42402000, 24137728) = 0
select(7, [6], NULL, NULL, {2, 500}) = 1 (in [6], left {2, 10000})
ioctl(6, FIONREAD, [2896]) = 0
read(6, "1000\r\ndm*\314\303\270\250qk\250<D\236\310\246\257\270"..., 2896) = 2896
old_mmap(NULL, 24141824, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40cfe000
munmap(0x43b07000, 24137728) = 0
select(7, [6], NULL, NULL, {2, 500}) = 1 (in [6], left {2, 10000})
ioctl(6, FIONREAD, [2656]) = 0
read(6, "\16\t\306\346#\256z\327`c\216\\\356@{\347\35h\214n\214"..., 2656) = 2656
old_mmap(NULL, 24145920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x42404000
munmap(0x40cfe000, 24141824) = 0
select(7, [6], NULL, NULL, {2, 500}) = 1 (in [6], left {2, 10000})
ioctl(6, FIONREAD, [2656]) = 0
read(6, "\261f\237\313\0377ZKy\31\235\260Fv63\322\244\206\332\v"..., 2656) = 2656
old_mmap(NULL, 24145920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x43b0b000
munmap(0x42404000, 24145920) = 0
select(7, [6], NULL, NULL, {2, 500}) = 1 (in [6], left {2, 10000})
ioctl(6, FIONREAD, [1448]) = 0
read(6, "f78\r\n)c\n^,+!\344\322oBuz\32\351\205Q\274\201HnQxQ\223"..., 1448) = 1448
old_mmap(NULL, 24150016, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40cfe000
munmap(0x43b0b000, 24145920) = 0


So from all of that I think that the slave cctv.fp.co.uk is running zms OK and that the server is running zmc and capturing the frames OK but the server just isn't displaying them properly. Can I test if the server ZM installation can actually output pictures?

The logs don't show any ERR: 's at the moment.

Any ideas where to go from here, this is a big sticking point. If I haven't supplied some info then please let me know!

Thanks to all

Pete
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

You could try bumping up the debug level in the capturing zmc processes (just send them one USR1 signal per level). Also you can use zmu to get the latest captured image timestamp and/or image to check what they are seeing.

Phil
somepdguy
Posts: 43
Joined: Thu Jun 24, 2004 8:35 am

thanks

Post by somepdguy »

Hi Phil

Thanks for that, i have kill -SIGUSR1 pidofzmc 3 times but can't see any more debug info in /tmp/zm* or /var/log/messages


I have tried running zmu on the monitor

root@brian:~# zmu -m 2 -U admin -P yeahbaby -i
Segmentation fault

I take it that is bad, and perhaps the problem?

Thanks

Pete
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Does it segfault with -t as well as -i? It looks a bit like zmc is locking up somewhere if it's not responding to signals. The other thing to do is to set the ZM_DBG_LEVEL_zmc environment variable and run zmc from within that shell. This should have the same effect.

Phil
somepdguy
Posts: 43
Joined: Thu Jun 24, 2004 8:35 am

thanks

Post by somepdguy »

Thanks Phil


root@brian:~# zmu -m 2 -U admin -P yeahbaby -i
Segmentation fault
root@brian:~# zmu -m 2 -U admin -P yeahbaby -i -t
Segmentation fault
root@brian:~# zmu -m 2 -U admin -P yeahbaby -it
root@brian:~# zmu -m 2 -U admin -P yeahbaby -t
Segmentation fault
root@brian:~# zmu -m 2 -U admin -P yeahbaby -i
Segmentation fault
root@brian:~# zmu -m 2 -U admin -P yeahbaby -it

the -it doesn't segfault but the other combinations do.

regarding the other suggestion
root@brian:~# export ZM_DBG_LEVEL_zmc=1
root@brian:~# echo $ZM_DBG_LEVEL_zmc
1
root@brian:~# zmc -m 2
root@brian:~# killall -9 zmc
root@brian:~# killall -9 zmc
root@brian:~# killall -9 zmc
zmc: no process killed
root@brian:~# zmc -m 2

then it just sits there :\

I also tried

root@brian:~# export ZM_DBG_LEVEL_zmc=5
root@brian:~# zmc -m 2

(i think completely unrelated...) now when i check /var/log/messages i am getting

Jun 15 20:40:45 brian zmc_m2[23419]: DB3 [Unable to extract subheader from stream, retrying]
Jun 15 20:40:45 brian zmc_m2[23419]: DB3 [Expecting 1448 bytes]
Jun 15 20:40:45 brian zmc_m2[23419]: DB3 [Read 1448 bytes]
Jun 15 20:40:45 brian zmc_m2[23419]: DB3 [Unable to extract subheader from stream, retrying]
Jun 15 20:40:45 brian zmc_m2[23419]: DB3 [Expecting 1208 bytes]
Jun 15 20:40:45 brian zmc_m2[23419]: DB3 [Read 1208 bytes]
Jun 15 20:40:45 brian zmc_m2[23419]: DB3 [Unable to extract subheader from stream, retrying]
Jun 15 20:40:46 brian zmc_m2[23419]: DB3 [Expecting 1448 bytes]
Jun 15 20:40:46 brian zmc_m2[23419]: DB3 [Read 1448 bytes]
Jun 15 20:40:46 brian zmc_m2[23419]: DB3 [Unable to extract subheader from stream, retrying]
Jun 15 20:40:46 brian zmc_m2[23419]: DB3 [Expecting 1448 bytes]
Jun 15 20:40:46 brian zmc_m2[23419]: DB3 [Read 1448 bytes]
Jun 15 20:40:46 brian zmc_m2[23419]: DB3 [Unable to extract subheader from stream, retrying]


is DB3 debug level 3?

Has increasing the debug level worked (or did the sigusr1 i did earlier just take a while to work)?


Pete
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

I got your PM. I'll try and take a look at it tomorrow.

Phil
somepdguy
Posts: 43
Joined: Thu Jun 24, 2004 8:35 am

still no luck

Post by somepdguy »

I have played a bit more but am basically stuck at this point.

Does the DB3 mean debug level 3? Why wouldn't ZM be able to extract the header from the stream when Firefox and my other ZM box can??

Is there anything that needs to be installed to allow linux to read HTTP streams, all the perl modules are installed.

Strange one and still the sticking point on my current project!!


Pete
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Sorry I didn't get in for a look yesterday. I'll try shortly or this evening.

The DB3 comment about not being able to get a header is indeed debug so nothing to worry about. All it means is that the header for the next frame is not in the current buffer so it has to go off and read more. So that part of it looks like it's working fine.

Phil
somepdguy
Posts: 43
Joined: Thu Jun 24, 2004 8:35 am

hi

Post by somepdguy »

sorry to nag - any ideas before i rebuild from scratch?
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

I have to apologise. I got muddled up with your issue and someone elses, with a similar username. So I've been looking at their system thinking it was yours. I _promise_ to try and find time to get in tomorrow.

Phil
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

I think I may have identified a problem that could occur on slower links and which I think is causing your problem.

You could try installing this patch

Code: Select all

*** src/zm_event.cpp	16 May 2005 09:27:05 -0000	1.62
--- src/zm_event.cpp	22 Jun 2005 12:40:04 -0000
***************
*** 448,454 ****
  	}
  
  	fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
- 	fprintf( stdout, "--ZoneMinderFrame\r\n" );
  
  	FILE *fdj = NULL;
  	int n_bytes = 0;
--- 448,453 ----
***************
*** 500,509 ****
  
  					image.EncodeJpeg( buffer, &n_bytes );
  				}
  				fprintf( stdout, "Content-Length: %d\r\n", n_bytes );
  				fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
! 				write( fileno(stdout), buffer, n_bytes );
! 				fprintf( stdout, "\r\n\r\n--ZoneMinderFrame\r\n" );
  				fflush( stdout );
  				last_delta = this_delta;
  				db_written = true;
--- 499,509 ----
  
  					image.EncodeJpeg( buffer, &n_bytes );
  				}
+ 				fprintf( stdout, "--ZoneMinderFrame\r\n" );
  				fprintf( stdout, "Content-Length: %d\r\n", n_bytes );
  				fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
! 				fwrite( buffer, n_bytes, 1, stdout );
! 				fprintf( stdout, "\r\n\r\n" );
  				fflush( stdout );
  				last_delta = this_delta;
  				db_written = true;
Index: src/zm_monitor.cpp
===================================================================
*** src/zm_monitor.cpp	19 May 2005 16:22:22 -0000	1.80
--- src/zm_monitor.cpp	22 Jun 2005 12:37:01 -0000
***************
*** 1265,1271 ****
  void Monitor::StreamImages( int scale, int maxfps, time_t ttl )
  {
  	fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
- 	fprintf( stdout, "--ZoneMinderFrame\r\n" );
  
  	int fps = int(GetFPS());
  	if ( !fps )
--- 1265,1270 ----
***************
*** 1328,1337 ****
  				}
  				snap_image->EncodeJpeg( img_buffer, &img_buffer_size );
  
  				fprintf( stdout, "Content-Length: %d\r\n", img_buffer_size );
  				fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
  				fwrite( img_buffer, img_buffer_size, 1, stdout );
! 				fprintf( stdout, "\r\n\r\n--ZoneMinderFrame\r\n" );
  
  				if ( ttl )
  				{
--- 1327,1337 ----
  				}
  				snap_image->EncodeJpeg( img_buffer, &img_buffer_size );
  
+ 				fprintf( stdout, "--ZoneMinderFrame\r\n" );
  				fprintf( stdout, "Content-Length: %d\r\n", img_buffer_size );
  				fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
  				fwrite( img_buffer, img_buffer_size, 1, stdout );
! 				fprintf( stdout, "\r\n\r\n" );
  
  				if ( ttl )
  				{
on the remote end, e.g. the box you are running the zms processes on, or both for that matter. See if that makes a difference. Also if using zms in the path doesn't work, don't forget to try nph-zms as well.

Phil
Locked