/webcam

Primary LanguageShell

This is a collection of scripts that create a web page to view pictures and movies collected by a camera.

How to use the WebCam scripts:

0) Download and save the scripts and other files to a local directory (http://itworks.hu)

1) Get a source of images, such as a camera.  WebCam can collect images in any of four ways:
   A) The GPhoto2 program
   B) The Capture program.  To install on ubuntu:
      i. apt-get install libusb-dev pkg-config libgtk2.0-dev libreadline-dev
      ii. download, compile, and install libptp2 from http://libptp.sourceforge.net:
          a. download and untar the tarball   
          b. ./configure
          c. make
          d. make install
          e. ldconfig
      iii. download, compile, and install capture from http://capture.sourceforge.net
          a. download and untar
          b. make
          c. make install
   C) from any source that puts new pictures into a directory.  I use the http://www.airlink101.com/products/aic250.php
   D) using ffmpeg/avconv to grab image from v4l2 streams

2) Set up a webserver with PHP.  On Ubuntu:

  apt-get install lighttpd php5-cgi
  lighty-enable-mod fastcgi
  /etc/init.d/lighttpd force-reload

3) Copy the php, png, and txt files from the tarball's web directory to the webserver's target directory.  
   The user that runs the scripts should have permission to write to a directory on the webserver.  The directory structure will be:

/
 index.php (provided in the package)
 index_day.php (provided in the package)
 index_day_video.php (provided in the package)
 index_month.php (provided in the package)
 title.txt (provided in the package - change it's content to your liking)
 basic.css (provided in the package)
 webcam/
	full.mp4
	full.ogv
	YYYY/
	    YYYY-MM.mp4
	    YYYY-MM.ogv
	    YYYY-MM_low.mp4
	    YYYY-MM_low.ogv
	    YYYY-MM_thumb.jpg
	    YYYY-MM_thumb_dated.jpg
	    MM/
		YYYY-MM-DD_low.mp4
		YYYY-MM-DD_low.ogv
		YYYY-MM-DD.mp4
		YYYY-MM-DD.ogv
		YYYY-MM-DD_strip.jpg
		YYYY-MM-DD_thumb_dated.jpg
		YYYY-MM-DD_thumb.jpg
		YYYY-MM_thumb_dated.jpg
		YYYY-MM_thumb.jpg
		DD/
		   HH:MM:SS.jpg
		   HH:MM:SS_thumb.jpg

All files and directories in this structure are automatically created by the scripts unless otherwise noted.
index.php should be customized by changing "webcam" to whatever directory name you are using.

4) Install avconv and other prerequisites:
On ubuntu, 

  sudo apt-get install avconv libavcodec-unstripped-52 libavutil-unstripped-49 normalize-audio libsox-fmt-all lame sox ttf-dejavu-extra

7) Add the capture.sh script regularly, e.g., every minute between 5 and 21. Use the flags to customize For example, 
   put this in your cron:

* 5-21  *   *   *     /usr/share/webcam/capture.sh -c /bin/capture -q /bin/avconv

7a) To capture an image more frequently than once per minute in cron, which only runs one per minute, use the -w flag.  
    This will capture an image every W seconds throughout each minute.

8) Add the daily_movie.sh script to run every hour when capture might take place.  for example:

3 6-22  *   *   *     /usr/share/webcam/daily_movie.sh -z 640x480 -o "" -m "your_music_dir" -f 15 -i 1 -1 -2 -3 -q

9) Add the monthly_movie.sh script to run once per day, right after midnight.  for example:

30 2  *   *   *     /opt/webcam/monthly_movie.sh -z640x480 -o "" -m "your_music_dir" -f 10 -i 1 -1 -q

10) Add the full_movie.sh script to run once per day, after the monthly movie is created.  for example:

35 2  *   *   *     /opt/webcam/full_movie.sh -z640x480 -m "your_music_dir" -f 30 -q
-----------------------------------------------------------------------------------------------------------------------
This repository is licenced under please mention me licence. So if you're
planning to use, reuse or even abuse it, do mention it's author. And please 
add a comment to the relevant blog post on my blog http://itworks.hu, so I
would keep up the effort.