Motion

From Omnia
Jump to navigation Jump to search

Motion

Motion, a software motion detector - http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome

Installation

Raspberry Pi:

apt-get install motion

RHEL 6:

# install RPM Fusion - couldn't get to work :-(
yum install motion

Manual Installation:

yum install gcc make libjpeg-devel  # assuming needing gcc make and others?
mkdir -p ~/.src ; cd ~/.src
# wget http://sourceforge.net/projects/motion/files/latest/download?source=files -O motion-latest.tar.gz
wget http://sourceforge.net/projects/motion/files/motion%20-%203.2/3.2.12/motion-3.2.12.tar.gz/download -O motion-3.2.12.tar.gz
tar -zvxf motion-3.2.12.tar.gz
cd motion-3.2.12
./configure --prefix=/opt/motion
make clean
make
sudo make install
sudo ln -s /opt/motion/etc /etc/motion
sudo cp /opt/motion/etc/motion-dist.conf /opt/motion/etc/motion.conf
sudo /opt/motion/bin/motion

Config

ConfigFileOptions < Motion < Foswiki - http://www.lavrsen.dk/foswiki/bin/view/Motion/ConfigFileOptions

/etc/motion/motion.conf:

# ubuntu # process_id_file /var/run/motion/motion.pid
daemon on
process_id_file /var/run/motion.pid
videodevice /dev/video0
width 320
height 240
# width 640
# height 480
framerate 2
minimum_frame_time 1
text_right %Y-%m-%d\n%T-%q
text_left My Camera
target_dir /pub/cam/mycam
jpeg_filename %Y-%m-%d/%Y-%m-%d-%H-%M-%S-%q
webcam_port 8081
webcam_localhost off
# on_picture_save /etc/motion/motion-latest %f
on_picture_save logger -t mycam %f

To basically disable the images: (overwrites same file continually)

target_dir /tmp
jpeg_filename motion.conf

Prime

/etc/motion/motion.conf:

daemon on
process_id_file /var/run/motion.pid

thread /etc/motion/familyroom.conf
thread /etc/motion/kendesk.conf

/etc/motion/familyroom.conf:

netcam_url http://10.10.10.65/video.cgi
netcam_userpass admin:
width 320
height 240
framerate 2
minimum_frame_time 1
text_right %Y-%m-%d\n%T-%q
#text_left CAMERA %t
text_left Family Room
target_dir /pub/cam/familyroom
jpeg_filename %Y-%m-%d/%Y-%m-%d-%H-%M-%S-%q
webcam_port 8081
webcam_localhost off
on_picture_save logger -t cam-familyroom %f

/etc/motion/kendesk.conf:

netcam_url http://10.10.10.61:8080/videofeed
#width 320
#height 240
framerate 2
minimum_frame_time 1
text_right %Y-%m-%d\n%T-%q
#text_left CAMERA %t
text_left Ken Desk
target_dir /pub/cam/kendesk
jpeg_filename %Y-%m-%d/%Y-%m-%d-%H-%M-%S-%q
webcam_port 8082
webcam_localhost off
on_picture_save logger -t cam-kendesk %f

D-Link DCS-930L Wireless Net Camera

DLink < Motion < Foswiki - http://www.lavrsen.dk/foswiki/bin/view/Motion/DLink

JPEG: netcam_url http://xx.xx.xx.xx/IMAGE.JPG (for single JPEG images)
MJPEG: netcam_url http://xx.xx.xx.xx/VIDEO.CGI ( preferred for streaming MJPEG video) 

JPEG: netcam_url http://my.camera.ip.address/image.jpg
MJPEG: netcam_url =http://my.camera.ip.address/video.cgi?showlength=1= or just video.cgi

MJPEG - "I'm currently experiencing Motion losing connection with the net camera after less than 1 day using the video.cgi method, whereas it works 24/7 for many weeks using the image.jpg method. I am using basic user authentication, although may turn it off to see if it changes the lost connection behavior. "

-

D-Link DCS-930L wireless (802.11g) net camera

Firmware version: 1.00

Product: http://www.dlink.com/products/?pid=DCS-930L

Tested with motion 3.2.12

JPEG: netcam_url http://x.x.x.x/image.jpg
MJPEG netcam_url http://x.x.x.x/mjpeg.cgi

-

Amazon.com: D-Link DCS-930L mydlink-Enabled Wireless-N Network Camera: Camera & Photo ($35 w/ Prime) - http://amzn.com/B00452V66G

-

Connect to DLink IP cameras - http://www.ispyconnect.com/man.aspx?n=dlink

See DLink IP Cameras

umask

motion would not respect the umask group permission on directories as writable. So I fixed the source code:

fix-umask-group-write.patch:

--- motion.c.old        2015-02-25 10:35:31.713336862 -0700
+++ motion.c    2015-02-25 10:35:07.256762369 -0700
@@ -2511,7 +2511,7 @@
 int create_path(const char *path)
 {
     char *start;
-    mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
+    mode_t mode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH;

     if (path[0] == '/')
         start = strchr(path + 1, '/');
umask 0002
/opt/motion/bin/motion


Patch Submitted: UmaskGroupPermission < Motion < Foswiki - http://www.lavrsen.dk/foswiki/bin/view/Motion/UmaskGroupPermission

init.d

From CentOS 5 installation:

#!/bin/bash
#
# Startup script for the Motion Detection System
#
# chkconfig: - 85 15
# description: Motion Detection System.  It is used to detect \
#              movement based on compare images.
# processname: motion
# pidfile: /var/run/motion.pid
# config: /etc/motion.conf

# Source function library.
. /etc/rc.d/init.d/functions



motion=${MOTION-//usr/bin/motion}
prog=motion
PIDFILE=/var/run/motion.pid
RETVAL=0


start() {
        echo -n $"Starting $prog: "
    umask 0002
    umask
        daemon $motion
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/motion
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        killproc $motion
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/motion
}
stopsafe() {
        echo -n $"Stopping $prog: ( for restarting ) "
        killproc $motion
        RETVAL=$?
        sleep 10s
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/motion
}
reload() {
        echo -n $"Reloading $prog: "
        killproc $motion -HUP
        RETVAL=$?
        echo
}

# See how we were called.
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        status)
                status $motion
                RETVAL=$?
                ;;
        restart)
                stopsafe
                start
                ;;
        condrestart)
                if [ -f /var/run/motion.pid ] ; then
                        stop
                        start
                fi
                ;;
        reload)
                reload
                ;;
        *)
                echo $"Usage: $prog {start|stop|restart|condrestart|reload|status}"
                exit 1
esac

exit $RETVAL

To support our /opt/ install:

17c17
< motion=${MOTION-//usr/bin/motion}
---
> motion=${MOTION-//opt/motion/bin/motion}

keywords