I have a small room, also known as a closet *cough* that I have my printer and some small computers in. Some day I plan to put a 3D printer there as well. It would be wise to set up a simple webcam, so I can check on it. You know, in case of fire and stuff. 😉

Setting up a webcam w/o a UI

It’s easy. Just plug it in. Before you do though, list your usb devices.

Now plug it in, and list them again. This will help you find the BUS and DEVICE_ID of your device.

If the device and driver is correctly initialised, you will have 1-or-more video devices in “/dev”.

To get a whole bunch of data about your device, do a verbose lsusb.

My cheap camera’s resolutions return this:

Meaning my camera supports 5 resolutions:

  • 640×480 (0) ** 4:3
  • 352×288 (1) ** 11:9
  • 320×240 (2) ** 4:3
  • 176×144 (3) ** 11:9
  • 160×120 (4) ** 4:3

My camera’s default seems to be 352×288.

Setting up Motion

Install it.

At a minimum, you need this in your config:

My config looks like this:

You can customize it to suit your needs.

Docs: http://www.lavrsen.dk/foswiki/bin/view/Motion/ConfigFileOptions

NOTE: Be careful with the documentation above! Features like webcam_port are included in the documentation, but they’re actually deprecated and no longer supported. The docs do say this, but you may not notice this unless you read ever word.

Test it by running Motion.

If you want it always running, you’ll have to set it up as a service.

Now simply visit port 8081 of the machine to view the active webcam.

Motion has some neat features. As the name suggests, it can actually detect motion. Check out the docs to learn more.

Reference: https://gist.github.com/endolith/2052778

Variant: Running it when you’re not home

Here’s a clever idea:

A script that regularly checks if a machine with your phone’s mac address can be reached on the local network:

http://superuser.com/a/512706