dockmotion
dockmotion copied to clipboard
:eyes: Surveillance made easy
dockmotion
A surveillance solution base on Motion and Docker.
It's easy and ready to use. Just plug in a webcam and run dockmotion, then videos and images will be saved once a motion is detected while a notification e-mail including the recorded video and a preview image will be sent. On top of that, the webcam can be accessed anytime via HTTP live streaming.
Quick Start
Clone this project then cd into it:
git clone https://github.com/kfei/dockmotion
cd dockmotion
Build or pull the image
Then build your own dockmotion Docker image:
docker build -t dockmotion .
Note that a pre-built image is also available:
docker pull kfei/dockmotion
Custom settings
Modify the sample motion.conf to
suit your webcam, e.g., videodevice, v4l2_palette, etc.
If using Gmail, change account and password settings in the
sample and save it as ssmtp.conf.
Run
Run the container with configs , e.g.,
docker run -it --device=/dev/video0
-p 8081:8081 \
-e TIMEZONE="Asia/Taipei" \
-e MAILTO="[email protected]" \
-v /data-store:/var/lib/motion \
-v /path/to/motion.conf:/etc/motion/motion.conf \
-v /path/to/ssmtp.conf:/etc/ssmtp/ssmtp.conf \
dockmotion
Note that:
- The
--deviceflag should be replaced by your webcam's device ID. - Expose port 8081 so that you can watch the live streaming, e.g.,
vlc http://localhost:8081. - Set
TIMEZONEtoAsia/Taipeiinstead of using UTC time. - All alarm mails will be sent to the e-mail address provided by
MAILTO. - Mount a volume to
/var/lib/motionfor container since there might be lots of images and videos produced by Motion.
Runtime Configs
There are some environment variables can be supplied at run time:
TIMEZONEis for correct time stamp when motion detected. Check/usr/share/zoneinfoor see the full list of time zones.MAILTOto specify who will receive the alarm e-mails. Please make sure you set up this correctly.
Settings in motion.conf can be overridden:
MOTION_PIXELSto specify the capture size of image, e.g.,1280x720. Note that the size must be supported by your webcam.MOTION_THRESHOLDforthreshold.MOTION_EVENT_GAPforevent_gap.MOTION_TIMELAPSEfor the time-lapse mode, e.g.,600,86400. Please see below for further explanation.
The Time-lapse Mode
Using dockmotion to capture
time-lapse videos is
quite easy. The MOTION_TIMELAPSE environment variable has two parts:
interval and duration, both in seconds. For instance, if a -e MOTION_TIMELAPSE="600,86400" is supplied, Motion will capture images every 10
minutes within 24 hours. Note that in time-lapse mode, the motion detection
will be disabled.
An example run, for capturing one frame per hour within a week:
docker run -it --device=/dev/video0
-e MOTION_PIXELS="1280x720" \
-e MOTION_TIMELAPSE="3600,604800" \
-v /data-store:/var/lib/motion \
-v /path/to/motion.conf:/etc/motion/motion.conf \
dockmotion
Now a weekly time-lapse video will be in /data-store.
A cool time-lapse:

(If you happen to know the author of this time-lapse, please let me know so I may source them properly.)
Hooks
There are many types of hook can be set in Motion. For instance,
dockmotion just provides an e-mail notification script as the on_event_end
hook. Please dig into motion.conf and define your own hooks.
Screenshots
-
E-mail Notification

-
HTTP Live Streaming
