Question 4.5: Making a Webcam Server You want to set up a Raspberry Pi as ......

Making a Webcam Server

You want to set up a Raspberry Pi as a webcam server.

Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

Download the motion software. This will allow you to set up a Raspberry Pi with a USB webcam connected to it so you can connect to a web page and view the webcam.

To install the software, enter the following command in a Terminal window:

$ sudo apt-get install motion

Plug in your USB webcam and type lsusb to see if the webcam is connected:

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 3538:0059 Power Quotient International Co., Ltd
Bus 001 Device 006: ID eb1a:299f eMPIA Technology, Inc.

If it isn’t obvious, try disconnecting it, run the command again, and see if one of the entries vanishes from the list. In this case, the final entry in the list is for the webcam.

There are now a few configuration changes that you need to make. First, edit the file /etc/motion/motion.conf using the command:

$ sudo nano /etc/motion/motion.conf

This is quite a big configuration file. Right near the top of the file, you will find the line daemon off; change this to be daemon on.

The other change is much further down the file. You need to change webcam_localhost = on to webcam_localhost = off.

There is one other file that you need to change. Enter the command:

$ sudo nano /etc/default/motion

Change start_motion_daemon=no to start_motion_daemon=yes.

To get the web service running, issue the command:

$ sudo service motion start

You should now be able to open your web browser and view the webcam. To do this, you will need to know the IP address of your Raspberry Pi (Recipe 2.2).

From another computer on the same network, open a browser and go to the URL http://192.168.1.16:8081/. You will need to change the URL to match the IP address of your Raspberry Pi, but you need to keep the :8081 port number on the end of the URL.

If all goes well, you should see something like Figure 4-7.

Discussion

The motion software is actually really powerful; there are many other settings you can tweak to change how your webcam works.

By default, the webcam will be viewable only from within your network. If you want your webcam to be visible to the whole Internet, you need to set up port forwarding on your home hub. This will require you to log in to the admin console for the hub, look for the port forwarding option, and enable it for port 8081 for the IP address of the Raspberry Pi.

You will then be able to view the webcam using the external IP address allocated by your ISP. This is usually shown on the from page of your admin console. But beware: unless you pay your ISP for a static IP address, this IP address is likely to change every time you restart your home hub modem.

See Also

There is thorough documentation on the motion website.

The Raspberry Pi has a plug-in camera module (Figure 1-18). At the time of writing, this is not compatible with motion, but it may be by the time you are reading this.

See also Recipe 3.16 for information on using apt-get.

4.7

Related Answered Questions

Question: 4.8

Verified Answer:

Download and run Open Arena (Figure 4-10) from the...
Question: 4.7

Verified Answer:

Mojang, the original developers of Minecraft, have...
Question: 4.11

Verified Answer:

Install the VLC media player by running the follow...
Question: 4.6

Verified Answer:

There are a number of emulators around for old gam...
Question: 4.10

Verified Answer:

Download and run the GNU image manipulation progra...
Question: 4.4

Verified Answer:

The Pi Store is the Raspberry Pi equivalent of App...
Question: 4.3

Verified Answer:

You can use a number of browsers on the Raspberry ...
Question: 4.2

Verified Answer:

Raspberry Pi is, after all, a Linux computer, so t...
Question: 4.1

Verified Answer:

A Raspberry Pi actually makes a pretty good media ...