Page 1 of 1

Retrieve a Snapshot

Posted: Thu Sep 17, 2009 3:35 pm
by beerygaz
Is there a way to access the nph-zms cgi-bin app to retrieve a single snapshot of a monitor? I've tried accessing it with some of the suggested syntax on the forum but get the following in /var/log/messages:

Sep 17 17:31:37 dvr zms[15001]: INF [Debug Level = 0, Debug Log = <none>]
Sep 17 17:31:37 dvr zms[15001]: FAT [Unable to load monitor id 1 for streaming]
Sep 17 17:31:37 dvr zms[15001]: INF [Got signal 6 (Aborted), exiting and forcing backtrace]
Sep 17 17:31:37 dvr zms[15001]: ERR [Signal address is (nil), from 0x396424]
Sep 17 17:31:37 dvr zms[15001]: ERR [Backtrace: [0x396424]]
Sep 17 17:31:37 dvr zms[15001]: ERR [Backtrace: [0x396424]]
Sep 17 17:31:37 dvr zms[15001]: ERR [Backtrace: /lib/libc.so.6(gsignal+0x51) [0x13b7c1]]
Sep 17 17:31:37 dvr zms[15001]: ERR [Backtrace: /lib/libc.so.6(abort+0x182) [0x13d092]]
Sep 17 17:31:37 dvr zms[15001]: ERR [Backtrace: /usr/libexec/zoneminder/cgi-bin/nph-zms [0x8054bed]]
Sep 17 17:31:37 dvr zms[15001]: ERR [Backtrace: /usr/libexec/zoneminder/cgi-bin/nph-zms [0x808060b]]
Sep 17 17:31:37 dvr zms[15001]: ERR [Backtrace: /usr/libexec/zoneminder/cgi-bin/nph-zms [0x804c1ef]]

While I'm at it, is there a way to log ZM activity to another log file other than 'messages'?

Posted: Fri Sep 18, 2009 10:01 pm
by hushpuppy
Yes, create a dir under zm called check, make sure it has permissions for your web-user (mine is www-data, your could be apache, or something else), create a file called "check.php" (or anything you want, i avoid index.php because i want to be able to see the pics created (I've not written a web page for this yet).

In "check.php", put these lines.
<?php
exec('(cd /var/www/html/zm/check ; /usr/local/bin/zmu -m 1 -U <user name> -P <password> -i -v -S 85)');

?>

The 1 after -m represents the camera number, I've 4 cams, so 4 similar lines (-m1 to -m4)

This is a quick way to do this, ideally i should have a page that calls the exec command, then updates the images on the same page, I've just not got round to that yet.

Hope this helps, works great for my iphone.

If the php script doesnt work, check permissions AND paths, if it still doesnt work, check them again, was a permissions problem that caused me headaches.

Posted: Sat Sep 19, 2009 11:17 am
by beerygaz
Thanks for the prompt response hushpuppy, but I have a slightly different requirement.

I have a Home Automation application that can grab a snapshot via a URL, and expects a JPG image as a result. If I call your PHP script it will put the image in a dir but not return the image to the calling application. Also, I don't know how to pass the camera ID to PHP as a parameter. My PHP, is, I'm afraid, non-existent.

Posted: Sat Sep 19, 2009 7:56 pm
by hushpuppy
>I have a Home Automation application that can grab a snapshot via a URL, and expects a JPG >image as a result.
The script i posted does indeed create jpegs.



> If I call your PHP script it will put the image in a dir but not return the image to the calling >application.

Hmm, I dont understand exactly what you mean by this, can you be more specific.



> Also, I don't know how to pass the camera ID to PHP as a parameter. My PHP, is, I'm afraid, >non-existent.

That we can work out when weve sorted out the problem above.



You may also want to look at something like this :-

http://<ipaddress>/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=100&maxfps=1&user=<username>&pass=<password>

Posted: Sun Sep 20, 2009 10:11 am
by beerygaz
It was the cgi-bin option that I was originally trying but struggled with syntax (I was also getting my monitor ID wrong - assuming the first in the list was 1).

I searched about and managed to modify your suggestion:
http://<ipaddress>/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=100&maxfps=1&user=<username>&pass=<password>

into:

http://<ipaddress>/cgi-bin/zm/nph-zms?mode=single&monitor=1&scale=100&user=<username>&pass=<password>

I struggled to find the path to nph-zms that the Fedora RPM uses, but got there in the end. Is there somewhere I can find a reference for the parameters that nph-zms can accept?

HP - Thanks for all of your help in getting this sorted. I really appreciate it.

Posted: Sun Sep 20, 2009 7:17 pm
by hushpuppy
I thought it would be on the wiki, but can't find it there, but did find something after a search on the forum.


mode - should be either 'jpeg' for mpjpeg stream, 'mpeg' for mpeg stream or 'single' for individual jpeg frame
monitor - id of monitor, not to be used with event
event - id of event, not to be used with monitor
format - video format for mpeg streaming
scale - scale factor as %ge of original image size
rate - frame rate as %ge of original event (not for use with monitor)
maxfps - maximum fps at which to send frames
bitrate - video bitrate for mpeg streaming
ttl - time to live, in monitor streaming what the maximum streaming period is before zms will exit
user, pass, auth - authentication options


Hope this helps.

view via android mobile

Posted: Mon Mar 29, 2010 7:28 pm
by grndamgt4
Thanks alot, i've been trying to get a live image via android mobile and the mode=single made that work for me.
I was hoping the jpeg stream would work but no luck.