Getting a image snapshot

Forum for questions and support relating to the 1.27.x releases only.
Locked
liderbug
Posts: 125
Joined: Wed Dec 19, 2007 4:46 pm

Getting a image snapshot

Post by liderbug »

I have need (weather cam) an image every 3 minutes. When ZM is watching a camera for an event is the frame in memory or on disk. If on disk somewhere - where? Where does it "buffer" the frames?

Thanks
Chuck
TheKorn
Posts: 142
Joined: Fri Aug 02, 2013 12:39 pm

Re: Getting a image snapshot

Post by TheKorn »

All of that is held in shared memory, not on disk.

Honestly a better/simpler solution would be to do a simple wget to single image (many cameras have this) in a cron job.
liderbug
Posts: 125
Joined: Wed Dec 19, 2007 4:46 pm

Re: Getting a image snapshot

Post by liderbug »

It's a RSTP/libvlc - wget just sits there.

Had a thought (don't go there...) that I could do a script: mysql update Monitors set function = 'Record' where id = 1; wait 1 or 2 seconds the reset to 'Modect'. Then just reach in and grab a jpg [ and erase the rest ] So I tried it by hand and the web screen updates but it doesn't record. So I'm thinging that when I change 'function' on the web page it triggers something else - can someone tell me what that is?

Thanks
Chuck
hesral
Posts: 44
Joined: Sun Apr 06, 2014 12:11 pm

Re: Getting a image snapshot

Post by hesral »

You can maybe make another monitor in zoneminder, that "captures" from the other monitor. Set framerate for the new monitor to 0.005(one picture ca every 180sec).

You get the stream for the other zoneminder monitor, the one with the "real" stream by using remote as source, your zoneminder server as ip, and the folowing as path
cgi-bin/nph-zms?mode=jpeg&monitor=[monitornumber]&user=[username]&password=[password]
rememeber to switch monitornumber with the monitor number you want to monitor. You see this number at the top, when you configure the monitor, I think.
username and password as needed.

As you already are saving images on the other monitor, you can set the new monitor in "monitor" mode.

I have not tested this, and can't test it from here, but it should work. At least it works whenever I want to connect one zonemindersetup to another.

I think you can make the same kind of link on a webpage by setting the source of an img tag to:
http://zoneminder-server-ip/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=100&maxfps=0.005&buffer=1000&user=username&password=password

last bit was copied from:
http://onlinetechadvice.blogspot.no/2012/03/stream-zoneminder-vlc.html
liderbug
Posts: 125
Joined: Wed Dec 19, 2007 4:46 pm

Re: Getting a image snapshot

Post by liderbug »

What about zmtrigger? From what I read it will do what I want except its already running (Address already in use at ...) I have tried "update monitor set function = record, sleep 5, set function = mondect. Works fine, except it doesn't "record". So when you do it with a mouse something else runs - it's been a very busy couple of days so I haven't had time.

Anyone with a thought?

Thanks.
liderbug
Posts: 125
Joined: Wed Dec 19, 2007 4:46 pm

Re: Getting a image snapshot

Post by liderbug »

Got it. Not ZM - but it works.
crontab */5 * * * *

Code: Select all

#!/bin/bash

typeset -i n
cd ~/bin/WU

function get_image
{
# -t 5 (seconds) produces 8 frames
 rm out.avi 
 ffmpeg -t 5 -i "rtsp://sg11:554/user=admin&password=&channel=1&stream=0.sdp" -vcodec libx264 -preset ultrafast -tune zerolatency -r 10 -async 1 -acodec libmp3lame -ab 24k -ar 22050 -bsf:v h264_mp4toannexb -maxrate 750k -bufsize 3000k -f mpegts out.avi 2> /dev/null

 ffmpeg -i out.avi -r 1 -f image2 image-%3d.jpeg 2> /dev/null
 photo=`ls -t | head -1`  # is image-008.jpeg
}

rh=`sunrise | cut -d: -f1`  # don't load a lot of night time images
rm=`sunrise | cut -d: -f2`
sh=`sunset | cut -d: -f1`
sm=`sunset | cut -d: -f2`
nh=`date +'%H'`
nm=`date +'%M'`
rise=`echo "($rh*60)+$rm-60" | bc`
set=`echo "($sh*60)+$sm+60" | bc`
now=`echo "($nh*60)+$nm" | bc`
if [ $now -gt $rise ]
then
  if [ $now -lt $set ]
  then
    get_image
    convert $photo -resize 640x480 myCAM1.jpg
    echo "binary" > .wuftp
    echo "put myCAM1.jpg" >> .wuftp
    ftp webcam.wunderground.com < .wuftp
  fi 
fi
http://www.wunderground.com/personal-we ... =KCOBLACK1
Hope this can give someone else a hand. It's code from ?5 yrs? ago the "get_image" replaced curl "oldcam..."
Locked