Difference between pages "Apt-get" and "Set up a Webcam with Linux"

From Linuxintro
(Difference between pages)
imported>ThorstenStaerk
 
 
Line 1: Line 1:
apt-get is a [[system management]] [[command]] to [[install]] [[dpkg]] [[software]] [[packages]].
+
<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>
 +
[[File:Screenshot_from_2020-03-01_13-18-32.png]]
 +
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.
  
= TroubleShooting =
+
= Try it =
Here is an example for troubleshooting apt-get:
+
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''''':
<pre>
+
cheese
root@Microknoppix:~# apt-get install cheese
 
Reading package lists... Done
 
Building dependency tree     
 
Reading state information... Done
 
Some packages could not be installed. This may mean that you have
 
requested an impossible situation or if you are using the unstable
 
distribution that some required packages have not yet been created
 
or been moved out of Incoming.
 
The following information may help to resolve the situation:
 
  
The following packages have unmet dependencies:
+
This should switch on your webcam and you should see what it's recording.  
  cheese: Depends: gstreamer0.10-plugins-good but it is not going to be installed
 
E: Broken packages
 
root@Microknoppix:~# apt-get install gstreamer0.10-plugins-good
 
Reading package lists... Done
 
Building dependency tree     
 
Reading state information... Done
 
Some packages could not be installed. This may mean that you have
 
requested an impossible situation or if you are using the unstable
 
distribution that some required packages have not yet been created
 
or been moved out of Incoming.
 
The following information may help to resolve the situation:
 
  
The following packages have unmet dependencies:
+
Ok, you are reading on, so there is still something left, maybe:
  gstreamer0.10-plugins-good: Depends: libcucul0 (>= 0.99.beta14-1) but it is not going to be installed
+
* terminal says "command not found", you need to install cheese. Read on at [[#Install_cheese|Install Cheese]].
E: Broken packages
+
* cheese does not show the camera's content -> read on at [[#Check the Setup|Check the Setup]].
root@Microknoppix:~# apt-get install libcucul0               
+
* you want to [[#record_a_video]] with your webcam.
Reading package lists... Done
+
 
Building dependency tree     
+
= Install cheese =
Reading state information... Done
+
To install cheese, you need to know your distribution. Here is how to [[find out your distribution]].
The following packages were automatically installed and are no longer required:
+
* for Debian, Raspbian, Ubuntu, Kubuntu, Flubuntu, Xubuntu, GEUbuntu, Edubuntu, ...:
  libopenal1 libavutil49 libosip2-4 libsrtp0 libdiscid0 liblircclient0
+
sudo apt-get install cheese
  libavformat52 libschroedinger-1.0-0 mplayer-skin-blue libcdparanoia0
+
* for SUSE:
  libexosip2-4 libavcodec52 liboil0.3 libdirac-encoder0 libortp8 libspeexdsp1
+
yast -i cheese
  libmusicbrainz3-6 libfaad2
+
 
Use 'apt-get autoremove' to remove them.
+
= Check the Setup =
The following extra packages will be installed:
+
If cheese starts, but does not find a webcam, you need to dig deeper.
  libatk1.0-0 libavcodec52 libavformat52 libavutil49 libortp8 libsrtp0
+
* [[open a console]] and list your video4linux devices:
Suggested packages:
+
<source>
  srtp-utils
+
ls -ltr /dev/video*
The following packages will be REMOVED:
+
</source>
  adriane adriane-multimedia gnome-mplayer libcaca0 liblinphone3
+
* you will find an output like this:
  libmediastreamer0 libpostproc51 libswscale0 linphone linphone-nox mplayer
+
<source>
The following NEW packages will be installed:
+
crw-rw----+ 1 root video 81, 0 Nov 11 09:06 /dev/video0
  libcucul0 libsrtp0
+
</source>
The following packages will be upgraded:
+
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.
  libatk1.0-0 libavcodec52 libavformat52 libavutil49 libortp8
+
 
5 upgraded, 2 newly installed, 11 to remove and 622 not upgraded.
+
You can also test your webcam the following ways:
Need to get 5263kB of archives.
+
* if you have [[vlc]] installed you can start it and choose Media -> Open Capture Device -> Video device name = ''/dev/video0'' -> Play
After this operation, 8520kB disk space will be freed.
+
* if you have mplayer installed you can use the command
Do you want to continue [Y/n]? Y
+
<source>
Get:1 http://ftp.de.debian.org testing/main libatk1.0-0 1.30.0-1 [82.4kB]
+
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0 -fps 30
Get:2 http://ftp.de.debian.org testing/main libavformat52 4:0.5.2-5 [709kB]
+
</source>
Get:3 http://ftp.de.debian.org testing/main libavcodec52 4:0.5.2-5 [4001kB]
+
 
Get:4 http://ftp.de.debian.org testing/main libavutil49 4:0.5.2-5 [90.3kB]   
+
= Troubleshooting =
Get:5 http://ftp.de.debian.org stable/main libcucul0 0.99.beta14-1 [265kB]      
+
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.
Get:6 http://ftp.de.debian.org testing/main libsrtp0 1.4.4~dfsg-6 [49.5kB]      
+
 
Get:7 http://ftp.de.debian.org unstable/main libortp8 3.3.2-3 [65.6kB]       
+
== SUSE Linux 11.0 and earlier ==
Fetched 5263kB in 16s (329kB/s)                                               
+
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.
(Reading database ... 88299 files and directories currently installed.)
+
To find out what driver you need, [[open a console]] and call
Removing adriane ...
+
[[hwinfo]] --usb
Removing adriane-multimedia ...
+
If a Logitech Quickcam Messenger is plugged in the answer will be like:
Removing gnome-mplayer ...
+
<source highlight=23>
Removing mplayer ...
+
06: USB 00.2: 0000 Unclassified device
Removing libcaca0 ...
+
  [Created at usb.122]              
Removing linphone ...
+
  UDI: /org/freedesktop/Hal/devices/usb_device_46d_8da_noserial_if2
Removing linphone-nox ...
+
  Unique ID: Eopr.vE+cdFBwClB                                     
Removing liblinphone3 ...
+
  Parent ID: uIhY.uOe2OKugI8D                                     
Removing libmediastreamer0 ...
+
  SysFS ID: /devices/pci0000:00/0000:00:1a.2/usb3/3-1/3-1:1.2    
Removing libpostproc51 ...
+
  SysFS BusID: 3-1:1.2                                           
Removing libswscale0 ...
+
  Hardware Class: unknown                                         
Processing triggers for menu ...
+
  Model: "Logitech QuickCam Messanger"                           
Processing triggers for man-db ...
+
  Hotplug: USB                                                   
Processing triggers for hicolor-icon-theme ...
+
  Vendor: usb 0x046d "Logitech, Inc."                             
(Reading database ... 88096 files and directories currently installed.)
+
  Device: usb 0x08da "QuickCam Messanger"                         
Preparing to replace libatk1.0-0 1.28.0-1 (using .../libatk1.0-0_1.30.0-1_i386.deb) ...
+
  Revision: "1.00"                                               
Unpacking replacement libatk1.0-0 ...
+
  Driver: "snd-usb-audio"                                         
Preparing to replace libavformat52 4:0.5+svn20090706-2+b1 (using .../libavformat52_4%3a0.5.2-5_i386.deb) ...
+
  Driver Modules: "snd_usb_audio"                                 
Unpacking replacement libavformat52 ...
+
  Speed: 12 Mbps                                                 
Preparing to replace libavcodec52 4:0.5+svn20090706-2+b1 (using .../libavcodec52_4%3a0.5.2-5_i386.deb) ...
+
  Module Alias: "usb:v046Dp08DAd0100dc00dsc00dp00ic01isc02ip00"   
Unpacking replacement libavcodec52 ...
+
  Driver Info #0:                                                 
Preparing to replace libavutil49 4:0.5+svn20090706-2+b1 (using .../libavutil49_4%3a0.5.2-5_i386.deb) ...
+
     Driver Status: quickcam_messenger is active                   
Unpacking replacement libavutil49 ...
+
    Driver Activation Cmd: "modprobe quickcam_messenger"
Selecting previously deselected package libcucul0.
+
  Driver Info #1:                                                
Unpacking libcucul0 (from .../libcucul0_0.99.beta14-1_i386.deb) ...
+
     Driver Status: gspca is active                               
Selecting previously deselected package libsrtp0.
+
    Driver Activation Cmd: "modprobe gspca"
Unpacking libsrtp0 (from .../libsrtp0_1.4.4~dfsg-6_i386.deb) ...
+
  Config Status: cfg=new, avail=yes, need=no, active=unknown     
Preparing to replace libortp8 3.2.1-1 (using .../libortp8_3.3.2-3_i386.deb) ...
+
  Attached to: #20 (Hub)
Unpacking replacement libortp8 ...
+
</source>
Setting up libatk1.0-0 (1.30.0-1) ...
+
This means you can install and load the webcam driver like this:
Setting up libavutil49 (4:0.5.2-5) ...
+
yast -i gspcav-kmp-default
Setting up libavcodec52 (4:0.5.2-5) ...
+
modprobe gspca
Setting up libavformat52 (4:0.5.2-5) ...
+
Now you should see a video device:
Setting up libcucul0 (0.99.beta14-1) ...
+
ls /dev/video*
Setting up libsrtp0 (1.4.4~dfsg-6) ...
+
/dev/video  /dev/video0
Setting up libortp8 (3.3.2-3) ...
+
That means you can install and start your webcam-viewer-software. We choose gqcam:
root@Microknoppix:~# apt-get install cheese
+
yast -i gqcam
Reading package lists... Done
+
gqcam
Building dependency tree     
+
It works. You see a video what from what is going on in front of your webcam.
Reading state information... Done
+
 
The following packages were automatically installed and are no longer required:
+
== Ubuntu ==
  libopenal1 libavutil49 libosip2-4 libsrtp0 libdiscid0 liblircclient0
+
This has been tested with Ubuntu 8.10 x32 but should work with any Ubuntu version.
  libavformat52 libschroedinger-1.0-0 mplayer-skin-blue libexosip2-4
+
Find out the driver activation command of your webcam. For this, first install the software '''hwinfo'''. [[Open a console]] and type:
  libavcodec52 libdirac-encoder0 libortp8 libspeexdsp1 libmusicbrainz3-6
+
sudo apt-get [[install]] [[hwinfo]]
  libfaad2
+
Then call hwinfo:
Use 'apt-get autoremove' to remove them.
+
hwinfo --usb
The following extra packages will be installed:
+
If a Logitech Quickcam Messenger is plugged in the response will be like:
  gstreamer0.10-alsa gstreamer0.10-plugins-base gstreamer0.10-plugins-good
+
<source highlight=20>
  gstreamer0.10-x libavc1394-0 libcaca0 libcamel1.2-11 libcdio7 libdv4
+
04: USB 00.2: 0000 Unclassified device
  libebook1.2-9 libedataserver1.2-9 libiec61883-0 libraw1394-8 libshout3
+
  [Created at usb.122]
  libtag1c2a libvisual-0.4-0 libvisual-0.4-plugins libwavpack1
+
  UDI: /org/freedesktop/Hal/devices/usb_device_46d_8da_noserial_if2
Suggested packages:
+
  Unique ID: 4ajv.vE+cdFBwClB
  libdv-bin libraw1394-doc
+
  Parent ID: k4bc._Mkd+LmXb03
The following NEW packages will be installed:
+
  SysFS ID: /devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb1/1-1/1-1:1.2
  cheese gstreamer0.10-alsa gstreamer0.10-plugins-base
+
  SysFS BusID: 1-1:1.2
  gstreamer0.10-plugins-good gstreamer0.10-x libavc1394-0 libcaca0
+
  Hardware Class: unknown
  libcamel1.2-11 libcdio7 libdv4 libebook1.2-9 libedataserver1.2-9
+
  Model: "Logitech QuickCam Messanger"
  libiec61883-0 libraw1394-8 libshout3 libtag1c2a libvisual-0.4-0
+
  Hotplug: USB
  libvisual-0.4-plugins libwavpack1
+
  Vendor: usb 0x046d "Logitech, Inc."
0 upgraded, 19 newly installed, 0 to remove and 622 not upgraded.
+
  Device: usb 0x08da "QuickCam Messanger"
Need to get 7586kB of archives.
+
  Revision: "1.00"
After this operation, 14.0MB of additional disk space will be used.
+
  Driver: "snd-usb-audio"
Do you want to continue [Y/n]?
+
  Driver Modules: "snd_usb_audio"
</pre>
+
  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 [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.
 +
 
 +
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'':
 +
<source>
 +
mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -nosound -ovc lavc -o myvideo.avi
 +
</source>
 +
* or use the software ''streamer'', example:
 +
<source>
 +
streamer -c /dev/video0 -f jpeg -F stereo -o myvideo.avi -t 0:05
 +
</source>
 +
 
 +
== video conferencing ==
 +
* to do video conferencing, [[use skype under Linux]].
 +
 
 +
== watch it ==
 +
To watch your camera's input, use ''cheese'' or mplayer:
 +
<source>
 +
mplayer -fps 30 -cache 128 -tv driver=v4l2:width=640:height=480:device=/dev/video0 tv://
 +
</source>
 +
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 =
 
= See also =
* [[dpkg]]
+
* [[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://www.goldmann.de/webcam-linux_tipp_408.html
 +
* http://wiki.ubuntuusers.de/Webcam
 +
 
 +
<stumbleuponbutton />

Revision as of 12:28, 26 December 2020

Screenshot from 2020-03-01 13-18-32.png 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.

<source>

ls -ltr /dev/video*

</source>

  • you will find an output like this:

<source>

crw-rw----+ 1 root video 81, 0 Nov 11 09:06 /dev/video0

</source> 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

<source>

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

</source>

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: <source highlight=23> 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)

</source> 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:

<source>

mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -nosound -ovc lavc -o myvideo.avi

</source>

  • or use the software streamer, example:

<source>

streamer -c /dev/video0 -f jpeg -F stereo -o myvideo.avi -t 0:05

</source>

video conferencing

watch it

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

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

</source> 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