CGI interface for events?

Forum for questions and support relating to the 1.28.x releases only.
Locked
spargopolis
Posts: 8
Joined: Mon Nov 30, 2015 10:52 am
Location: Ottawa, Canada

CGI interface for events?

Post by spargopolis »

Hi,

I'm running ZM 1.28.1 on Ubuntu 14.04. I'm working on a ZM plugin for Kodi. As such I would like to be able to view any recorded events direct through Kodi.

ZM offers a "CGI-BIN" for the live video feed, configurable in the Paths tab (described as "Web path to zms streaming server"). Does this same API work for events? For example I've tried the following URL:

Code: Select all

http://192.168.1.107/cgi-bin/nph-zms?monitor=1&view=event&eid=82&format=avi&bitrate=10&maxfps=25&user=admin&pass=PASS
I manually added the "&view=event&eid=82" bit, but always get the live feed...

Thanks for your interest.
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: CGI interface for events?

Post by knight-of-ni »

Start here:
http://zoneminder.readthedocs.org/en/latest/api.html

The API is only available in ZoneMinder development snapshots for the moment, but a new release is just around the corner.

Whatever you end up doing, keep in mind that the variable PATH_ZMS under Options is different for every distro, so don't hard code that in your plugin.

When asker comes around, he will be able to provide more in depth help as he currently has the most experience using the API.
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: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: CGI interface for events?

Post by asker »

Log onto the web console of ZM, play an event and inspect source - you will find the correct URL to use (ignore auth= and replace with user & pass as above)

The APIs don't provide you a URL for live playback or event playback, unfortunately.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
spargopolis
Posts: 8
Joined: Mon Nov 30, 2015 10:52 am
Location: Ottawa, Canada

Re: CGI interface for events?

Post by spargopolis »

Log onto the web console of ZM, play an event and inspect source - you will find the correct URL to use (ignore auth= and replace with user & pass as above)
Thanks for the replies. I inspected the html source and the URL was as follows.

Code: Select all

<img id="evtStream" src="http://192.168.1.107/cgi-bin/nph-zms?source=event&mode=jpeg&event=84&frame=1&scale=100&rate=100&maxfps=10&replay=single&connkey=645511&rand=1451519639" alt="Event-84" width="1280" height="720"/>
I tried adding the user/pw options, and pasting the URL into a browser and I didn't see video.

However I did figure it out. I took the URL for the live video, and just added the "source=event&event=X" options. e.g.

Code: Select all

http://192.168.1.107/cgi-bin/nph-zms?source=event&event=84&monitor=1&format=avi&bitrate=10&maxfps=25&user=admin&pass=PASS
This works in a browser, so it should work with the Kodi plugin.
Again thanks for your help.
spargopolis
Posts: 8
Joined: Mon Nov 30, 2015 10:52 am
Location: Ottawa, Canada

Re: CGI interface for events?

Post by spargopolis »

I have a similar question to the earlier one in this thread, but for Montage view instead of Events. For the Kodi plugin I have worked on, I would like to add a single screen which contains a Montage view of multiple cameras, very similar to the same feature available in the Zoneminder Web interface. Note the user would be able to configure which cameras are shown, and what layout is used through menus.
The APIs don't provide you a URL for live playback or event playback, unfortunately.
As asker stated the new APIs don't provide live playback, so I'm limited to using the CGI Web API afaik.

I found that a single camera in Montage mode has a URL of the form:

Code: Select all

http://192.168.1.123/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=25&maxfps=10&user=admin&pass=PASS
but this is for monitor 1 only (shown at 25% scale). Is it possible to have Zoneminder itself combine multiple camera video streams into a single stream/URL such that I could see more than 1 camera at a time? I'm guessing it's not possible but thought I would ask the question just the same.

Thanks for your interest.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: CGI interface for events?

Post by asker »

spargopolis wrote: Is it possible to have Zoneminder itself combine multiple camera video streams into a single stream/URL such that I could see more than 1 camera at a time? I'm guessing it's not possible but thought I would ask the question just the same.
Nope - you will have to create the montage yourself. ZM does not stitch images together. You can do that by creating a small html file that loads images from each camera and lays them next to each other using CSS.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
spargopolis
Posts: 8
Joined: Mon Nov 30, 2015 10:52 am
Location: Ottawa, Canada

Re: CGI interface for events?

Post by spargopolis »

Nope - you will have to create the montage yourself. ZM does not stitch images together. You can do that by creating a small html file that loads images from each camera and lays them next to each other using CSS.
I got busy so I'm trying to restart this task.
Asker, you responded to this a while ago. Would you be able to point me in the direction of how to create a sample HTML file which contains a live CGI link? If I understand correctly the CGI link would be different than a normal hyperlink. The CCS layout stuff I think I can figure out... Thanks.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: CGI interface for events?

Post by asker »

Simple 2 column layout example
1) replace http://server/zm/cgi-bin/nph-zms with your server+cgi-bin path
2) replace monitor=1/2/3/4 with your monitor IDs
3) replace pass=xxxxx with pass=<your password>

Note that if you are using Chrome and using https, and it complains of insecure connections because of self-signed certs, you will need to start it with --allow-running-insecure-content

Code: Select all

<html>
        <style>
         .twocol {
           -webkit-column-count:2;
           -moz-column-count:2;
           -column-count:2;

           -webkit-column-gap:0;
           -moz-column-gap:0;
           -column-gap:0;
         }
        </style>

        <body>
        <div class="twocol">
                <img src="http://server/zm/cgi-bin/nph-zms?mode=jpeg&scale=100&monitor=1&user=admin&pass=xxxxx" width="100%" >
                <img src="http://server/zm/cgi-bin/nph-zms?mode=jpeg&scale=100&monitor=2&user=admin&pass=xxxx" width=100%" >
                <img src="http://server/zm/cgi-bin/nph-zms?mode=jpeg&scale=100&monitor=3&user=admin&pass=xxxx" width="100%" >
                <img src="http://server/zm/cgi-bin/nph-zms?mode=jpeg&scale=100&monitor=4&user=admin&pass=xxxx" width="100%" >
        </div>
        </body>
</html>
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Locked