Get latest Frame (jpg) from camera?

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
kibbling
Posts: 20
Joined: Fri Oct 07, 2022 12:45 pm

Get latest Frame (jpg) from camera?

Post by kibbling »

Hello,

Sorry for my newby question. I tired each documentation, but can’t find:

How can I extract the latest Image of a camera as jpg, in order to upload it to my homepage (each minute)?
I use “Record” and write all cameras all the time without images (because of the space) to disc.
I found the URL

Code: Select all

http://IP/zm/index.php?view=image&fid=2251&eid=14&show=capture
where I can capture each Frame from the stream. But I only can guess, what is the latest frame. So currently I guess the frame number by the walltime modulo the FPS.

Any tip for an URl to geht/extract the “latest” frame , in order to upload it each minute to the website?

I have not managed to figure out what is the “connkey” for the live URL, think this is somehow a “secret”? Maybe a way to bypass this connkey?

Code: Select all

http://IP/zm/cgi-bin/nph-zms?scale=75&mode=jpeg&maxfps=30&monitor=1&rand=1665146563&connkey=637539
bbunge
Posts: 2934
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: Get latest Frame (jpg) from camera?

Post by bbunge »

How about video instead?

Set up a basic user with view only permission. I use user with a password of user. I also set up a low res cam with monitor function.

Here is the code to put into an html file:

<html>
<meta http-equiv="refresh" content="300">
<body>
<img src="https://your.url.net/zm/cgi-bin/nph-zms ... &pass=user">
<body/>
<html/>

Your Zoneminder server will need to be port forwarded through your router. Note the monitor=4 is the cam ID from the Zoneminder cam list.
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Get latest Frame (jpg) from camera?

Post by Magic919 »

Have a look at zmu to grab a frame.
-
User avatar
iconnor
Posts: 2900
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Get latest Frame (jpg) from camera?

Post by iconnor »

If you look at the console with thumbnails, that is an example of how to get the latest jpeg.

The gist of it is http://hostname/zm/cgi-bin/nph-zms?mode ... &monitor=1
You can add scale= or width= etc. You will likely also need to add authentication if you have auth turned on. So user=&pass= etc.


The view=image stuff is really for getting event frames.

Also as mentioned, there is zmu.
kibbling
Posts: 20
Joined: Fri Oct 07, 2022 12:45 pm

Re: Get latest Frame (jpg) from camera?

Post by kibbling »

Thank you all.
I found only this workaround until now. Everything else is a mjpg and not a jpg.

curl "http://IP/zm/cgi-bin/nph-zms?mode=jpeg&monitor=1" -m 1 > out.mjpg
ffmpeg -i out.mjpg -r 1 -f image2 image_%03d.jpg
... upload image_002.jpg

@iconnor:
Thats also MJpg not jpg.

@Magic919:
What is "zmu"? Where to look at it?

@bbunge:
Thats not possible. Need to push lots of Cameras through very small internet connection.
Also dont want to open a port from extern to this network.
So it needs to be "push", not pull. And need to have very small amount of data.
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Get latest Frame (jpg) from camera?

Post by Magic919 »

ZMU is part of the ZM install. Run zmu -h for some clues. You'd usually specify monitor number, user and password.
-
kibbling
Posts: 20
Joined: Fri Oct 07, 2022 12:45 pm

Re: Get latest Frame (jpg) from camera?

Post by kibbling »

Thank you, thats great. Think "zmu -i .. -m..." do the trick!
User avatar
iconnor
Posts: 2900
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Get latest Frame (jpg) from camera?

Post by iconnor »

Sorry I typod. It should be mode=single not mode-single. mode=jpeg is mjpeg mode=single is a single jpg.
kibbling
Posts: 20
Joined: Fri Oct 07, 2022 12:45 pm

Re: Get latest Frame (jpg) from camera?

Post by kibbling »

Thank you, this is also working!
Very helpful here, thank you all!
User avatar
burger
Posts: 390
Joined: Mon May 11, 2020 4:32 pm

Re: Get latest Frame (jpg) from camera?

Post by burger »

This works well. Here's an example webpage that reloads the image w/js every couple seconds in case anyone is interested.

The zmu I put in cron.

Code: Select all

<head>
    <title>Camera</title>
    <script type="text/javascript" >
setInterval(function() {
    var myImageElement = document.getElementById('myImage');
    myImageElement.src = 'Monitor4.jpg?rand=' + Math.random();
}, 5000);

    </script>
</head>
<body>
<h1 style="text-align: center">Camera <a href="URL">URL</a>
<div align="center">
<img id="myImage" src="Monitor4.jpg" />
</div<
</body>
fastest way to test streams:
ffmpeg -i rtsp://<user>:<pass>@<ipaddress>:554/path ./output.mp4 (if terminal only)
ffplay rtsp://<user>:<pass>@<ipaddress>:554/path (gui)
find paths on ispydb or in zm hcl

If you are new to security software, read:
https://wiki.zoneminder.com/Dummies_Guide
Post Reply