Shrunk Expand

zoneminder

zoneminder

apt-get install python-software-properties
add-apt-repository ppa:iconnor/zoneminder
apt-get update
sudo apt-get install zoneminder

We want a small delay on zoneminder’s startup time, to allow MySQL to start before Zoneminder

sudo nano /etc/init.d/zoneminder

Add below: start() {

sleep 15

should look like:

start() {
       sleep 15
       echo -n "Starting $prog: "

Ctrl+o Enter to save

CTRL+x to exit

sudo ln –s /etc/zm/apache.conf etc/apache2/conf.d/zoneminder.conf
sudo service apache2 restart

Lastly, I have had to do this using my local cameras (seems to be not needed when just using network cams;
sudo chmod 666 /dev/video0
Then restart zoneminder.


The axis wireless cameras lock up now and then, you can try to install the following cron job to reboot them;
05 15 * * * curl -u root:PASSWORD  http://ip.of.cam/axis-cgi/admin/restart.cgi &>/dev/null


Modect.
Benson set up some motion detect zones and straight away the cameras showed up red on the list and no video in groov.
The error in the ZM log was along the lines of ‘extends outside of image dimensions’.
In a nutshell, somehow he managed to get the active zone points outside of the camera resolution.
Soon as we deleted the motion detect zone, the camera feed started again.


To view the recorded streams in Chrome (or IE), you need cambozola.jar.
Download it from here;  http://www.zoneminder.com/downloads
And then copy / FTP it to /usr/share/zoneminder It will pick it up and use it from there.


Message on display

You can put a message along with the time, the message can be sent a few different ways, in my case, an Opto controller.
To set it up, do the following;

1. sudo nano /usr/bin/zmtrigger.pl
You want to comment out (add #) the triggers that you are not going to use, in my case, everything after the first 6802 one.
2. Go to the web page, open options, on the first page, toward the bottom, there is a entry ‘opt_triggers’, tick the box, save the settings, restart zm from the web page.
3. While you are in the web page area, open the config for the monitor you want to add the text to the end of and add %Q at the end of timestamp string in your monitor settings, or where you want the text to appear.
4. Change the monitor function to NoDect?, MoCord? or MoDect?.
5. Send the command. There are few different ways to do this, the following scrips will take the text as a URL:

$cfgServer    = "localhost";
$cfgPort    = 6802;
$cfgTimeOut    = 10;

if ($extTrigger) {
    // open a socket
    if(!$cfgTimeOut) {
   // without timeout
        @$conn_handle = fsockopen($cfgServer, $cfgPort);
    }else{
   // with timeout
        @$conn_handle = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut);
    }
    if(!$conn_handle) {
    //    echo "Connexion failed ";
   exit();
    }else{
    //    echo "Connected ";
        fputs($conn_handle, $extTrigger);
    }
// close connexion
fclose($conn_handle);
}

You then form the URL like thus;
 http://myserver/zm/myscript.php?extTrigger=<id>|<action>|<score>|<cause>|<text>|<showtex>

Or, you can do it from telnet;

telnet localhost 6802
1|show||||test

(Hint, to get out of the telnet session, its ctrl+], then quit).

A typical session goes like this;

host@host:~$ telnet 192.168.1.1 6802
Trying 192.168.1.2...
Connected to 192.168.1.2.
Escape character is '^]'.
1|show||||humm
1|show||||humming bird
^]
telnet> quit
Connection closed.

#!/bin/sh

# ./script.sh | telnet
echo 'open localhost 6802'
sleep 1
echo $1
sleep 1
echo 'quit'

Create this script “script.sh” (executable) and enter this on the console:

./script.sh ‘1|show18’ | telnet

Note, the first number is the monitor number, so if you add %Q to all your monitors, you can select which monitor you want to spit the text at via the command/script/URL.

Thus, on the PAC Control side we make the string, and send it.

// open the comm handle to the webserver
zm_comm_handle_status = OpenOutgoingCommunication? (zm_telnet_comm_handle);
// the comm handle is; tcp:192.168.1.x:6802
// it takes about 1 second for the webserver to respond to the connect request.
DelaymSec?(1000);

Then, in the looping optoscript block;
// Send the data
zm_allsky_data = “1 | show | | | | cam =” + sallsky_temp + chr(96) + “C” + ” ” + sallsky_fan + ” ” + “OA = ” + sallsky_oa_temp + chr(96) + “C” + chr(13) + chr(10);
zm_comm_handle_status = TransmitString?(zm_allsky_data, zm_telnet_comm_handle);

//update the data every 15 seconds.
DelaymSec?(15000);


curl

Note, I have not used any of what follows.
How can I grab single frames for archival purposes?

The simpest way is to run curl, either locally (on the server) or on a remote client:

curl ‘ http://SERVER:PORT/?mode=single‘ -s -o snap.jpg

The above line saves a snapshot to the file snap.jpg. (The “-s” option makes curl run in “silent mode”, i.e. prevents it from displaying the download progress meter or error messages). As a more elaborate example, the following shell script takes a snapshot approximately every 5 seconds. Frames are stored as 0.jpg, 1.jpg, 2.jpg etc.

#!/bin/bash # Palantir timed capture script (suitable for FFmpeg) n=0 while true ; do

curl ‘ http://SERVER:PORT/?mode=single‘ -s -o $n.jpg n=$(($n+1)) sleep 5

done

Alternatively, you can name frames according to the time (HHMMSS) they were captured:

#!/bin/bash while true ; do

curl ‘ http://SERVER:PORT/?mode=single‘ -s -o date +%H%M%S.jpg sleep 5

done

With FFmpeg it is trivial to make a MPEG file out of the captured frames. Assuming they were named 0.jpg, 1.jpg etc., the following line creates a movie in which snapshots are played back at a rate of 10 per second:

ffmpeg -r 10 -i %d.jpg movie.mpg

MPlayer/MEncoder (which rely on the FFmpeg libraries) can be used, too. However, they expect the sequential frame names to be zero-padded, as in 0000.jpg, 0001.jpg, etc.; in order to produce the correct filenames, the above shell script has to be slightly modified:

#!/bin/bash # Palantir timed capture script (suitable for MPlayer/MEncoder) n=0 while true ; do

curl ‘ http://SERVER:PORT/?mode=single‘ -s -o printf %04d $n.jpg n=$(($n+1)) sleep 5

done

The following line creates an MPEG4 movie in which snapshots are played back at a rate of 10 per second:

mencoder “ mf://????.jpg” -mf fps=10 -o movie.mpg -ovc lavc

The following line combines the captured frames into an animated GIF named output.gif. Note that the intended playback speed (in this example, 5 frames per second) has to be specified both as a -mf fps=… and as a gif89a:… parameter:

mplayer “ mf://????.jpg” -mf fps=5 -vo gif89a:5:output.gif


video lag

pasted here in case he takes it down;

 http://www.pictux.org/blog/20100712/zoneminder-124x-delay-issue/?lang=it

[1]: cut off the <span> tag that display fps: from <div><SLANG>: <span></span> – <span></span> fps</div> to <div><SLANG>: <span></span> – fps</div> in file montage.php, view.php, etc
(I have not done this one, not using this tag, so dont need it).

[2]: turning off mpeg streaming setting pre-buffer on the monitor settings to something less … From what I can remember, it appears that zoneminder buffers the first 10 frames (internally) so the frame you see is always 10 frames behind real time. This means that if you are capturing at 25 fps the image you see is 0.4 seconds behind reality. If you are capturing at 5fps you are 2 seconds behind and if at 1fps you are 10 seconds behind.
(Dropping the pre-buffer might help if you have Modetc, but if its just a monitor, not sure it makes any difference).

[3]: Delays with RTSP, HTTP, anything when the fps is above 6fps or zoneminder controls the fps. Try this and let us know how it goes. Remote Protocol: HTTP Remote Method: Simple Remote Host Name: user:password@ip address Remote Host Port: 80 Remote Host Path: /axis-cgi/mjpg/video.cgi?resolution=320×240&compression=20 Remote Image Colors: 24bit color Capture Width: 320 Capture Height: 240 Maximum FPS: blank Alarm Max FPS: blank.
(This. This is important. If you put a number (I put 1.0) in maximum FPS you get some really nasty lag (up to 2-3 minutes!). This makes most of my groov demos unusable. What seems to happen is the camera is producing frames quicker than ZM can use them, so it just get buffered in ZM memory. For ‘Monitor’ I leave them blank, and the lag is gone. Trouble is, for Modetc it can cause issues?)

[4]: Options-> Web-> CAN_STREAM Override the automatic detection of browser streaming capability (?) Change this to yes. It is camera setting its the PRE buffer.
(Not used this one either, not sure what its doing).,

My solution Set on ZM camera config:
Maximum FPS: blank.
Alarm Max FPS: blank

Set on remote ip camera: Quality: Auto FPS: 10

Set on Options -> Bandwidth -> (used bandwidth) -> WEB_L_VIDEO_MAXFPS to 10

Webography [1]  http://www.zoneminder.com/forums/viewtopic.php?t=15409 [2]  http://www.zoneminder.com/forums/viewtopic.php?t=16007 [3] http://www.zoneminder.com/forums/viewtopic.php?t=15162 [4]  http://www.zoneminder.com/forums/viewtopic.php?t=16020

Kind of on the topic of lag:- black/red/blue screens due to timeouts.
Bensons network is super busy, his high def cameras are pushing it hard.
Getting a few solid blank frames from one of the front cameras and the winepod cam.
Looking at it for him;
Options -> Network. There is a value for how long ZM waits before giving up on the image. It was set to about 2000ms, I bumped it to 8000ms, that helped a fair bit.
On each camera config, be sure and put a value in both the max FPS and the Alarm FPS. I put 1.00 in both. That helped a good amount. (Not tested for lag, since he does not have many/any real time demos).

From there, the trouble then comes when you do modect. It detects the blank frame (be it black, red or blue) and records it as motion and thus an event.
To help cut this down. Two settings.
In each camera config, under ‘Buffers’. Set the Alarm Frame Count to something other than 1. If you have 1 FPS and the cameras drop for around 5 seconds, then you need to try 5. BUT, this will mean all motion for 5 seconds will be ignored. Problem.
Next, in the ‘Zones’ (click on the configured zone) there is a setting at the bottom, ‘Overload Frame Ignore Count’. Its set to 0. You need to put something in there to tell it to ignore the overloaded frame is that black/blue/red.


shared memory

zoneminder ver 1.24.X uses the old way, anything 1.25.x or newer uses a different method that I have no experience with at all.

sudo nano /etc/sysctl.conf to include the following somewhere:

# Memory modifications for ZoneMinder
kernel.shmall = 33554432
kernel.shmmax = 536870912

Now, apply the settings with sudo sysctl -p

This forces a reload of that file. Next, you can check that the memory parameters have been changed:

cat /proc/sys/kernel/shmall
33554432
cat /proc/sys/kernel/shmmax
536870912

Which is successful. You can also check it with ipcs -l. Now, reboot ZoneMinder and you shouldn’t have any problems.
(But, you probably will).


Dont forget tail -f /var/log/messages to see what zoneminder is freaking out about.