0.0
No commit activity in last 3 years
No release in over 3 years
A network video recorder for multiple IP cameras which uses VLC to record and organises the files according to date and camera name.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 1.7
>= 0
~> 10.0
>= 0
>= 0
~> 2.99

Runtime

 Project Readme

ElectricEye

A network video recorder for multiple IP cameras using VLC.

MLUG presentation slides on electric_eye

History

I’ve been using Zoneminder & motion and these programs are either too large for my requirements (zoneminder) or don’t work with the cameras I own (motion). What I did notice is all my cameras work through VLC with high resolution and VLC can record.

I started with VLC doing the recording up to 0.1.0 where I changed over to using ffmpeg instead.

Requirements

  • ffmpeg 3.x - recording & motion detection We are using 3.x for it’s reconnect features.
  • ruby 1.9.3 or above
  • Linux (Tested on Debian 7, Xubuntu 14.04)

Installation

Under linux install vlc xvfb & ruby

sudo apt-get install ffmpeg ruby

Add this line to your application’s Gemfile:

gem 'electric_eye'

And then execute:

$ bundle

Or install it yourself as:

$ gem install electric_eye

Configuration

Enter your cameras into the JSON config file like so

---
duration: 60
path: "/media/data/recordings"
threshold: 2
cameras:
- :name: Reception
  :url: rtsp://<user>:<passwd>@<camera's ip>/live2.sdp
- :name: Kitchen
  :url: rtsp://<user>:<passwd>@<camera's ip>/live2.sdp
- :name: Workstations
  :url: rtsp://<user>:<passwd>@<camera's ip>/live2.sdp

You should be able to view the URL through vlc before using this program.

The recordings directory will end up with these directories

/media/data/recordings/reception
/media/data/recordings/kitchen

Files will be numbered up to your wrap figure. The wrap figure determines when the recording program should start from zero again. EG: If you select you duration as 3600 seconds and a wrap figure of 168 then you get a rolling recording over a 1 week period which would be divided up into 1hr files.

reception000.mjpeg
motion-reception000.mjpeg
reception001.mjpeg
motion-reception001.mjpeg

The default is going to be 10 minute blocks, this can be overridden with the duration variable above in minutes.

Configure ffmpeg location

Add the following to your ~/.bashrc file pointing it to your ffmpeg location

export FFMPEG_BIN="/opt/ffmpeg3/bin/ffmpeg"

To compile ffmpeg 3 into there do the following

./configure --prefix=/opt/ffmpeg3
make -j4
sudo make install

Rebooting cameras

Some people reboot their cameras everynight. This does not work well with electric eye at the moment. As a work around you have to stop and start electric eye in your crontab.

Usage

First make sure you add your cameras

electric_eye -a Reception <url>

Now start the daemon to start the recording process

electric_eye -s

Start with debug messages

electric_eye -s --log-level=debug

Stop all recordings

electric_eye -k

Usage in development mode

bundle exec bin/electric_eye -h

Debug mode

bundle exec bin/electric_eye -s --log-level=debug

Start on boot

To start the service on boot (on a linux machine) add the following

Add the following to /etc/init/electric_eye

#!/usr/bin/env ruby
#
# Electric Eye
#
# chkconfig:    2345 80 20
# description:  Network Video Recorder

RBENV_DIR= '/usr/local/rbenv/shims'
APP_NAME = 'electric_eye'

case ARGV.first

when 'start'
        system "su johnsmith -c \"#{RBENV_DIR}/electric_eye -s\""

when 'stop'
        system "su johnsmith -c \"#{RBENV_DIR}/electric_eye -k\""

when 'restart'
        system "su johnsmith -c \"#{RBENV_DIR}/electric_eye -k\""
        sleep 0.5
        system "su johnsmith -c \"#{RBENV_DIR}/electric_eye -s\""

end

unless %w{start stop restart}.include? ARGV.first
        puts "Usage: #{APP_NAME} {start|stop|restart}"
        exit
end

Make executable & add to startup

cd /etc/init.d
chmod +x electric_eye
update-rc.d electric_eye defaults

Replace johnsmith with your user where you have setup your camera profiles. NOTE: I cannot get it working nicely with the root user.

Cleanup

Optional - This was needed for versions prior to 0.1.0, now it is only a precaution as ffmpeg does clean up after itself.

Cleaning up recordings. Put the following into your /etc/crontab per recording directory.

00 19	* * *	root	/usr/bin/find <directory to recordings> -type f -mtime +<days> -exec rm {} \;

Example for cleaning up reception after 60days at 7pm everynight.

00 19	* * *	root	/usr/bin/find /media/recordings/reception -type f -mtime +60 -exec rm {} \;

Contributing

  1. Fork it ( https://github.com/map7/electric_eye/fork )
  2. Create your feature branch (`git checkout -b my-new-feature`)
  3. Commit your changes (`git commit -am ‘Add some feature’`)
  4. Push to the branch (`git push origin my-new-feature`)
  5. Create a new Pull Request

  • [X] Add more testing
  • [X] Add post recording motion detection (use vlc)
  • [X] Make sure we cannot add blank cameras
  • [X] Create threshold as a variable
  • [X] Swap over to using ffmpeg
  • [X] Do post motion detection (using fmmpeg)
  • [X] Add a feature to clean up old recordings using a “period” setting (ffmpeg handles this) EG: 60 day period which could be set in the config file how many days you want to keep Then just call ‘electric_eye –remove-recordings’ within crontab This would iterate over all my cameras and remove old recordings to keep a rolling set of days.
  • [ ] Adjust motion detection to date format
    <yyyymmdd>-<hhmm>-<camera name>.mpeg
        
  • [ ] Allow motion detection to be turned on/off (default: off)
  • [ ] Threshold should be per camera or have inside & outside thresholds There is a large difference in movement between indoor office cameras and outdoor cameras. With wind and rain comes a lot of motion!