Webcams in Linux, Part 1

Webcams are everywhere these days: they're standard on a lot of laptops, LCD monitors are starting to incorporate them, and decent standalone USB webcams can be had for less than $40. In this two-part series we'll set up a Webcam on Linux, and then use it to perform a number of amazing and fun tasks.

Webcams are everywhere these days: they're standard on a lot of laptops, LCD monitors are starting to incorporate them, and decent standalone USB webcams can be had for less than $40. In this two-part series we'll set up a Webcam on Linux, and then use it to perform a number of amazing and fun tasks.

You won't get television-quality video with an inexpensive Webcam; you'll get small fuzzy herky-jerky. But it's acceptable herky-jerky. A low-end Webcam typically supports 15 frames per second at 320 x 240 pixels. For comparison, movies run at 24 fps. Spending a bit more money will get you some silky smooth video. One example is the Logitech QuickCam Pro 9000. For $99.99 you get a built-in microphone, autofocus, good-quality optics, 30 frames per second, and high-quality video capture size up to 960 x 720 pixels.

It takes more than a good Webcam to get good performance. You should have a modern PC, dual-core if possible, because all that video processing takes some horsepower. A typical minimum bandwidth requirement for smooth video is 256 kbps both ways.

Linux support for Webcams is pretty good, thanks to a number of hardy Linux developers. As usual, the vendors themselves have no interest in supporting anything but MS Windows. Michel Xhaard, with little help, figured out how to support over 250 different Webcams from a common base driver. This base driver, GSPCA/SPCA5xx, is now included in Debian and its offspring. The good folks at Linux UVC driver and tools support a different set of Webcams, and the nice people at Philips USB Webcam Driver for Linux keep it maintained, even though it supports mostly older devices.

https://o1.qnsr.com/log/p.gif?;n=203;c=204657336;s=9478;x=7936;f=201808231619130;u=j;z=TIMESTAMP;a=20403940;e=i
The bad news is "pretty good" means you may still have to compile and manually install drivers, and perform other manual tweakages. Just like the good old days.

If you're still shopping, first find out what works best on your own particular Linux distribution. Mandriva is probably the Webcam-friendliest Linux. Logitech Webcams are the most popular, but not all of them have native Linux drivers.

If you're using an inherited Webcam, you may get lucky and it will work as soon as you connect it. Here is the short way:

Install Camorama

Install both v4l and v4l2 (Video for Linux)

Connect Webcam

Start Camorama

Wave to yourself

If Camorama doesn't work, try the Testbed account in Kopete. Figure 1 shows me and my best friend in Kopete.

Figure 1 shows a problem with integrated Webcams: you have to adjust your whole screen to frame your image. I was sitting tall, too.

Camorama does not support v4l2, which is unfortunate because v4l2 has a lot of improvements and bugfixes over version 1. The Ubuntu forums are full of users asking what the "could not connect to video device (dev/video0)" error message means when they try to use Camorama. One reason is they're using a driver that requires v4l2, or they don't have v4l installed.

On a modern Linux distribution, udev and HAL should detect the Webcam, create /dev/video0 with the correct permissions, owner root and group video, and load the correct kernel module. If you are not in the "video" group, add yourself, then logout and log back in. Run the id command with no options to make sure. Run lsmod to verify that the correct kernel module loaded.

My own Webcam is built into a Viewsonic VX2255 LCD monitor. This monitor also has a built-in microphone. The Webcam requires a USB cable, so I connected it and ran these commands to see if Kubuntu Gutsy recognized it:

That reveals that this Webcam is supported by the uvcvideo kernel module, and if I need to do a Web search for more information I have the Super Secret Webcam Name and Number. Take that, Viewsonic! Remember that dmesg updates as you plugin or remove peripherals, so its most recent output always shows the latest activity. If dmesg doesn't see a device, then the kernel does not see it, and you're probably out of luck.

Come back next week and we'll get cracking on some fun stuff, such as spying on people and displaying ourselves on the Internet. Please visit Resources for all manner of helpful links.

Advertiser Disclosure:
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.