motionEye with Raspberry PI

motionEye

motionEye is a web frontend for a Linux video surveillance program called motion. This tutorial will walk you through the necessary steps to install and configure motionEye on a Raspberry PI. You will build yourself an intelligent video surveillance system based on afordable components and opensource software.

Special thanks go to Kenneth Lavrsen, the original author of motion, a great piece of software that does all the hard work for this project.

motionEye Features

  • web interface, responsive design
  • user/password protection (administrator and normal user)
  • mjpg streaming
  • motion detection, output to jpeg and avi files
  • timelapse capturing
  • browsing, previewing and downloading of media files
  • advanced camera settings

Required Hardware

Screenshots

motioneye1 motioneye2 motioneye3 motioneye4 motioneye5 motioneye6

 

Installing The OS

Download the latest version of the Raspbian operating system. Here you'll find instructions on how to transfer the OS image to the memory card. Once the OS is on the SD card, boot your Raspberry PI. The commands presented with the following steps are to be executed exclusively in a terminal on the Raspnberry PI.

Before moving on, it is recommended that you update the packages on your system:

sudo aptitude update && sudo aptitude upgrade

Installing The Required Packages

motionEye requires a few libraries and extra programs. Install them with the following command:

sudo aptitude install python-tornado python-jinja2 python-imaging motion ffmpeg v4l-utils

Installing motionEye

Choose the latest version from the downloads list (use the Tags tab) and download it to /home/pi. Unpack (replacing xyz with the code in the filename):

cd /home/pi
tar zxvf ccrisan-motioneye-xyz.tar.gz
mv ccrisan-motioneye-xyz motioneye
cd motioneye

After this step you'll have motionEye installed in /home/pi/motioneye, your current directory.

Configuring motionEye

Create a settings.py file from the existing template:

cp settings_default.py settings.py

The default settings are good in most of the cases. If you wish to customize motionEye, you can later edit the settings.py file - you'll find a short description next to each of the available options.

CSI Camera Board

Follow this step only if you use the CSI Camera Board instead of a regular USB webcam.

limitations

  • only a single camera module can be used with motionEye
  • given the high resolution at which this camera can work, it is possible that the performance of Raspberry PI be not enough (processing of large images is CPU-hungry)

the uv4l driver

The camera module does not have a native v4l driver (at the time of writing). There is however a set of userspace components that emulate the v4l interface for such a camera module. 

UPDATE: now it has :)

the bcm2835_v4l2 module

Append bcm2835_v4l2 to /etc/modules

sudo nano /etc/module

troubleshooting

  • make sure you run the latest version of the Raspberry PI firmware
  • make sure you have enabled the camera module in raspi-config
  • don't overclock your PI too much, using the camera module causes core overheating already
  • allocate at least 64MB of RAM to the GPU

Running motionEye

motionEye does not need root privileges to run; it can be started directly from the directory where it was extracted:

./motioneye.py

If everything was properly installed and configured, motionEye should emit an info message saying that the server started. Now point your browser to http://raspberrypi:8765 (replacing raspberrypi with the IP adress of your device). The motionEye web interface should show up. Use admin with no password, when prompted for authentication. Start by adding a new camera and feel free to experiment with the various available settings.

When you're done "experimenting", hit ctrl-c.

Autostarting At Boot

You'll probably want motionEye to start automatically at boot. Add the following line to /etc/rc.local (right before the exit 0):

sudo -u pi sh -c '/home/pi/motioneye/motioneye.py > /home/pi/motioneye/run/motioneye.log 2>&1' &

This will start the server with the user pi, put the log into motioneye.log and run the process in the background.

The motion daemon will be run automatically by motionEye - it should not run at startup.

Where to buy

Below you can find affiliate linked images to buy directly from Amazon. Thank you for supporting this site!

Comments

  • Alex

    Super .You make something verry usefull and nice.Good job

    Posted at 2014-01-15 11:55:32

    Reply

  • Yu

    Hello.
    Excellent work, I've implemented in my raspy. Thanks for that.
    I'm Spanish and I've translated all that could / make known ...
    Well, my English is fatal and use google for this message.
    I have translated files: main.html, main.js, ui.js, README.md, LICENSE and AUTHORS.
    I think I'm not missing any files to translate, no?
    If this small translation job you want to use in the project,
    would be my pleasure to assist in this.
    Greetings.

    Posted at 2014-04-02 14:48:01

    Reply

  • Joe

    i Get this message when i try to add a cam in the webinterface.

    Failed to open /dev/video0: No such file or directory
    2014-04-20 23:16:21: ERROR: Uncaught exception GET /config/list_devices/?_=1398028575990 (192.168.1.105)
    HTTPRequest(protocol='http', host='192.168.1.109:8765', method='GET', uri='/config/list_devices/?_=1398028575990', version='HTTP/1.1', remote_ip='192.168.1.105', body='', headers={'Accept-Language': 'sv-SE,sv;q=0.8,en-US;q=0.6,en;q=0.4', 'Accept-Encoding': 'gzip,deflate,sdch', 'Host': '192.168.1.109:8765', 'Accept': '*/*', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36', 'Connection': 'keep-alive', 'X-Requested-With': 'XMLHttpRequest', 'Referer': 'http://192.168.1.109:8765/', 'Authorization': 'Basic YWRtaW46'})
    Traceback (most recent call last):
    File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 1000, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
    File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 1118, in wrapper
    return method(self, *args, **kwargs)
    File "./src/handlers.py", line 155, in get
    self.list_devices()
    File "./src/handlers.py", line 129, in wrapper
    return func(self, *args, **kwargs)
    File "./src/handlers.py", line 457, in list_devices
    for d in v4l2ctl.list_devices()]
    File "./src/v4l2ctl.py", line 43, in list_devices
    output = subprocess.check_output('v4l2-ctl --list-devices', shell=True)
    File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
    CalledProcessError: Command 'v4l2-ctl --list-devices' returned non-zero exit status 1
    2014-04-20 23:16:21: ERROR: 500 GET /config/list_devices/?_=1398028575990 (192.168.1.105) 88.23ms

    Posted at 2014-04-21 00:18:19

    Reply

  • andrew

    Has anyone been able to make it work with X10 USB cameras ? MotionEye detects the usb camera, but is "Unable to open video device"

    Posted at 2014-09-17 22:39:40

    Reply

  • michael

    1 sudo nano /etc/module

    should be: sudo nano /etc/modules

    Posted at 2014-11-05 19:29:12

    Reply

  • Tomek

    May I ask if the entries hashed in configuration files located in motioneye/conf subdirectory should be unhashed to make them active? Now I can see, that after I've configured user names and passwords for regullar access and administrative, after I reboot RPi I can access them without need to input user and password.
    Another question is about schedule. Does below entry means, that besides of defines time there will be no recording AND streaming?

    # @working_schedule 07:00-16:30|07:00-16:30|07:00-16:30|07:00-16:30|07:00-16:30|-|-

    Posted at 2014-12-01 00:35:25

    Reply

  • john

    hi. i am gaving an issue with the program to start after a reboot. i have to run manually the ./motioneye.py
    i have added in /etc/rc.local, the following
    sudo -u pi sh -c '/home/pi/motioneye/motioneye.py > /home/pi/motioneye/run/motioneye.log 2>&1' & but still no luck. any ideas please?

    Posted at 2015-04-04 00:03:44

    Reply

    • Mike

      Just in case anyone else has this problem. This would be the command if you have an account on your machine named "pi". Make sure to change all 3 instances of "pi" to whatever your account name is and you should be all set. Worked for me anyway.

      Posted at 2015-06-09 19:19:03

      Reply

  • Michael

    Hi!
    Can anyone help me, please?

    I get this error when typing:"./motioneye.py"

    pi@raspberrypi ~/motioneye $ ./motioneye.py
    Traceback (most recent call last):
    File "./motioneye.py", line 28, in
    from tornado.httpclient import AsyncHTTPClient
    ImportError: No module named tornado.httpclient

    Thanks in advance
    Michael

    Posted at 2015-06-22 21:04:18

    Reply

  • Michael

    1st of all: Great program! Thank you!

    Can anyone please help me with port forwarding e.g. by using dyn-DNS on selfhost...

    Thank you in advance!
    Michael

    Posted at 2015-07-16 22:08:37

    Reply

  • Jussi

    More easy is to just copy motionpie -image, which contains all configurations ready installed.

    Posted at 2015-08-01 16:08:24

    Reply

  • brian

    cp settings_default.py settings.py
    Can you explain what is supposed to be happening at this point, I get no such file error, in pi or motioneye and even motioneye/motioneye.
    I don't have a settings_default.py but have a settings.py in pi/motioneye/motioneye

    Posted at 2015-10-15 16:39:02

    Reply

  • David

    I have a question...
    How i can visualice my Webcams installed on my Pi, on Internet
    Local Network work's but no Internet another LAN (my office) :v

    Posted at 2016-04-09 03:05:11

    Reply

  • tom

    I'm a computer idiot trying to get a raspberry pi3 and raspberry pi camera rev 1.3 working with motioneye OS. I have watched many vids and read pages and never saw anyone else get stopped here and asked for their login/password. I get stuck when asked for the login/password here:

    DNS server address is 75.75.75.75
    75.75.76.76

    Welcome to meye-2b5ac9b0!
    meye-wb5ac9b0 login:
    Password:

    Can anyone tell me where to find this info ? Thanks.

    Posted at 2016-06-02 16:23:58

    Reply

    • leo

      had the same issue when trying to install straight from the sd card. trying to install through rpi jessie but having some issues with the download repository that was suggested

      Posted at 2016-07-04 15:17:53

      Reply

  • Armand

    Hi,

    ffmpeg is not available?

    sudo apt-get install ffmpeg
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Package ffmpeg is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    E: Package 'ffmpeg' has no installation candidate

    Posted at 2016-07-16 14:15:51

    Reply

  • Armand

    Hi again,

    I did the following for ffmpeg

    For jessie add this line

    deb http://ftp.debian.org/debian jessie-backports main
    to your sources.list

    Run apt-get update

    After that message no public key ....

    gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553
    gpg: directory `/home/pi/.gnupg' created
    gpg: new configuration file `/home/pi/.gnupg/gpg.conf' created
    gpg: WARNING: options in `/home/pi/.gnupg/gpg.conf' are not yet active during this run
    gpg: keyring `/home/pi/.gnupg/secring.gpg' created
    gpg: keyring `/home/pi/.gnupg/pubring.gpg' created
    gpg: requesting key 46925553 from hkp server pgpkeys.mit.edu
    gpg: /home/pi/.gnupg/trustdb.gpg: trustdb created
    gpg: key 46925553: public key "Debian Archive Automatic Signing Key (7.0/wheezy) " imported
    gpg: no ultimately trusted keys found
    gpg: Total number processed: 1
    gpg: imported: 1 (RSA: 1)

    gpg -a --export 8B48AD6246925553 | sudo apt-key add -

    Do the same for the other key.

    then run apt-get update again
    should be fine now.

    after that
    apt-get -t jessie-backports install ffmpeg

    Posted at 2016-07-16 14:51:58

    Reply

  • Alexander

    Hello

    I have a Raspberry PI B+ with Raspbian, and I have a camera module, with 2 servos, plugged to GPIO
    (something like that
    http://ru.aliexpress.com/item/Free-Shipping-1set-Nylon-FPV-Pan-tilt-Camera-Mount-Gimbal-2pcs-SG90-9g-Servo-Retail-Promotion/32272366054.html?spm=2114.13010608.0.116.BDrei3).

    In source code of main page (main.css) I found these strings:


    div.camera-action-button.up {
    background-position: -900% 0px;
    }

    div.camera-action-button.right {
    background-position: -1000% 0px;
    }

    div.camera-action-button.down {
    background-position: -1100% 0px;
    }

    div.camera-action-button.left {
    background-position: -1200% 0px;


    If I correctly understand, is it possible to move the camera (up,down,left,right) "from-the-box" ? If it is, where can I find the settings for that (maybe scripts/aliases/something else) ?

    Posted at 2016-09-06 04:58:07

    Reply