Giter Club home page Giter Club logo

electric_eye's Introduction

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.

The problem was though VLC doesn’t automate the recordings or handle the file structure nicely. This is where I started to think about creating an application which records from VLC and nicely sorts those recordings in directories by date & time.

Requirements

  • VLC - recording & motion detection
  • xvfb - Running virtual frame buffers (ie: desktops)
  • ruby
  • Linux (Tested on Debian 7)

Installation

Under linux install vlc xvfb & ruby

sudo apt-get install vlc xvfb 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/temp"
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/20150527
/media/data/recordings/kitchen/20150527

Notice the date at the end of these paths, there will be one for each day. The contents within will be recordings which are done by default every 10minutes, example;

20150527-1020-reception.mjpeg
20150527-1030-reception.mjpeg
20150527-1040-reception.mjpeg

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

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

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

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
  • [ ] Add a feature to clean up old recordings using a “period” setting 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.
  • [ ] Allow different recording programs like raspicam
  • [ ] Do inline motion detection (using activevlc)

electric_eye's People

Contributors

map7 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.