On a tight budget, but want to monitor your business, home, or maybe just your baby's room? Using Linux and the webcam_server project, you can set up a poor man's monitoring solution quickly and easily.
Setting up a system to broadcast pics or video from a Webcam may sound like quite a challenge. Believe it or not, it's really fairly easy to get up and running. All you need is a Linux machine (In this case, Ubuntu), a Web server (Apache), a webcam, and a little tool called webcam_server. Once you are done, you can point that Webcam to your target and then view it from within a browser. If your machine housing the server is available to the outside world, you can share that link or view it from anywhere you have access to a Web browser, including your mobile device!
Let's get this up and running.
In case there is no Web server installed and running, let's install that. This is simple to do. In fact, a fully-functioning LAMP (Linux Apache MySQL PHP) server can be installed with a single command. Although the LAMP server will be far more power than necessary for the Webcam server, it's always nice to have it running in case more features are required later on.
To install the LAMP server, open up a terminal window and issue the command:
sudo tasksel. From the resulting window (see Figure 1) use the arrow keys to move the cursor down and select LAMP. Now hit the Tab key to move to the OK "button". From this point, all that is necessary to complete the installation is answer a few questions (such as the MySQL admin user and password) and your LAMP server will be up and running. You may need to install
tasksel first. (
sudo apt-get install tasksel)
In order to test the Web server, open up a browser and point it to http://localhost. The famous "It works!" notification should appear. If an error displays that the browser can not connect to localhost, it could be a sign that Apache is not running. To start Apache, run
sudo /etc/init.d/apache2 start. Once the server has started, attempt to view the page again.
In order to install webcam_server, download the .deb file from one of the mirrors listed on the webcam_server packages page. Once that file has been downloaded, open up a terminal window and follow these directions:
- Change into the directory the webcam_server file was saved to.
Issue the command
sudo dpkg -i webcam_server_XXX.debWhere XXX is the release number.
- Type your sudo password and hit Enter.
- Allow the installation to complete.
The Webcam server is ready to be started, but before this is done, make sure a Webcam is connected and working. Once the Webcam has been recognized (This can be checked with a tool like Cheese Webcam Booth) start the server with the command
webcam-server. That command will start the server without any options.
If you need to have the webcam-server start at boot (or to start with specific options) a script will be necessary. You have two options, create a new script, or take the easy way out. The easy way is to download this file and save it to
/etc/init.d. (In order to copy or move the file use sudo to gain the necessary privileges.) Make sure to adjust any of the settings, in the downloaded file, necessary to fit any specific needs not addressed in the default (The defaults should work just fine.) After the file has been moved, give the file executable rights with the command
chmod +x /etc/init.d/webcam-server and then add the script to the init defaults with the command
sudo update-rc.d webcam-server defaults.
If the webcam-server script is being used as a startup service, it will need to be started by issuing the command
sudo /etc/init.d/webcam-server start. If the output "Starting webcam-server: Started!" is displayed, congratulations, the Webcam server is up and running. Now, we have to make Apache aware of this.
When the webcam-server package was installed all of the necessary files were placed in
/usr/share/doc/webcam-server/applet. Those files need to be moved to the document root of the Apache server with the command
sudo cp /usr/share/doc/webcam-server/applet/* /var/www/. Now open up the file
/var/www/webcam.html (with a text editor) and edit it to fit specific needs. The values that might need personalization are:
- Title: This is the title page for the Webcam page served up.
- URL value: This is the address of the Webcam server. By default this is set to localhost:8888. If this is not changed, the only address the Webcam server will be able to connect to is localhost. If an IP address or domain is used, make sure the change is reflected in this entry.
- FPS value: This is the Frame Per Second value. By default it is set to 1 second.
- Width value: This is the width of the java applet in the browser window.
- Height: This is the height of the java applet in the browser window.
Save that file and it's time to start viewing.
Viewing the Webcam Server
In order to view the new Webcam server, open up a browser and point it to the address configured in
/var/www/webcam.html. So, by default, open up http://ADDRESS_TO_SERVER/webcam.html and what is being seen by the Webcam should be displayed, updated at the frames per second configured in
webcam.html (see Figure 2).
My cheesy grin shows our Webcam server is a GO!
There are plenty of applications for this simple to set up Webcam server. Whether it be for security, viewing traffic, or viewing your infant in its crib, this simple system will serve as an amazingly flexible and reliable solution.