A simple tool that allows image snapshots to be made from cameras managed by MotionEye.
Features:
- take snapshots from cameras managed by MotionEye
- stores images
- simple web interface
- simple snapshot viewer
- provides a simple API that a device can call, initiating a snapshot, and returning a url to the snapshot
MotionEye Snapshotter is useful for when you have a lightweight IOT device that is used to trigger snapshots. For example a door monitoring system detects when a door is opened, which then tells MotionEye Snapshotter to take and store a timestamped snapshot of a camera facing the door.
# go get -v github.com/smford/motioneye-snapshotter
Clone git repo and build yourself
# git clone git@github.com:smford/motioneye-snapshotter.git
# cd motioneye-snapshotter
# go build
- Create the docker volume to store configuration
# docker volume create motioneye-snapshotter
- Copy
config.yaml
andindex.html
to/var/lib/docker/volumes/motioneye-snapshotter/_data/
- Start up motioneye-snapshotter
# docker run --name motioneye-snapshotter -d --restart always -p 54036:5757/tcp -v motioneye-snapshotter:/config smford/motioneye-snapshotter:latest
Create a configuration file called config.yaml
an example is available below:
indexfile: /path/to/index.html
listenip: 0.0.0.0
listenport: 5757
meserver: http://127.0.0.1:8765
meuser: admin
snapshoturl: https://snapshots.mydomain.com
outputdir: /path/to/outputdir
cameras:
1: main-door
2: lobby
camerasigs:
1: xxxxXXxxxxxXxxxx
2: yyYYyYyyYYyYyyYy
Setting | Details |
---|---|
indexfile | the name and path to the file that is shown when people visit the main page of motioneye-snapshotter |
listenip | The IP for simple-canary to listen to, 0.0.0.0 = all IPs |
listenport | The port that simple-canary should listen on |
meserver | The URL to the MotionEye Server |
meuser | The MotionEye user to login and get the snapshot as |
snapshoturl | Pretty URL for people to access the web interface of motioneye-snapshotter |
outputdir | Directory to store all snapshots |
cameras | A list of cameras, with 1 being the camera number within MotionEye, and main-door being the name you have chosen to easily identify the camera |
camerasigs | A list of cameras and their snapshot signitures (details below) |
The configuration for cameras needs to be pulled out from motioneye and is not easy to spot.
We first need to discover each cameras number and also its signature. The camera number is an internal identifier that motioneye uses to identify a camera. The camera signature is special string, unique to each camera, that is somewhat like a password.
- Login as an admin user to motioneye web interface
- Go to the configuration of the camera you are wanting
- Expand "Video Streaming" then click "Snapshot URL". A small popup will appear, with a URL displayed similar to what is shown below.
https://127.0.0.1/picture/1/current/?_username=admin&_signature=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN
- The camera number is the number in the URL directly after
picture
. In the above example it is1
- The camera signature is the string after
_signature=
. In the above example it isabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN
- Choose a nice human readable name for the camera, in this example we will use
front-door
- Here is the part of config.yaml we need to configure:
You can now see in the configuration under
... cameras: 1: front-door 2: kitchen camerasigs: 1: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN 2: xxxxXXxxxxxXxxxx ...
cameras
that1: front-door
where 1=camera number and front-door is the nice human readable name we chose for the camera. Undercamerasigs
just add the camera number and the cameras specific signature.
After creating the config.yaml and the index.html file simply run:
# motioneye-snapshotter --config /path/to/config.yaml
See the instructions here https://github.com/smford/motioneye-snapshotter#docker
- IoT Device detects that a door has opened and wants a snapshot of the main-door camera to be taken:
Configure it to do an http request to:
http://192.168.10.1:54036/snap?camera=main-door
- Using a cronjob to take snapshots every 5 minutes:
*/5 * * * * wget --spider "http://192.168.10.1:54036/snap?camera=main-door" >/dev/null 2>&1
--config [config file] Configuration file: /path/to/file.yaml, default = ./config.yaml
--displayconfig Display configuration
--help Display help
Assuming motioneye-snapshotter is configured to use 192.168.10.1:54036 and there is a camera called main-door
Task | URL | Result |
---|---|---|
Display index.html | http://192.168.10.1:54036/ |
|
Take a snapshot of main-door camera |
http://192.168.10.1:54036/snap?camera=main-door |
Returns path to snapshot taken |
Browse cameras and the snapshots taken | http://192.168.10.1:54036/files |
|
See what cameras are configured | http://192.168.10.1:54036/cameras |
|
Download a specific snapshot | http://192.168.10.1:54036/files/main-door?file=20211012_124955.jpg |
Downloads image |