Motion Eye and Motion


Documentation

motioneye github page

motioneye wiki

motioneye configuration file

motion home page

motion documentation

motion configuration

Installation

Installed following instructions on the motioneye github page:

python3 -m pip install --pre motioneye
motioneye_init

This installed motioneye, as well as motion version 4.7.0 (and other prerequisites). Note that motion is actually a deb package, so can be controlled using apt.
It created a user called motion. The motioneye server runs as user motion.
It also started the motioneye server.

The motioneye server runs under systemd, and so can be controlled using systemctl.

The installation can be updated using:

systemctl stop motioneye
python3 -m pip install --upgrade --pre motioneye
systemctl start motioneye

The motioneye service is normally disabled. To enable and start it before vacating use:

systemctl enable motion eye
systemctl start motioneye

Configuration

motioneye provides a web interface at http://sage:8765. Note that https does not work.

The configuration file for motioneye is /etc/motioneye/motioneye.conf, which is owned by user motion.

motioneye starts the motion server, with a parameter telling it to use /etc/motioneye/motion.conf as its configuration file.
motion has its own systemd service file, but it shouldn't be started or stopped using systemctl when you are using motioneye. - this won't affect the motion started by motioneye.

Configuration is done via the web interface rather than by editing configuration files. Click on the settings button at the top left to access the configuration options.

Camera configuration

Click on the drop-down list to the right of the settings button and select "add camera ..." to add a camera.
Click the settings button to edit camera settings - under "Video Device".

I added the Foscam camera using the following settings:

Camera name: Foscam
Camera ID: 1
Camera device: rtsp://192.168.183.12:554/videoMain
Camera type: Network camera
Video resolution: 1280x720
Frame rate: 15

The camera user name and password have to be entered when the camera is added, but I can't see any way of editing them later via the web interface.

The camera configuration is saved to /etc/motioneye/camera-<ID>.conf, so the user and password could be edited there.

Motion notifications

I configured it to send me emails:

Send an email: selected
Email addresses: motion@tinhaze.co.uk
SMTP server: granite.wingpath.co.uk
SMTP port: 587
SMTP account: frank
SMTP password: *********
From address: motion@sage.wingpath.co.uk
Use TLS: selected
Attached Pictures Time Span: 10

Still images

These need to be enabled if you want images in motion notification emails.

Capture mode: motion triggered
Preserve pictures: For one week

Images are saved to files under /var/lib/motioneye/Camera1, so they could be copied from there if needed. They could also be manually deleted.

General settings

Set a password for the admin user.

Connecting a webcam - plan A

We are using Logitech C270 HD Webcams on mugwort and bonobo.
These have a maximum resolution of 720p (1280x720) @ 30fps.

In order to access a webcam on mugwort or bonobo we have to set up an RTSP server on the raspberry to stream the video from the v4l webcam device.

For testing purposes, we can use "ffplay rtsp://...." to play the stream - this is simpler than configuring it in motioneye.

The webcam is probably available on /dev/video0, although 'v4l2-ctl --list-devices' produces:

UVC Camera (046d:0825) (usb-0000:01:00.0-1.2):
/dev/video0
/dev/video1
/dev/media4

I don't know what the other two devices are for.

Installing v42ltrsstreamer

There are several ways to create an RTSP stream from v4l2 webcam, but the simplest seems to be v4l2rtspstreamer.

I tried downloading the zip file of source for this, but it wouldn't build.

I got it to build (on mugwort) following instructions from Real Time Streaming Protocol and the Raspberry Pi – Video for Linux 2:

apt install cmake liblog4cpp5-dev libv4l-dev
git clone https://github.com/mpromonet/v4l2rtspserver.git
cd v4l2rtspserver
cmake .
make
make install

To test it, I tried (on mugwort):

v4l2rtspserver -P 7447 /dev/video0

and on sage:

ffplay rtsp://mugwort:7447/unicast

Running v42lrtspstreamer as a service

To get v4l2rtspstreamer to run as a service, I created the file /etc/systemd/system/v4l2rtspserver.service (copied from the above instructions):

[Unit]
Description=V4L2 RTSP server
After=network.target

[Service]
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/v4l2rtspserver -F 15 -P 7447 /dev/video0
WorkingDirectory=/usr/local/share/v4l2rtspserver

[Install]
WantedBy=multi-user.target

Then:

systemctl enable v4l2rtspserver
systemctl start v4l2rtspserver

It should automatically start on reboot.

Adding the webcam to motioneye

I added the Foscam camera using the following settings:

Camera name: mugwort
Camera ID: 2
Camera device: rtsp://mugwort:7447/unicast
Camera type: Network camera

I also had to setup Motion Notifications and Still Images as for the Foscam camera.

Connecting a webcam - plan B

Plan A worked, but not very well: update of the image was very slow, and motion detection was unreliable. It's not clear why: neither sage not mugwort was working hard and network speed was OK. Using ffplay on sage to play the video stream from mugwort was fast.

I decided to try plan B: install a separate instance of motioneye on mugwort.

Installation

On Raspberry OS bookworm you are supposed to install Python packages in a "virtual environment". I couldn't get this to work, so I resorted to using a --break-system-packages option as a workaround. See New error when installing motioneye #2964, for example.

python3 -m pip install --break-system-packages --pre motioneye
motioneye_init

Configuration

Camera set up was tricky. I was offered drop-down list of camera choices with names like bcm2835-codec-decode - I couldn't find one that worked. I resorted to choosing one, and changing the video_device in the configuration file /etc/motioneye/camera-1.conf to /dev/video0.

Other configuration was similar to that above for sage.