Raspberry Pi and MotionEye – Setting up your own video surveillance

logo

Requirements:

  • Raspberry Pi Model B
  • USB Webcam
  • Ethernet Cable or Wifi USB
  • Power

Step 1: Connecting your camera.

Connect your camera to your Raspberry Pi. In my case I am using Logitech C920. Once you have your camera connected, restart your Raspberry by typing:

sudo reboot

Once you have rebooted, list the usb devices connected on your Raspberry by typing.

lsusb

Your result should be similar to this:

Bus 001 Device 004: ID 046d:0821 Logitech, Inc. HD Webcam C910
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter / SMSC9512/9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In our case, we are interested in Logitech Webcam C910. By default, the Rasbpian Jessie OS comes with several preinstalled webcams.

Step 2: Installing Motion and prerequisites

We then need to install motion.

sudo apt-get install motion

As you probably know, ffmpeg is missing from the official Debian repos. Moreover, the variant offered by deb-multimedia.org no longer works with Raspbian after recent updates. You can either compile it yourself (not recommended) or download this prebuilt package and install it:

wget https://github.com/ccrisan/motioneye/wiki/precompiled/ffmpeg_3.1.1-1_armhf.deb
dpkg -i ffmpeg_3.1.1-1_armhf.deb

We finally install all the prerequisites:

apt-get install python-pip python-dev curl libssl-dev libcurl4-openssl-dev libjpeg-dev libx264-142 libavcodec56 libavformat56 libmysqlclient18 libswscale3 libpq5

Step 3: Installing Motioneye

To install motioneye we can use pip.

pip install motioneye
  1. Prepare the configuration directory:
mkdir -p /etc/motioneye cp
/usr/local/share/motioneye/extra/motioneye.conf.sample
/etc/motioneye/motioneye.conf
  1. Prepare the media directory:
mkdir -p /var/lib/motioneye
  1. Add an init script, configure it to run at startup and start the motionEye server:
cp /usr/local/share/motioneye/extra/motioneye.systemd-unit-local
/etc/systemd/system/motioneye.service systemctl daemon-reload
systemctl enable motioneye systemctl start motioneye

Step 4: Running the application!

Once you have everything installed, visit your raspberry’s IP address with the port number 8765.

https://miro.medium.com/max/700/1*lMvuhssRwEG5srCtO-U1Og@2x.png

You are done! MotionEye features motion control as well as the ability to connect multiple cameras.