Difference between revisions of "Set up a Webcam with Linux"

From Linuxintro
imported>ThorstenStaerk
 
(158 intermediate revisions by 18 users not shown)
Line 1: Line 1:
You just want to see a video stream from your webcam to verify it is working correctly, right? Then this article is for you.
+
{{#externalredirect: https://www.bingehacking.net/2022/09/set-up-webcam-with-linux.html}}
  
= What to buy =
+
<metadesc>Here is how you set up your webcam with Linux, capture videos and images, do VoIP calls and automate recording. Tested with SUSE Linux, Ubuntu and Debian.</metadesc>
Buy the Logitech Quickcam messenger and install SUSE Linux 11. Other webcams and distributions may work as well, but this article wants to give an exact description about one installation that surely works.
 
  
= What to call =
+
 
Install gqcam
+
 
 +
<b>Hi Friends,
 +
 
 +
I am moving this site to https://www.bingehacking.net/2022/09/set-up-webcam-with-linux.html</b>
 +
This way, you will be able to leave comments and likes, and I will not need to take care for running the wiki software any longer.
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
[[File:Set-up-a-webcam.png|thumb|A capture from a webcam in the program Cheese]]
 +
You want to set up your webcam with Linux, see a video stream from it and learn which applications you can use with it, right? Then this article is for you.
 +
 
 +
= Try it =
 +
First let's try if it works out of the box, so, connect your webcam (if it's not inbuilt), [[open a terminal]] and start the application '''''cheese''''':
 +
cheese
 +
 
 +
This should switch on your webcam and you should see what it's recording.
 +
 
 +
Ok, you are reading on, so there is still something left, maybe:
 +
* terminal says "command not found", you need to install cheese. Read on at [[#Install_cheese|Install Cheese]].
 +
* cheese does not show the camera's content -> read on at [[#Check the Setup|Check the Setup]].
 +
* you want to [[#record_a_video]] with your webcam.
 +
 
 +
= Install cheese =
 +
To install cheese, you need to know your distribution. Here is how to [[find out your distribution]].
 +
* for Debian, Raspbian, Ubuntu, Kubuntu, Flubuntu, Xubuntu, GEUbuntu, Edubuntu, ...:
 +
sudo apt-get install cheese
 +
* for SUSE:
 +
yast -i cheese
 +
 
 +
= Check the Setup =
 +
If cheese starts, but does not find a webcam, you need to dig deeper.
 +
* [[open a console]] and list your video4linux devices:
 +
 
 +
ls -ltr /dev/video*
 +
 
 +
* you will find an output like this:
 +
 
 +
crw-rw----+ 1 root video 81, 0 Nov 11 09:06 /dev/video0
 +
 
 +
In this example your webcam device is named ''/dev/video0''. If you have no /dev/video file, read [[#Troubleshooting]]. If you have several video4linux devices, for example a [[tv card]] your webcam may show up as /dev/video1 or whatever. But the time (in this case Nov 11 09:06) will be the time when you plugged it in.
 +
 
 +
You can also test your webcam the following ways:
 +
* if you have [[vlc]] installed you can start it and choose Media -> Open Capture Device -> Video device name = ''/dev/video0'' -> Play
 +
* if you have mplayer installed you can use the command
 +
 
 +
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 30
 +
 
 +
= Troubleshooting =
 +
Troubleshooting heavily depends on the distribution and version you are using. If you have done cabling correctly and a device file /dev/video* does not appear, your kernel probably does not know the hardware. In this case you may have to install the device driver separately because it may not be part of the kernel.
 +
 
 +
== SUSE Linux 11.0 and earlier ==
 +
This has been tested with SUSE Linux 11.0 x64 but should work with any earlier SUSE version. You will need to log in as user root.
 +
To find out what driver you need, [[open a console]] and call
 +
[[hwinfo]] --usb
 +
If a Logitech Quickcam Messenger is plugged in the answer will be like:
 +
 
 +
06: USB 00.2: 0000 Unclassified device
 +
  [Created at usb.122]               
 +
  UDI: /org/freedesktop/Hal/devices/usb_device_46d_8da_noserial_if2
 +
  Unique ID: Eopr.vE+cdFBwClB                                     
 +
  Parent ID: uIhY.uOe2OKugI8D                                     
 +
  SysFS ID: /devices/pci0000:00/0000:00:1a.2/usb3/3-1/3-1:1.2     
 +
  SysFS BusID: 3-1:1.2                                           
 +
  Hardware Class: unknown                                         
 +
  Model: "Logitech QuickCam Messanger"                           
 +
  Hotplug: USB                                                   
 +
  Vendor: usb 0x046d "Logitech, Inc."                             
 +
  Device: usb 0x08da "QuickCam Messanger"                         
 +
  Revision: "1.00"                                               
 +
  Driver: "snd-usb-audio"                                         
 +
  Driver Modules: "snd_usb_audio"                                 
 +
  Speed: 12 Mbps                                                 
 +
  Module Alias: "usb:v046Dp08DAd0100dc00dsc00dp00ic01isc02ip00"   
 +
  Driver Info #0:                                                 
 +
    Driver Status: quickcam_messenger is active                   
 +
    '''Driver Activation Cmd: "modprobe quickcam_messenger"'''
 +
  Driver Info #1:                                                 
 +
    Driver Status: gspca is active                               
 +
    Driver Activation Cmd: "modprobe gspca"
 +
  Config Status: cfg=new, avail=yes, need=no, active=unknown     
 +
  Attached to: #20 (Hub)
 +
 
 +
This means you can install and load the webcam driver like this:
 +
yast -i gspcav-kmp-default
 +
modprobe gspca
 +
Now you should see a video device:
 +
ls /dev/video*
 +
/dev/video  /dev/video0
 +
That means you can install and start your webcam-viewer-software. We choose gqcam:
 
  yast -i gqcam
 
  yast -i gqcam
call gqcam
 
 
  gqcam
 
  gqcam
result:
+
It works. You see a video what from what is going on in front of your webcam.
/dev/video: No such file or directory
 
=> very poor! It does not even give a recommendation what to do. But we do: Load the webcam driver
 
modprobe gspca
 
Start gqcam again. Now it works. You see a video what from what is going on in front of your webcam.
 
  
= How to use it =
+
== Ubuntu ==
* to capture video streams, use the software ''streamer''.
+
This has been tested with Ubuntu 8.10 x32 but should work with any Ubuntu version.
* to do video conferences, use ''ekiga''.
+
Find out the driver activation command of your webcam. For this, first install the software '''hwinfo'''. [[Open a console]] and type:
* to do IP phoning, use ''skype''.
+
sudo apt-get [[install]] [[hwinfo]]
* to watch your camera's input, use ''gqcam''.
+
Then call hwinfo:
 +
hwinfo --usb
 +
If a Logitech Quickcam Messenger is plugged in the response will be like:
 +
<source highlight=20>
 +
04: USB 00.2: 0000 Unclassified device
 +
  [Created at usb.122]
 +
  UDI: /org/freedesktop/Hal/devices/usb_device_46d_8da_noserial_if2
 +
  Unique ID: 4ajv.vE+cdFBwClB
 +
  Parent ID: k4bc._Mkd+LmXb03
 +
  SysFS ID: /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb1/1-1/1-1:1.2
 +
  SysFS BusID: 1-1:1.2
 +
  Hardware Class: unknown
 +
  Model: "Logitech QuickCam Messanger"
 +
  Hotplug: USB
 +
  Vendor: usb 0x046d "Logitech, Inc."
 +
  Device: usb 0x08da "QuickCam Messanger"
 +
  Revision: "1.00"
 +
  Driver: "snd-usb-audio"
 +
  Driver Modules: "snd_usb_audio"
 +
  Speed: 12 Mbps
 +
  Module Alias: "usb:v046Dp08DAd0100dc00dsc00dp00ic01isc02ip00"
 +
  Driver Info #0:
 +
    Driver Status: gspca_zc3xx is active
 +
    Driver Activation Cmd: "modprobe gspca_zc3xx"
 +
  Config Status: cfg=new, avail=yes, need=no, active=unknown
 +
  Attached to: #8 (Hub)</source>
 +
Activate the driver:
 +
sudo modprobe gspca_zc3xx
 +
Now you should be able to see the video device:
 +
[[ls]] /dev/video*
 +
/dev/video0
 +
You can now test your webcam using the software cheese:
 +
sudo apt-get install cheese
 +
cheese
  
= If you have another webcam =
+
== Other webcams ==
 
If you have another webcam, try the above nevertheless. If it does not work, exchange the driver gspca against uvcvideo:
 
If you have another webcam, try the above nevertheless. If it does not work, exchange the driver gspca against uvcvideo:
  zast -i uvcvideo_kmp_default
+
  yast -i uvcvideo_kmp_default
 
  modprobe uvcvideo
 
  modprobe uvcvideo
 
and start gqcam again.
 
and start gqcam again.
  
Note that /dev/video needs to be there, otherwise, no v4l! The driver needs to create it.
+
= Use it =
  
To be sure about Vendor and Device IDs, here is a screenshot when calling hwinfo with the Logitech Quickcam messenger:
+
== record video ==
<pre>
+
to capture video streams you can use [http://en.wikipedia.org/wiki/Cheese_%28software%29 cheese], a nice program with a graphical user interface. It allows you to watch and record your camera output at the same time. It stores in a strange format (.webm), but [[vlc]] can play this.
hwinfo --usb delivers
+
 
06: USB 00.2: 0000 Unclassified device
+
You can also automate video recording so you can capture the camera stream with sitting in front of the computer. To do this you can
  [Created at usb.122]               
+
* use the software ''mencoder'':
  UDI: /org/freedesktop/Hal/devices/usb_device_46d_8da_noserial_if2
+
 
  Unique ID: l1VU.vE+cdFBwClB                                     
+
mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -nosound -ovc lavc -o myvideo.avi
  Parent ID: zPk0.v+N+B0xY+P6                                     
+
 
  SysFS ID: /devices/pci0000:00/0000:00:1d.0/usb4/4-2/4-2:1.2     
+
* or use the software ''streamer'', example:
  SysFS BusID: 4-2:1.2                                           
+
 
  Hardware Class: unknown                                         
+
streamer -c /dev/video0 -f jpeg -F stereo -o myvideo.avi -t 0:05
  Model: "Logitech QuickCam Messanger"                           
+
 
  Hotplug: USB                                                   
+
== video conferencing ==
  Vendor: usb 0x046d "Logitech, Inc."                             
+
* to do video conferencing, [[use skype under Linux]].
  Device: usb 0x08da "QuickCam Messanger"                         
+
 
  Revision: "1.00"                                               
+
== watch it ==
  Driver: "snd-usb-audio"                                         
+
To watch your camera's input, use ''cheese'' or mplayer:
  Driver Modules: "snd_usb_audio"                                 
+
 
  Speed: 12 Mbps                                                 
+
mplayer -fps 30 -cache 128 -tv driver=v4l2:width=640:height=480:device=/dev/video0 tv://
  Module Alias: "usb:v046Dp08DAd0100dc00dsc00dp00ic01isc02ip00"   
+
 
  Driver Info #0:                                                 
+
Or use [[vlc]]. You can [[run vlc as root]] by the way. To watch your webcam /dev/video0, start vlc and select Media -> Open Capture Device -> Video device name = /dev/video0 -> Play
    Driver Status: quickcam_messenger is active                   
+
 
    Driver Activation Cmd: "modprobe quickcam_messenger"         
+
= Testbed =
  Driver Info #1:                                                
+
The following webcams have been found working with this tutorial:
    Driver Status: gspca is active                               
+
* Logitech Quickcam messenger
    Driver Activation Cmd: "modprobe gspca"                       
+
* Philips Webcam SPC220NC
  Config Status: cfg=new, avail=yes, need=no, active=unknown     
+
 
  Attached to: #26 (Hub)                                         
+
A general list of working webcams can be found at http://mxhaard.free.fr/spca5xx.html.
  
13: USB 00.3: 0000 Unclassified device
+
The guide has been tested with SUSE Linux 11.4 till 13.2 and Ubuntu.
  [Created at usb.122]               
 
  UDI: /org/freedesktop/Hal/devices/usb_device_46d_a0b_noserial_if3_logicaldev_input
 
  Unique ID: hz3w.SFg3xCNSZQ3                                                     
 
  Parent ID: uIhY.uOe2OKugI8D                                                     
 
  SysFS ID: /devices/pci0000:00/0000:00:1a.2/usb3/3-1/3-1:1.3                     
 
  SysFS BusID: 3-1:1.3                                                             
 
  Hardware Class: unknown                                                         
 
  Model: "Logitech USB Headset"                                                   
 
  Hotplug: USB                                                                     
 
  Vendor: usb 0x046d "Logitech, Inc."                                             
 
  Device: usb 0x0a0b "Logitech USB Headset"                                       
 
  Revision: "10.13"                                                               
 
  Driver: "usbhid"                                                                 
 
  Driver Modules: "usbhid"                                                         
 
  Device File: /dev/input/event2                                                   
 
  Device Files: /dev/input/event2, /dev/input/by-path/pci-0000:00:1a.2-usb-0:1:1.3-event-
 
  Device Number: char 13:66                                                             
 
  Speed: 12 Mbps                                                                       
 
  Module Alias: "usb:v046Dp0A0Bd1013dc00dsc00dp00ic03isc00ip00"                         
 
  Driver Info #0:                                                                       
 
    Driver Status: usbhid is active                                                     
 
    Driver Activation Cmd: "modprobe usbhid"                                           
 
  Config Status: cfg=new, avail=yes, need=no, active=unknown                           
 
  Attached to: #27 (Hub)                                                               
 
</pre>
 
  
 
= See also =
 
= See also =
 +
* [[hardware]]
 +
* http://en.opensuse.org/Webcam
 +
* http://www.linux.com/feature/126186
 
* http://ubuntulinuxhelp.com/linux-driver-for-quickcam-usb-cameras-logitech-quickcam-fusion/
 
* http://ubuntulinuxhelp.com/linux-driver-for-quickcam-usb-cameras-logitech-quickcam-fusion/
 
* http://www.goldmann.de/webcam-linux_tipp_408.html
 
* http://www.goldmann.de/webcam-linux_tipp_408.html
 +
* http://wiki.ubuntuusers.de/Webcam
 +
 +
<stumbleuponbutton style="3"></stumbleuponbutton>

Latest revision as of 08:28, 25 September 2022

ExternalRedirect Error

External redirection is not enabled for this namespace, page or URL. This page is: [Set up a Webcam with Linux]



Hi Friends,

I am moving this site to https://www.bingehacking.net/2022/09/set-up-webcam-with-linux.html This way, you will be able to leave comments and likes, and I will not need to take care for running the wiki software any longer.





A capture from a webcam in the program Cheese

You want to set up your webcam with Linux, see a video stream from it and learn which applications you can use with it, right? Then this article is for you.

Try it

First let's try if it works out of the box, so, connect your webcam (if it's not inbuilt), open a terminal and start the application cheese:

cheese

This should switch on your webcam and you should see what it's recording.

Ok, you are reading on, so there is still something left, maybe:

Install cheese

To install cheese, you need to know your distribution. Here is how to find out your distribution.

  • for Debian, Raspbian, Ubuntu, Kubuntu, Flubuntu, Xubuntu, GEUbuntu, Edubuntu, ...:
sudo apt-get install cheese
  • for SUSE:
yast -i cheese

Check the Setup

If cheese starts, but does not find a webcam, you need to dig deeper.

ls -ltr /dev/video*
  • you will find an output like this:
crw-rw----+ 1 root video 81, 0 Nov 11 09:06 /dev/video0

In this example your webcam device is named /dev/video0. If you have no /dev/video file, read #Troubleshooting. If you have several video4linux devices, for example a tv card your webcam may show up as /dev/video1 or whatever. But the time (in this case Nov 11 09:06) will be the time when you plugged it in.

You can also test your webcam the following ways:

  • if you have vlc installed you can start it and choose Media -> Open Capture Device -> Video device name = /dev/video0 -> Play
  • if you have mplayer installed you can use the command
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 30

Troubleshooting

Troubleshooting heavily depends on the distribution and version you are using. If you have done cabling correctly and a device file /dev/video* does not appear, your kernel probably does not know the hardware. In this case you may have to install the device driver separately because it may not be part of the kernel.

SUSE Linux 11.0 and earlier

This has been tested with SUSE Linux 11.0 x64 but should work with any earlier SUSE version. You will need to log in as user root. To find out what driver you need, open a console and call

hwinfo --usb

If a Logitech Quickcam Messenger is plugged in the answer will be like:

06: USB 00.2: 0000 Unclassified device
  [Created at usb.122]                
  UDI: /org/freedesktop/Hal/devices/usb_device_46d_8da_noserial_if2
  Unique ID: Eopr.vE+cdFBwClB                                      
  Parent ID: uIhY.uOe2OKugI8D                                      
  SysFS ID: /devices/pci0000:00/0000:00:1a.2/usb3/3-1/3-1:1.2      
  SysFS BusID: 3-1:1.2                                             
  Hardware Class: unknown                                          
  Model: "Logitech QuickCam Messanger"                             
  Hotplug: USB                                                     
  Vendor: usb 0x046d "Logitech, Inc."                              
  Device: usb 0x08da "QuickCam Messanger"                          
  Revision: "1.00"                                                 
  Driver: "snd-usb-audio"                                          
  Driver Modules: "snd_usb_audio"                                  
  Speed: 12 Mbps                                                   
  Module Alias: "usb:v046Dp08DAd0100dc00dsc00dp00ic01isc02ip00"    
  Driver Info #0:                                                  
    Driver Status: quickcam_messenger is active                    
    Driver Activation Cmd: "modprobe quickcam_messenger"
  Driver Info #1:                                                  
    Driver Status: gspca is active                                 
    Driver Activation Cmd: "modprobe gspca"
  Config Status: cfg=new, avail=yes, need=no, active=unknown       
  Attached to: #20 (Hub)

This means you can install and load the webcam driver like this:

yast -i gspcav-kmp-default
modprobe gspca

Now you should see a video device:

ls /dev/video*
/dev/video  /dev/video0

That means you can install and start your webcam-viewer-software. We choose gqcam:

yast -i gqcam
gqcam

It works. You see a video what from what is going on in front of your webcam.

Ubuntu

This has been tested with Ubuntu 8.10 x32 but should work with any Ubuntu version. Find out the driver activation command of your webcam. For this, first install the software hwinfo. Open a console and type:

sudo apt-get install hwinfo

Then call hwinfo:

hwinfo --usb

If a Logitech Quickcam Messenger is plugged in the response will be like: <source highlight=20> 04: USB 00.2: 0000 Unclassified device

 [Created at usb.122]
 UDI: /org/freedesktop/Hal/devices/usb_device_46d_8da_noserial_if2
 Unique ID: 4ajv.vE+cdFBwClB
 Parent ID: k4bc._Mkd+LmXb03
 SysFS ID: /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb1/1-1/1-1:1.2
 SysFS BusID: 1-1:1.2
 Hardware Class: unknown
 Model: "Logitech QuickCam Messanger"
 Hotplug: USB
 Vendor: usb 0x046d "Logitech, Inc."
 Device: usb 0x08da "QuickCam Messanger"
 Revision: "1.00"
 Driver: "snd-usb-audio"
 Driver Modules: "snd_usb_audio"
 Speed: 12 Mbps
 Module Alias: "usb:v046Dp08DAd0100dc00dsc00dp00ic01isc02ip00"
 Driver Info #0:
   Driver Status: gspca_zc3xx is active
   Driver Activation Cmd: "modprobe gspca_zc3xx"
 Config Status: cfg=new, avail=yes, need=no, active=unknown
 Attached to: #8 (Hub)</source>

Activate the driver:

sudo modprobe gspca_zc3xx

Now you should be able to see the video device:

ls /dev/video*
/dev/video0

You can now test your webcam using the software cheese:

sudo apt-get install cheese
cheese

Other webcams

If you have another webcam, try the above nevertheless. If it does not work, exchange the driver gspca against uvcvideo:

yast -i uvcvideo_kmp_default
modprobe uvcvideo

and start gqcam again.

Use it

record video

to capture video streams you can use cheese, a nice program with a graphical user interface. It allows you to watch and record your camera output at the same time. It stores in a strange format (.webm), but vlc can play this.

You can also automate video recording so you can capture the camera stream with sitting in front of the computer. To do this you can

  • use the software mencoder:
mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -nosound -ovc lavc -o myvideo.avi
  • or use the software streamer, example:
streamer -c /dev/video0 -f jpeg -F stereo -o myvideo.avi -t 0:05

video conferencing

watch it

To watch your camera's input, use cheese or mplayer:

mplayer -fps 30 -cache 128 -tv driver=v4l2:width=640:height=480:device=/dev/video0 tv://

Or use vlc. You can run vlc as root by the way. To watch your webcam /dev/video0, start vlc and select Media -> Open Capture Device -> Video device name = /dev/video0 -> Play

Testbed

The following webcams have been found working with this tutorial:

  • Logitech Quickcam messenger
  • Philips Webcam SPC220NC

A general list of working webcams can be found at http://mxhaard.free.fr/spca5xx.html.

The guide has been tested with SUSE Linux 11.4 till 13.2 and Ubuntu.

See also