Webcam
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
Contents |
[edit] Kernel options
[edit] USB support
Make sure you have USB support in your kernel. Select OHCI HCD or UHCI HCD, depending on your motherboard's chipset. Use the lspci command to find out which one is right for you:
# emerge -av pciutils # lspci -v | grep HCI
Select the proper option in the kernel. If you are not sure, there is no harm in enabling both of them:
# genkernel --menuconfig all
| Linux Kernel Configuration: USB Support |
Device Drivers --->
USB support --->
<*> OHCI HCD support
<*> UHCI HCD (most Intel and VIA) support
|
[edit] IEEE support
Select the proper option in the kernel. If you are not sure, there is no harm in enabling both of them:
# genkernel --menuconfig all
| Linux Kernel Configuration: IEEE support |
Device Drivers --->
IEEE 1394 (FireWire) support --->
<*> IEEE 1394 (FireWire) support
<*> OHCI-1394 support
|
| Linux Kernel Configuration: IEEE video support |
Device Drivers --->
IEEE 1394 (FireWire) support --->
<*> OHCI-1394 Video support
|
Download and install the vloopback module via svn
svn co http://www.lavrsen.dk/svn/vloopback/trunk/vloopback cd vloopback make mkdir -p /lib/modules/`uname -r`/kernel/drivers/misc make install
[edit] Webcam support
Enable Video For Linux support in the kernel:
| Linux Kernel Configuration: Video For Linux |
Device Drivers --->
Multimedia devices --->
<*> Video For Linux
|
Note: if you are going to use a driver that uses the old V4L1 API (e.g. gspcav1), then you also need the "Enable Video For Linux API 1 compatible Layer" option checked. Otherwise the driver won't compile.
[edit] Webcam driver
To get information about your camera emerge usbutils and use lsusb to list usb devices. Example output:
# lsusb Bus 001 Device 002: ID 046d:08da Logitech, Inc. QuickCam Messanger
Some of the available drivers have support for more than one type of camera chipset. Some cameras are based on a known chipset, even if the model is not listed. If you can't find your model in the list, try the drivers one after the other. One of them might work.
[edit] 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. Some of these have better drivers in 3rd party packages. Continue checking this list for different drivers.
[edit] Philips
media-video/usb-pwc-re and media-video/usb-pwcx - Drivers for a variety of philips webcams called ToUcam (though not all of them).
[edit] Logitech
A few drivers are available, each supports a different set of webcams. Logitech maintains a compatibility list here. You can find your device by its product id (PID). To find out the PID run lsusb and look at the code before your device name that looks like 046d:xxxx. The last four characters are the PID.
You can also try several drivers until you find the one that works best.
- qc-usb
- qc-usb-messenger
- gspcav1 - Kernel 2.6.11 or newer
- spca5xx - Kernel 2.6.11 or older
- uvcvideo for new logitech webcams
[edit] OV51X (Sony EyeToy)
The modules are:
ov51x ov519_decomp
OV51x driver for Linux which supports JPEG decompression. Newer version available on the package's site. More info available on the driver's homepage.
[edit] Ricoh R5U870
This USB webcam is found on some Sony Vaio SZ 13" laptops and HP DV2000/DV6000/DV9000 Pavilion laptops.
Download the source and unpack it:
$ tar zxfv r5u870-0.9.1.tgz
And install (as root):
$ cd r5u870-0.9.1 $ make && make install
The driver name is r5u870
[edit] SN9C1XX
There are a couple of sn9c1xx webcams around, like the sweex minicam. There is general support in the kernel for these, but there is a more up-to-date driver in the sunrise overlay.
# layman --add sunrise # emerge sn9c1xx
Note: Do NOT forget to disable the driver in your kernel! They have the same name.
[edit] Syntek
This webcam can be found in some ASUS laptops. A driver is in development. Latest version is available from SVN:
# svn co https://syntekdriver.svn.sourceforge.net/svnroot/syntekdriver syntekdriver
Compiling requires ctags installed:
# emerge -n ctags # ln -s /usr/bin/exuberant-ctags /usr/bin/ctags
Compile and load the driver:
# cd syntekdriver/trunk/driver # make -f Makefile.standalone # insmod stk11xx.ko
[edit] IEEE camera
This is written with Unibrain Fire-i in mind, but it could be easier or trickier with other cameras. Most IEEE cameras support IIDC so we use the the opensource driver. Coriander depends on it, and we need it to export the video to v4l.
emerge coriander
or we could use dc1394_vloopback2 instead. This means that we don't need any gui to start the v4l device. You still need sys-libs/libraw1394 media-libs/libdc1394, but I am not sure if you need >=media-libs/libdc1394-2.0.0. I suggest using coriander until you have managed to use it at least once.
dc1394_vloopback2 --vloopback /dev/v4l/video0 --pipe
The default UDEV-configuration makes it a bit tricky. Remove the star after video[0-9]
| File: /etc/udev/rules.d/40-video.rules |
... # video4linux KERNEL=="video[0-9]", NAME="v4l/video%n*", SYMLINK+="%k", GROUP="video" ... |
This is important because else the video1394 is written as /dev/v4l/video0 and /dev/v4l/video1 , which the first two vloopback-devices also are called
Now you can load the modules
modprobe video1394 modprobe vloopback
Start up coriander, find a format in the services tab that works, and start v4l.
Kopete and AMSN needs a resolution of 320x240 to work with a webcam, so it's possible you want that resolution in coriander, or perhaps resized with some example apps which followed vloopback
[edit] Other
If you can't identify the make or model or your webcam, try these drivers :
- media-video/gspcav1: supports many webcams based on various chipsets. List of supported devices at http://mxhaard.free.fr/spca5xx.html
- media-video/linux-uvc: supports many webcams following the UVC specification. List of supported devices at http://linux-uvc.berlios.de . A specific viewer luvcview is available.
[edit] Loading driver
You should now have your camera's module installed (unless compiled into the kernel). 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>
Insert the module for your camera.
modprobe <module_name>
If you are using udev there should now be a device file in /dev/v4l/ called videoN (one for each webcam). If the device is not created, check dmesg for errors and useful messages. To create devices manually use :
mknod /dev/video0 c 81 0
and repeat as needed for more devices, replacing both 0's with consecutive numbers.Set permissions as needed.
[edit] Using
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.
v4l-info | less
This produces a lot of output. Scroll through the list to find the resolution.
[edit] Viewing
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, with resolution of 352x288:
$ mplayer tv:// -tv driver=v4l:width=352:height=288:device=/dev/video0 $ mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=rgb24:device=/dev/video0:noaudio -flip
If using v4l2 supporting driver (ex: linux-uvc):
$ mplayer -fps 15 tv:// -tv driver=v4l2:device=/dev/v4l/video0
(the -fps arg is needed because there is a bug in mplayer when playing back webcam using the media-video/linux-uvc driver)
Gtk1 application for viewing only. Able to manually save images on request. defaults to /dev/video so either make a symlink, or specify the correct device file on the command line using the -v option.
Modern version of gqcam.
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.
[edit] Recording / Grabbing
emerge with the encode use-flag. 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
Able to capture single frames to image files.
Proprietary viewer that uses the UVC video module to capture video and images. Works with some problematic webcams.
A cheesy program to take pictures and videos from your webcam
[edit] Video Phone
See VoIP for a list of a number of Voice over IP applications.
[edit] Streaming
emerge 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.
Specific setup for cameras based on PAC207* chipset:
| Code: Pixart camserv setup |
.... [video_v4l_qcam] path /usr/lib64/camserv/libvideo_v4l.so.0 device_path /dev/video0 port 0 color 30000 hue 30000 contrast 30000 brightness 30000 whiteness 30000 autobright 0 ... [video] video_section video_v4l_qcam width 320 height 240 maxfps 0 memhack 1 ... |
Streaming video server for Linux UVC compatible webcams with very low CPU and RAM usage.
[edit] 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.
[edit] Troubleshooting and Tweaks
[edit] "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).
[edit] Black screen
If you only see a blackscreen 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!
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:
Here is the root@localhost # 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 a n optical mouse and that would make it crash and I had to reboot the system. More about this issue can be found at Gentoo-forum and qc-usb mailing list
[edit] Odd colors
(Occures at least 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 containing
| Code: /etc/modules.d/gspca |
options gspca force_rgb=1 |
Run "update-modules force" before inserting the module.
[edit] Logitech tweaks
If using the qc-cam driver, you can improve the speed of the camera using the qcset util. You can enable double-buffering using the command qcset compat=dblbuf. The qcset util 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 correctly saved with the following command : qcset -i
[edit] Other resources
- Check the official site for the driver you are using for more info (Browse packages.gentoo.org or use eix to find the driver's homepage).
- Quickcam driver troubleshooting FAQ
[edit] Links
From Gentoo-Wiki:
From Gentoo Forums:
Others:
