Webcam server with ubuntu

  • 0
Last night I was playing around with a webcam motion detector program incidentally called motion. Very fast and lots of features. Its completely command line operated so its great for scripts. I had an idea to create a simple webcam page. Soooo I did. The great things about linux is the free spirit. A linux box can be just about anything you want it to. Hey if you want to check on the house with a webcam, a linux box and a ftp server you can! Or in my case if you want some sort of fun pointless webcam page hosted on your box you can! ect ect

To install motion on ubuntu
sudo apt-get install motion

It is important to note that motion by its almighty goodness does have a small server built into it. Check out www.lavrsen.dk/twiki/bin/view/Motion/WebcamServer if you want help with that. I am not using it since I was hoping to keep things simple and have a html page on my box. Sticking to what I know :).

I used lighthttpd to publish the webcam image. Lighthttpd is a simple, small, fast server that can allows you a server in less than 5 mins. It starts as soon as you install.
To install it run:
sudo apt-get install lighthttpd

I set motion up to save every image to the same file. So it just overwrites the old image with a new one from the cam. Editing the motion.conf in /ect/motion. I made a few adjustments.
To get motion to save the images in /var/www/ I based my .conf file on this tutorial infectedproject.wordpress.com, making a few changes:
target_dir /var/www/
snapshot_filename image
jpeg_filename image

So now (with motion having permission with sudo) motion will save the image in the www directory. All I needed to do is make a index.html and have some javascript to refresh the image.

To start motion I just run sudo motion. About it, done.

No comments:

Post a Comment