External access to snapshots of cameras

Forum for questions and support relating to the 1.28.x releases only.
Post Reply
bolick
Posts: 5
Joined: Wed Oct 20, 2010 7:59 am

External access to snapshots of cameras

Post by bolick » Mon Jul 13, 2015 3:05 pm

I'm wondering if there's a way to get snapshot of a particular camera (read "Zoneminder" monitor) in form of URL to JPEG?

This is my use-case:

I have N FullHD IP-cameras (1920x1080, h264 in RTSP) configured in Zoneminder.

I have another hand-made application that displays snapshots from all those cameras on one screen so I can see what's happening around now. In that my application now I'm retrieving snapshots directly from each camera via specific URL.

And with that approach of getting snapshots directly from cameras I have at least 2 issues:
[1] I want to separate [physically] network with cameras from [let's call it] generic "home network" and connect cameras to a dedicated network adapter of server that runs Zoneminder. But if I do so I won't be able to access cameras directly from devices that work in another network (in which Zoneminder web-interface is visible). So if I may get the same snapshots from Zoneminder server I won't need direct access to cameras.

[2] Even though I now may get snapshots from cameras directly I see almost every snapshot has corrupted areas/segments while h264 stream is perfectly correct at all times. I hope that with offloading JPEG creation from cameras to powerful Zoneminder machine and with move of many h264 streams to a separate network will help to resolve problem with corrupted JPEGs/snapshots as well.

I tried to use URLs of images I saw in Zoneminder window like "192.168.0.128/cgi-bin/zm/nph-zms?mode=jpeg&monitor=8" but outside of Zoneminder window by that URL I saw nothing. Probably I'm doing something stupidly wrong but looks like I'm out of ides.

Thanks a lot for any help or suggestions.

User avatar
knight-of-ni
Posts: 2100
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: External access to snapshots of cameras

Post by knight-of-ni » Tue Jul 14, 2015 1:06 pm

The way to solve item #1 is to get yourself a managed switch that supports vlan tagging.
Configure your camera and data networks for different vlans.

You then need a layer 3 routing device. You can pay more for a network switch that supports static routing. Another approach would be to use something like pfSense. It is a free software based firewall, which has a ton of functionality, including vlan support and routing between vlans.

This gets you want you want. You end up with two separate networks and the ability to directly communicate with your cameras from your data network.


I am hopeful that someone else who has actually done item #2 will reply. There are likely multiple ways to do this depending on what you want.

Zoneminder stores all events as jpeg's on your filesystem, so if you just want a jpeg from the most recent event then that is just an issue of searching for the most recent jpeg under your events folder.

If you want a jpeg that represents "now", then you may need to look into using zmtrigger to trigger an event at that point in time.

Here is an example of triggering an event via external means:
http://www.sparxeng.com/blog/software/z ... triggering
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

bolick
Posts: 5
Joined: Wed Oct 20, 2010 7:59 am

Re: External access to snapshots of cameras

Post by bolick » Wed Jul 15, 2015 4:16 pm

Thanks a lot for your reply.

But my question was not really on how to implement [1] or [2] but how to use ZoneMinder server as a source of "real-time" images from all its "monitors". Think about that as a possibility to display ZoneMinder's monitor on remote (still located in the same network) device.

User avatar
asker
Posts: 915
Joined: Sun Mar 01, 2015 12:12 pm

Re: External access to snapshots of cameras

Post by asker » Wed Jul 15, 2015 5:15 pm

bolick wrote:I'm wondering if there's a way to get snapshot of a particular camera (read "Zoneminder" monitor) in form of URL to JPEG?
.
You mean use ZM to grab a monitor feed and save it as an image?

Code: Select all

wget "http://yourserver/cgi-bin/zms?mode=single&monitor=1&user=xxx&pass=yyy"  -O foo.jpg
replace '1' with the correct monitorId and xxx and yyy with your login/passwords
Last edited by asker on Wed Jul 15, 2015 7:08 pm, edited 1 time in total.
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

User avatar
knight-of-ni
Posts: 2100
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: External access to snapshots of cameras

Post by knight-of-ni » Wed Jul 15, 2015 5:26 pm

bolick wrote:Thanks a lot for your reply.

But my question was not really on how to implement [1] or [2] but how to use ZoneMinder server as a source of "real-time" images from all its "monitors". Think about that as a possibility to display ZoneMinder's monitor on remote (still located in the same network) device.
And that is why I mentioned using zmtrigger. If you want a jpeg that is recent, then you need to tell zoneminder to create an event first. You use zmtrigger to do that.

BTW, You can use the same url's that zoneminder uses, but that will generate a stream, rather than a static jpeg.
To figure out what the url should be, open a live view, right click the image itself and copy the image location to the clipboard. That is all you need if zoneminder authentication is set to off or plain.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

User avatar
knight-of-ni
Posts: 2100
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: External access to snapshots of cameras

Post by knight-of-ni » Wed Jul 15, 2015 5:28 pm

asker wrote:
bolick wrote:I'm wondering if there's a way to get snapshot of a particular camera (read "Zoneminder" monitor) in form of URL to JPEG?
.
You mean use ZM to grab a monitor feed and save it as an image?

wget "http://yourserver/cgi-bin/zms?mode=sing ... x&pass=yyy" -O foo.jpg

replace '1' with the correct monitorId and xxx and yyy with your login/passwords
I'll be damned. That works? It gives you just one jpeg and not a mjpeg stream?
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

User avatar
asker
Posts: 915
Joined: Sun Mar 01, 2015 12:12 pm

Re: External access to snapshots of cameras

Post by asker » Wed Jul 15, 2015 6:16 pm

Yup it works. That's what I am doing in zmNinja to work around the max 10 (or 6) connections open problem of Chrome
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

bbunge
Posts: 2046
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: External access to snapshots of cameras

Post by bbunge » Wed Jul 15, 2015 7:30 pm

You can also set up a web page to access the camera streams. This will expose your user and password but if you create an unprivileged user in ZM it should not hurt security. If your ZM system is on an isolated LAN throw another LAN card in to access your server from another subnet/internet.

My code:

<html>
<meta http-equiv="refresh" content="300">
<body>
<p>Reception Camera Group</p>

<img src="http://server-url-or-ip/cgi-bin/nph-zms ... &pass=user">

<img src="http://server-url-or-ip/cgi-bin/nph-zms ... &pass=user">

<img src="http://server-url-or-ip/cgi-bin/nph-zms ... &pass=user">

<img src="http://server-url-or-ip/cgi-bin/nph-zms ... &pass=user">


</body></html>

bolick
Posts: 5
Joined: Wed Oct 20, 2010 7:59 am

Re: External access to snapshots of cameras

Post by bolick » Fri Jul 17, 2015 7:34 am

>> wget "http://yourserver/cgi-bin/zms?mode=sing ... x&pass=yyy" -O foo.jpg
>>
>> replace '1' with the correct monitorId and xxx and yyy with your login/passwords

That URL made a trick.. well with only 1 exception that I had to add "zm" betweeen "cgi-bin" and "zms".
And to be honest I'm very happy now because:
[1] I'm seeing perfectly correct snapshots instead of corrupted JPEG's I got directly from cameras.
[2] Moreover IP cameras that used to reset itself to some factory defaults (which among other things switched capture format from 1080p to 720p and what's even more disturbing picture was rotated on 180 degrees effectively giving upside down footage) now work stable - no issues so far since I switched to snapshots from ZoneMinder.

Thanks a lot!

bolick
Posts: 5
Joined: Wed Oct 20, 2010 7:59 am

Re: External access to snapshots of cameras

Post by bolick » Fri Jul 17, 2015 7:46 am

knnniggett wrote: BTW, You can use the same url's that zoneminder uses, but that will generate a stream, rather than a static jpeg.
To figure out what the url should be, open a live view, right click the image itself and copy the image location to the clipboard. That is all you need if zoneminder authentication is set to off or plain.
Well that was the first thing I tried but with no luck. Even though I don't have any users set at all so I assume it should not be a matter of authentication.
BTW that's a URL I'm getting by rigth-clicking on ZM monitor's image:

Code: Select all

http://192.168.0.128/cgi-bin/zm/nph-zms?mode=jpeg&monitor=1&scale=50&maxfps=30&buffer=1000&connkey=543576&rand=1437118775
I noticed that my URL has "zm/nph-zms" while one you proposed has "zm/zms". Is that expected?

User avatar
knight-of-ni
Posts: 2100
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: External access to snapshots of cameras

Post by knight-of-ni » Fri Jul 17, 2015 11:57 am

bolick wrote: Well that was the first thing I tried but with no luck. Even though I don't have any users set at all so I assume it should not be a matter of authentication.
Yes, you did, but the example you gave in your first post was missing a few parameters in the url, which is why it didn't work.
Not an issue now that Asker enlightened us that "mode=single" was the magic to get zonemidner to return a jpeg rather than a stream.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

thegizzard
Posts: 8
Joined: Fri May 11, 2018 9:33 pm

Re: External access to snapshots of cameras

Post by thegizzard » Fri May 11, 2018 9:35 pm

bolick wrote:
Fri Jul 17, 2015 7:34 am
>> wget "http://yourserver/cgi-bin/zms?mode=sing ... x&pass=yyy" -O foo.jpg
>>
>> replace '1' with the correct monitorId and xxx and yyy with your login/passwords

That URL made a trick.. well with only 1 exception that I had to add "zm" betweeen "cgi-bin" and "zms".
And to be honest I'm very happy now because:
[1] I'm seeing perfectly correct snapshots instead of corrupted JPEG's I got directly from cameras.
[2] Moreover IP cameras that used to reset itself to some factory defaults (which among other things switched capture format from 1080p to 720p and what's even more disturbing picture was rotated on 180 degrees effectively giving upside down footage) now work stable - no issues so far since I switched to snapshots from ZoneMinder.

Thanks a lot!
Hey I just registered for this board to thank you for this post. It works perfectly for me too!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest