Webcam

Webcams are live video capturing devices. They are usually connected using USB. If it is an ethernet or wifi webcam, you won't need any drivers, but just a browser.

USB support
Before continuing, make sure you've got USB up and running.

Webcam support
Video devices are connected using the Video4Linux frameworks. Enable support in your kernel:

Webcam driver
Now we'll need to identify your webcam's chipset and configure in-kernel support, or find an external module. Install sys-apps/usbutils:

And list the connected devices using lsusb.

The above output line will be just one of many, and is an example webcam. You may have a completely different line. If your webcam doesn't show up, run Also make sure you have booted with a kernel which supports your USB chipset. If you have, check dmesg's output while plugging in a webcam and see if anything happens.

Now that you (hopefully) know your webcam's chipset, open up your kernel configuration and see if there's in-kernel support for it. If there is, you can just go ahead and enable it, recompile and install your kernel.

Generic
Most webcams on the market today are supported by the two generic drivers below. Also, if you can't identify the make or model or your webcam, the following kernel drivers may help you out after all:

If your web camera is aggregated with microphone, you will need the USB sound device:

Specific Drivers
Some webcams, especially older ones, will need specific drivers. Some are in-kernel, others are available as external packages.

Tweaks
If using the qc-cam driver, you can improve the speed of the camera using the qcset utility. You can enable double-buffering using:

The qcset utility is full of interesting settings. With, the settings will be stored into the webcam and you will be able to control brightness, contrast, etc. You can check that your settings have been restored correctly by runing:

OV51X (Sony EyeToy)
For this webcam chipset, there's in sunrise. The modules included in this are:
 * ov51x
 * ov519_decomp

Ricoh R5U870
For this webcam chipset, there's in sunrise.

SN9C1XX
MSI StarCam 370i (WebCam) is an example of one of these cameras

This general process could probably be applied to any webcam.

Use lsusb (sys-apps/usbutils) to find the manufacturer and device codes.

pearcely:~ Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 007 Device 002: ID 0c45:60c0 Microdia PC Camera with Mic (SN9C105) Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 006 Device 003: ID 413c:2010 Dell Computer Corp. Bus 006 Device 002: ID 413c:1003 Dell Computer Corp. Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 006 Device 004: ID 413c:3010 Dell Computer Corp. Optical Wheel Mouse pearcely:~ Searched for using grep -i 60c0 /usr/src/linux/Documentation/video4linux/* which points to sn9c102.txt
 * 1) lsusb

Followed instructions on configuring that module. You may also like to enable the v4l compatability layer in the kernel.

Add sn9c102 to /etc/modules.autoload.d/kernel-2.6

Make sure both 'v4l' and 'v4l2' in USE setting in /etc/make.conf

Do emerge --newuse --verbose --with-bdeps y --update --deep world

Reboot, just to be sure you have not borked something (for example, emerge nvidia-drivers or virtualbox-modules)

Tested using mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 Alternatively, you could try env LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 if the first doesn't work.

Getting it working with ZoneMinder
Re-emerged ZoneMinder, just in case (temporarily changing my /etc/make.conf MAKEOPTS to '-j1' because zoneminder does not build well with parallel builds, apparently)

CPPFLAGS="-D__STDC_CONSTANT_MACROS" emerge -av www-misc/zoneminder

I had to put LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so; export LD_PRELOAD in my apache2 /etc/conf.d/apache2 I had tried simply putting it in the zoneminder service startup script, to no avail.

Restarted apache and browsed to the zoneminder page.

Now, you should be able to see the webcam stream! (configured as 320x240 PAL RGB24)

Syntek
This webcam can be found in some ASUS laptops. It is not yet available in any tree, so go to the Web site and install it manually.

Loading a driver
You should now have your camera's module installed. To find the module's name of the module use the equery tool from gentoolkit with the name of the driver's package:

And insert the module for your camera.

You can also add it to (if using =baselayout-2)

Libraries
Sometimes additional libraries may be needed for the camera to work correctly.
 * fixes the compatibility issue between v4l and v4l2, and also converts from different pixel formats used by cameras to a standard understood by most applications. If the driver recognizes your camera but the picture appears as noise or seriously distorted (while the resolution setting are alright) then you should try to emerge this library and follow the instructions given in ebuild messages.
 * contains 32bit version of the above libraries. These are required on 64bit systems running 32bit binaries like Skype

Using your webcam
If you are using udev there should now be a device file in called video0 (or video1, video2 or video3, for that matter). If the device is not created, check dmesg for errors and useful messages.

Testing
Some applications require the v4l and/or v4l2 use-flags to take advantage of your webcam. Some applications can't detect the camera's resolution. You can use the v4l-info tool from the package to find out what resolution your device supports, and also detect if it's working at all:

This produces a lot of output. Scroll through the list to find the resolution.

Mplayer
Versatile media player. Can play from many sources, including video devices. Specify the width and height manually, depending on what your camera supports. For example, a v4l2 driven webcam with a resolution of 640x480 and 15 frames per second:

Anononymous note: Remember to have mplayer compiled with dvb and v4l and/or v4l2. This can be done by adding media-video/mplayer dvb v4l v4l2 on /etc/portage/package.use.

Skype
If Skype doesn't display your webcam but another programs do like Cheese or MPlayer, it's because Skype doesn't load v4l. So you'll have to do it manually each time you load Skype:

(if you have v4l version1)

(if you have v4l version2)

To integrate the command in the launcher of gnome-panel, the "env" will have to be added before ld_preload, so we'll have:

or

i found the previous section personally to be ULTRA ugly.... looking around it was a problem of skype requiring 32 libs......  for me....

(if you have v4l version1)

(if you have v4l version2)

&& for my launchers....

or (last code line tested and functional on loopback and net: thanks for taking time out of your busy day to verify 'sinofyours')

Other packages

 * - Simple and effective.
 * - Viewer for use with the spca5xx or gspcav1 driver.
 * - One of the oldest video viewers for linux. Relatively old graphical interface. Gets the job done.
 * - Rewrite of xawtv with added features.
 * - Gnome webcam application

You might need to install media-libs/libv4l and run "LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so application" in order to make some programs which only work with v4l1 work on v4l2. Remember also to emerge those applications with the v4l v4l2 flag.



mplayer
Make sure mplayer's encode use-flag is enabled. Example usage for recording continuous video:

Recording with sound, one channel 64kbit mp3:

unmute ALSA capture  and press F4

List all soundcards and digital audio devices

change "adevice=/dev/dsp"

Other packages

 * media-video/w3cam - Obsolete, no longer in Portage. Was able to capture single frames and create image files. Could be used to make photos.

Streaming
You can also publish the video stream via ethernet.

vlc
Install with the stream, httpd and v4l use-flags. Run the GUI client and open a capture device. Make sure the correct device file is selected, and turn on streaming at the bottom of the dialog. In the stream settings, enable http and select at least a video codec. In the preferences window you may also set a user and password for accessing the stream. The "open capture dialog" and "stream settings" will also show you the options you need to perform all this from the command line.

camserv
Streaming video server.

Specific setup for cameras based on PAC207* chipset:

Other packages

 * UVC Streamer - Streaming video server for Linux UVC compatible webcams with very low CPU and RAM usage.

Monitoring
Even though this is not a good idea due to usb bandwidth, this is possible with 1 or 2 cameras, or with multiple usb bus cards.


 * - Motion detector.
 * - Allows you to capture, analyze, record and monitor any cameras attached to your system through a web interface.
 * - Not strictly a webcam application, but can be used in combination with a frame grabber to compare images and check for motion.

"Input/output error" or "No space left on device"
This can be due to USB bandwidth being exceeded. Try connecting the device to a different USB port, preferably on another bus (usually not the connector right next to it). Also see this post on the Gentoo forums.

v4l2: open /dev/video0: No such file or directory
this is a possible solution (and probably not the root of your problems)

as root (or sudo) run

mknod /dev/video0 c 81 0

Black screen
If you only see a black screen using xawtv or gqcam and then the application crashes and the kernel log gives you something like this: May 18 14:47:37 [kernel] ohci_hcd 0000:00:03.1: leak ed ef3340c0 (#81) state 2 May 18 14:48:00 [kernel] quickcam: Control URB error -2 May 18 14:48:00 [kernel] Unable to handle kernel paging request at virtual address 02000040 ... May 18 14:48:00 [kernel] <1>Fixing recursive fault but reboot is needed! Then you have to make sure the webcam is connected to a usb-hub (BUS) that does not have any other devices attached to it. You can investigate that by issuing lsusb as root:

If lsusb hangs you need to reboot first (look at the line reboot is needed! in the kernel log). Here you see that Bus 002 only has the Logitech webcam connected to it. Before that it was connected to Bus 003 where there is already an optical mouse and that would make it crash, so you may have to reboot the system. More about this issue can be found at Gentoo-forum and qc-usb mailing list.

Odd colors
Known to occur on logitech quickcam messenger 046d:08da. If using the gspca driver, try adding the parameter force_rgb=1. Either using modprobe manually, or add a file in /etc/modules.d:

Run "update-modules force" before inserting the module.

Mplayer refuses to work with your webcamera or shows some kind of a green noise
Emerge and try running:

If that works, you will probably want to go back and read section Webcam

Webcam /pre>}}

Konica, OV511, SE401, SN9C10x, STV680, W996[87]CF, some Philips webcams
Drivers for cameras based on these chip-sets can be found in the kernel.

Philips
Drivers for some Philips ToUcam webcams can be found in and.

Logitech
Some drivers are available in-kernel, but there are also some packages. A few drivers are available. Each supports a different set of webcams. Try them all until you find the one that works best:
 * - for new logitech webcams
 * - for new logitech webcams
 * - for new logitech webcams
 * - for new logitech webcams
 * - for new logitech webcams

These packages are removed from portage, drivers are available in-kernel since Oct 8, 2009.

Tweaks
If using the qc-cam driver, you can improve the speed of the camera using the qcset utility. You can enable double-buffering using: {{Root|