From Gentoo-en
Jump to: navigation, search

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.

Fix me: Add information for non-USB webcams. // What kinds then?

Kernel configuration

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:

Linux Kernel Configuration: Enabling video for linux
Device Drivers  --->
  Multimedia support  --->
    <*> Video For Linux

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:

emerge -av usbutils

And list the connected devices using lsusb.

# lsusb
Bus 001 Device 002: ID 046d:08da Logitech, Inc. QuickCam Messanger
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.

Note: Some drivers support more than one chipset, so it may not be clear from the config's title whether or not yours is supported. Read the options' help to be sure.


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:

Linux Kernel Configuration: USB_VIDEO_CLASS
Device Drivers  --->
  Multimedia support  --->
    [*] Video capture adapters  --->
      [*]   V4L USB devices  --->
        <*>   USB Video Class (UVC)

Linux Kernel Configuration: USB_GSPCA
Device Drivers  --->
  Multimedia support  --->
    [*] Video capture adapters  --->
      [*]   V4L USB devices  --->
        <*>   GSPCA based webcams --->
          [Select your device from the list]

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

Linux Kernel Configuration: SND_USB_AUDIO
Device Drivers  --->
  <*> Sound card support  --->
    <M>   Advanced Linux Sound Architecture  --->
       [*]   USB sound devices  ---> 
        <M>   USB Audio/MIDI driver

Specific Drivers

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

Note: TODO 2012-01: Fill in specific driver names for in-kernel drivers
Note: TODO 2012-01: Remove in-portage drivers that have been merged into the kernel and are no longer in portage
Manufacturer Model Driver Location Driver Name
Konika OV511 in-kernel TODO
Konika SE401 in-kernel TODO
Konika SN9C10x in-kernel TODO
Konika STV680 in-kernel TODO
Konika W996[87]CF in-kernel TODO
Philips ToUcam portage media-video/usb-pwc-re and media-video/usb-pwcx
Philps others TODO in-kernel TODO
Logitech New models (2010+) portage media-video/linux-uvc
Logitech Older models (2009-) portage media-video/qc-usb, media-video/qc-usb-messenger, media-video/gspcav1, media-video/spca5xx, Template:Portage has purged qc-usb... rebuilding my kernel with all modules for gspca reports that it is using gspca stv06xx & gspca main
Logitech QuickCam 4000 Pro, QuickCam Notebook Pro in-kernel TODO (Philips Webcam Driver)


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

# qcset compat=dblbuf

The qcset utility is full of interesting settings. With qcset keepsettings=1, 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:

# qcset -i

OV51X (Sony EyeToy)

For this webcam chipset, there's media-video/ov51x-jpeg in sunrise. The modules included in this are:

  • ov51x
  • ov519_decomp

Ricoh R5U870

For this webcam chipset, there's media-video/ov51x-jpeg in sunrise.


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.

# lsusb
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
Searched for using
grep -i 60c0 /usr/src/linux/Documentation/video4linux/*

which points to sn9c102.txt

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

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/ 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/; 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)


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

Note: You can skip this section if you built the drivers into the kernel.

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:

$ equery f <package name>

And insert the module for your camera.

# modprobe <module_name>

You can also add it to /etc/modules.autoload.d/linux-2.6 (if using <baselayout-2)

File: /etc/modules.autoload.d/linux-2.6

or /etc/conf.d/modules (if using >=baselayout-2)

File: /etc/conf.d/modules
modules="${modules} <module_name>"


Sometimes additional libraries may be needed for the camera to work correctly.

  • media-libs/libv4l 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.
  • app-emulation/emul-linux-x86-medialibs 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 /dev/v4l/ called video0 (or video1, video2 or video3, for that matter). If the device is not created, check dmesg for errors and useful messages.


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 media-tv/xawtv package to find out what resolution your device supports, and also detect if it's working at all:

$ v4l-info

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



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:

$ mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 15

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.


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)

LD_PRELOAD=/usr/lib/libv4l/ skype

(if you have v4l version2)

LD_PRELOAD=/usr/lib/libv4l/ skype

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

env LD_PRELOAD=/usr/lib/libv4l/ skype


env LD_PRELOAD=/usr/lib/libv4l/ skype

Note: On 64bit systems you have to preload 32bit version of v4l libraries located in /usr/lib32/libv4l/directory.
Note: Skype is using bash script to load the actual binary. This wrapper script will output an error while executed with LD_PRELOAD. To make Skype work you should put export LD_PRELOAD... into the actual bash script in /usr/bin/skype.

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)

LD_PRELOAD=/usr/lib32/libv4l/ /opt/bin/skype

(if you have v4l version2)

LD_PRELOAD=/usr/lib32/libv4l/ /opt/bin/skype

&& for my launchers....

env LD_PRELOAD=/usr/lib32/libv4l/ /opt/bin/skype


env LD_PRELOAD=/usr/lib32/libv4l/ /opt/bin/skype
(last code line tested and functional on loopback and net: thanks for taking time out of your busy day to verify 'sinofyours')

Other packages

You might need to install media-libs/libv4l and run "LD_PRELOAD=/usr/lib/libv4l/ 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.




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

$ mencoder tv:// -tv driver=v4l:width=<width>:height=<height>:device=/dev/video0 -nosound -ovc lavc -o <filename>.avi

Recording with sound, one channel 64kbit mp3:

$ mencoder tv:// -tv driver=v4l:width=<width>:height=<height>:device=/dev/video0:forceaudio:adevice=/dev/dsp -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o <filename>.avi

unmute ALSA capture

$ alsamixer
and press F4

List all soundcards and digital audio devices

$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Intel [HDA Intel], device 0... 

card 1: U0x46d0x9c1 [USB Device 0x46d:0x9c1], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

change "adevice=/dev/dsp"

mencoder tv:// ... adevice=hw.1:alsa

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.


You can also publish the video stream via ethernet.


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.


Streaming video server.

Note: If you know the following settings aren't needed, or can minimize this list, please do.

Specific setup for cameras based on PAC207* chipset:

File: /usr/share/camserv/camserv.cfg
path            /usr/lib64/camserv/
device_path     /dev/video0
port            0
color           30000
hue             30000
contrast        30000
brightness      30000
whiteness       30000
autobright      0

video_section           video_v4l_qcam
width                   320
height                  240
maxfps                  0
memhack                 1

Other packages

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


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.

  • media-video/motion - Motion detector.
  • www-misc/zoneminder - Allows you to capture, analyze, record and monitor any cameras attached to your system through a web interface.
  • media-video/motiontrack - 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:

# lsusb
Bus 004 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 002: ID 046d:c50e Logitech, Inc. MX-1000 Cordless Mouse Receiver
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 002: ID 046d:0870 Logitech, Inc. QuickCam Express
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000

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:

File: /etc/modules.d/gspca
options gspca force_rgb=1

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

Mplayer refuses to work with your webcamera or shows some kind of a green noise

Emerge media-libs/libv4l and try running:

$ LD_PRELOAD=/usr/lib/libv4l/ mplayer tv:// -tv driver=v4l:device=/dev/video0

If that works, you will probably want to go back and read section Webcam#Libraries /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.


Drivers for some Philips ToUcam webcams can be found in media-video/usb-pwc-re and media-video/usb-pwcx.


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:

Note: Some old Logitech webcams only work with the Philips driver (e.g. Logitech QuickCam 4000 Pro, Logitech QuickCam Notebook Pro).

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


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|