<----ads---->

Installation webcam in Ubuntu OS

Before you begin

  • Many webcams will "just work" in Ubuntu. There is a USB standard that defines USB streaming video called UVC. This stands for Universal Video Class, and it does for webcams what UMS does for USB memory sticks and hard drives.
  • This allows one driver to work with many webcams. When looking to purchase a webcam for use with Ubuntu, you should look for a UVC compatible camera. The Linux-UVC project has a good list of UVC compatible webcams as well as The Quickcam Team for Logitech cameras.
  • If you are new this page maybe a bit hard and The Document assumes prior knowledge of the subject matter contained herein in order to achieve successful results.
This is typical within the Linux community.Good luck!

Testing your webcam

  • Once you've founded a UVC web cam , you can test by usingEkiga is installed by default in Ubuntu, and can be used to test your webcam.
For UVC devices luvcview is a good program you can use to test that the camera is working. If it doesn't work, you may need to update the UVC driver (see Manual install instructions below). guvcview is another program to use and with a graphical user interface.
Cheese, Camorama, xawtv, VLC, aMSN, and Kopete are in the Ubuntu repositories. They all can be used to test and use your webcam.
In some cases you (VLC, mplayer, amongst others) will need to know the video and audio device files for your webcam. Before you plug in your webcam, try the following two command at a console:
UVC
ls /dev/video*
ls /dev/audio*
Make a note of the devices appearing. Now plug in your webcam, allow the system a few seconds to register the device, and run the two commands again. The new appearances should belong to your webcam (for instance, /dev/video0 and /dev/audio2).

Before attempting any drivers installation

If your webcam is not one of the latest models and you get at least something as the picture (some garbled or green screen or statics) instead of the expected picture -- you already have the installed drivers. Still you'll have to reconfigure the launching of the application in which the problem is observed.
Reason: The developers decided to change the way the drivers and cameras work: old drivers (before Ubuntu 8.10) had the code to decode the data received from the webcam, the new drivers (since 8.10) don't. instead they assume decoding it always done somewhere else. The applications which use the older assumptions have to be provided with the additional (compatibility and decoding) library.
An example of the procedure needed to adjust launching one typical application with the described problem follows.

Skype

Go to main menu, System, Preferences, Menus: Applications, Internet, Items: Skype, Properties, and replace the Command with
bash -c 'LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype'

64-bit

bash -c 'LD_PRELOAD=/usr/lib32/libv4l/v4l1compat.so skype'
If the above doesn't work then try running the command from a terminal and look at the output. If it is complaining about "error unexpected width / height in JPEG headerexpected: 320x240, header: 1600x1200" then try the following
bash -c 'LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so skype'

64-bit

bash -c 'LD_PRELOAD=/usr/lib32/libv4l/v4l2convert.so skype'

A clean start for skype

This can be tidied up by writing a small script in /usr/local/bin called skype that comes higher in the loading sequence that the script of the same name in /usr/bin/. That script is in charge of running skype; the new script loads the correct libraries then hands control to the former script.
In terminal type:
$ sudo gedit /usr/local/bin/skype
and paste the following 2 line code snippet into gedit:
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so 
/usr/bin/skype
save and close. Now back in terminal make it executable
$ sudo chmod a+x /usr/local/bin/skype
Reboot type skype and the web cam just works. This was tested on Lucid with a Logitech Quick Cam Communicator.

Driver installation

EasyCam

If needed, try EasyCam, a tool for installing webcam drivers. If you are unable to manage installing your Webcam using EasyCam, you may try installing your camera manually. At the end of this page are some links to help you with this.
If you are using Intrepid and have a Logitech QuickCam or something else using the gspca driver, see this answer for video4linux 1 compatibility. Note: requires building and installing software from scratch.

Manual driver installation instructions

Installing spca5xx manually

You can find howto's for manual installation of the spca5xx driver here.

Installing ov51x manually

You can find howto's for manual installation of the ov51x driver here.

Installing ov51x-jpeg manually

(July 16 2008) Currently the source package for ov51x-jpeg doesn't compile, but you can use this howto to get it running.

Installing UVC

The UVC module is included in 7.10 and later, and possibly earlier but the included version has problems with some webcams. If you need to install/update it you can find a howto here

Recording video

cheese

You can use cheese to test and record pictures and video from your webcam.
sudo apt-get install cheese
then run cheese . cheese should automatically detect your webcam and display live video stream. You can click either on photo or video and select Take a Photo or Start recording

ffmpeg

To record both video and audio using ffmpeg, first make sure ffmpeg is installed:
sudo apt-get install ffmpeg
then run ffmpeg with arguments such as these:
ffmpeg -f oss -i /dev/dsp -f video4linux2 -s 320x240 -i /dev/video0 out.mpg

MPlayer / MEncoder

MPlayer is capable of displaying a webcam video stream, for example with the command line
mplayer tv:// -tv driver=v4l:width=640:height=480:device=/dev/video0
For Jaunty / Karmic, use this command line.
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0
The resolution (width=??? & height=??? ) should be chosen to match the output of your device, and the device file (/dev/video0) to match your webcam's device file, see above.
The companion to MPlayer, MEncoder can record from a webcam to video files such as AVI, for example without audio:
mencoder tv:// -tv driver=v4l:width=320:height=240:device=/dev/video0 -ovc lavc -o webcam.avi
for Jaunty/Karmic,
mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -ovc lavc -o webcam.avi
and with audio
mencoder tv:// -tv driver=v4l:width=320:height=240:device=/dev/video0:forceaudio:adevice=/dev/dsp1 -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o webcam.avi
for Jaunty/Karmic,
mencoder tv:// -tv driver=v4l:width=320:height=240:device=/dev/video0:forceaudio:adevice=/dev/dsp1 -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o webcam.avi
Type 'man mencoder' for more info on the audio options. In the example, /dev/dsp1 refers to the webcam USB Audio device, while /dev/dsp would refer to the sound card.
You may need to install these programs with
sudo apt-get install mplayer mencoder

VLC

In VLC, choose 'Open capture device' from the file menu and enter the video and audio device files (see above) in video device name and audio device name, respectively. If you just want a 'mirror' (to see what the webcam is showing), click 'OK' and you're done. If you wish to record, tick off 'Stream/save' in the 'Advanced options' section. Click the settings button right next to it. Tick 'File' off under 'Outputs' and enter a filename. Encapsulation method can be left at the default (MPEG TS). Under 'Transcoding options', tick 'Audio codec' and 'Video codec'. These can also safely be left the defaults (obviously greater compression results in lower file sizes, so experiment). Click 'OK' in the Settings screen and once again in the main webcam screen (Video4linux). If you want to have more control, you can access several settings, including resolution, by clicking the Advanced options button.
If you wish to be able to quickly start a video session with your webcam, the resulting vlc command is printed in the Customize line at the bottom. You simply need to prepend 'vlc', e.g.
vlc v4l:// :v4l-vdev="/dev/video0" :v4l-adev="/dev/audio2" :v4l-norm=3 :v4l-frequency=-1 :v4l-caching=300 :v4l-chroma="" :v4l-fps=-1.000000 :v4l-samplerate=44100 :v4l-channel=0 :v4l-tuner=-1 :v4l-audio=-1 :v4l-stereo :v4l-width=640 :v4l-height=480 :v4l-brightness=-1 :v4l-colour=-1 :v4l-hue=-1 :v4l-contrast=-1 :no-v4l-mjpeg :v4l-decimation=1 :v4l-quality=100
The recording instructions will similarly need to be appended. Copy the contents of the 'Stream Output MRL' box under 'Settings' and change ":sout=" to "--sout " and append it to your vlc command:, e.g.
vlc v4l:// :v4l-vdev="/dev/video0" :v4l-adev="/dev/audio2" :v4l-norm=3 :v4l-frequency=-1 :v4l-caching=300 :v4l-chroma="" :v4l-fps=-1.000000 :v4l-samplerate=44100 :v4l-channel=0 :v4l-tuner=-1 :v4l-audio=-1 :v4l-stereo :v4l-width=640 :v4l-height=480 :v4l-brightness=-1 :v4l-colour=-1 :v4l-hue=-1 :v4l-contrast=-1 :no-v4l-mjpeg :v4l-decimation=1 :v4l-quality=100 --sout "#transcode{vcodec=mp1v,vb=1024,scale=1,acodec=mpga,ab=192,channels=2}:duplicate{dst=std{access=file,mux=mpeg1,dst=/tmp/test.mpg}}"
For Ubuntu 9.10 (Karmic Koala), use
vlc v4l2:// :v4l-vdev="/dev/video0" :v4l-adev="/dev/audio2" :v4l-norm=3 :v4l-frequency=-1 :v4l-caching=300 :v4l-chroma="" :v4l-fps=-1.000000 :v4l-samplerate=44100 :v4l-channel=0 :v4l-tuner=-1 :v4l-audio=-1 :v4l-stereo :v4l-width=640 :v4l-height=480 :v4l-brightness=-1 :v4l-colour=-1 :v4l-hue=-1 :v4l-contrast=-1 :no-v4l-mjpeg :v4l-decimation=1 :v4l-quality=100
as an example, because vlc is not compiled with v4l, but with v4l2
To simple take a few snapshots, open the webcam without recording and choose 'Snapshot' under the 'Video' menu.

Webcam Issues

Intrepid/Updated Hardy issues

With Intrepid and Hardy fully updated, several issues were presented with previously working webcams. The root causes for this issues were several webcam modules merged into the kernel from 2.6.26 and 2.6.27, libv4l modifications, gstreamer modifications and changes in Ubuntu's kernel.
Almost all the issues present at this time (14/12/08) are detected with corresponding bug reports, some of them are solved, and some others are in the process of getting them solved.
We are working hard to uncover and solve the remaining issues, so please bear with us in the meantime.
I'm listing here the issues organized by kernel module. So you've got to check which module your camera uses in order to check for the workaround or corresponding report.

List of Kernel modules with problems

Driver
Launchpad Bugs
Brief problem description
gspca
The mother of all webcam related bugs :). Well almost all of the, this one solves a lot of libv4l issues with gspca webcam and some other webcams as well
uvcvideo
Uvcvideo webcam issue detected mainly with cheese. It's solved right now just waiting the next kernel
pwc
Due to the mentioned changes this one became a dupe from bug #260918
gspca_zc3xx
This is caused by the inclusion of gspca modules on the kernel
gspca_zc3xx
Probably the same bug as the previous one
sn9c10x
snc9105 and sc9102 issues
sn9c20x
microdia solution for the sn9c20x webcams
r5u87x
This would be the package of userland tools needed to load firmware for Ricoh Cameras and would use the uvcvideo driver for the actual work
r5u870
This is the way to go if you've got a WDM camera not supported by uvcvideo or if you want to use the old driver. In the near (really near) future this would be deprecated
ov51x_jpeg
Trying to introduce this module into the kernel
ov51x_jpeg
As the current source package no longer builds, the latest version is the one for this webcam to work
stk, stkwebcam
The st11k module present in Hardy is no longer available in Intrepid/Jaunty. The stkwebcam doesn't supports all the previous webcams.
quickcam
Description

Fixing Webcam issues while using Flash since Intrepid

If your webcam stopped working in flash-powered streaming sites, for instance (like www.ustream.tv), that might be due to two reasons: (1) Bug in recent version of the adobe flash plugin (2) you are using an old webcam which doesn't work well with V4L2
See below for more information on solutions reported to work by some users.
=== Bug in recent version of Adobe flash player ===
In Ubuntu Hardy you were used to be asked to grant permission to the website you were visiting to take control on your webcam (through some flash popup with the settings). It seems that recent versions of Adobe flash player (the updated ones for Intrepid and Jaunty since June 2009, at least, and probably before also) have a bug which doesn't ask the user to grant access to a site when visiting it. Like ustream.tv for streaming using your webcam, as example.
The workaround is to grant access to that website by default without attempting to ask you each time.
* Choose the "Website privacy settings" * Select the site from the list of visited websites. * click on the option "always allow" above the list.
You should see that the icon on the left of that site in the list changes from yellowish to green colour. That's it.
Try again visiting that website, ustream.tv in this example, and your webcam should be streaming again as it used to do back with Hardy.
Enjoy! :-)
=== old webcam which doesn't work well with V4L2 ===
There seems to be a known problem in Ubuntu Intrepid and Jaunty (at least), due to switching from the video system V4L to the more recent V4L2. Many applications, like webcams, doesn't seem to work well (or at all) with V4L2. But luckily there is a simple workaround to avoid the problem, through installing and loading some libraries with backward-compatibility with V4L, so that Flash sees again your Webcam, as it used to do until Ubuntu Hardy.
In order to do it, we need to shut down any application that might be doing some use of the video: editors, instant messengers or even the internet browser, and in a terminal we'll type:
sudo apt-get install ld.so.preload-manager
y after that, execute:
sudo ld.so.preload-manager /usr/lib/libv4l/v4l1compat.so
Then, you have to switch the video mode to V4L from the multimedia systems selector, through executing:
gstreamer-properties
Go to the Video tab, and change the default value to V4L.
That should do the work (it did for me using Jaunty, and for others as reported originally at this source).

Fixing Audio problems with USB webcam

I installed a Logitech webcam Pro 9000 on a new Karmic/9.10 32bit install. Video worked "out of the box" but there was no audio.After hunting around for a while, I remembered how I had a similar problem trying to get digital audio out over hdmi on another 9.10 box. The problem was that the alsa settings (not visible under pulseaudio) had the IEC958 device muted (silly setting if you ask me!).
Anyway, I took the following steps to getting my webcam audio to work:
  1. start a terminal window/xterm window
  2. type: sudo alsamixer
  3. using the tab key, make sure to be either in "all" or "capture" mode
  4. using the left/right arrow key, navitage to the correct "slider"
    • (I'm not sure if the right one was front mic (left/right) or just plain "mic" or Mic Boost but I enabled them all)
  5. if the value at the bottom of the slider says "M" then your device is on "mute" - Hit the "m" key to togger the mute / un-mute
  6. using the up/down arrow, adjust the setting to get as much green as possible w/o getting in the red zone.
  7. repeat for all lables that look like "mic", "front mic" "Mic Boost" etc...
  8. exit alsamixer
  9. test your audio. I installed "cheese" to do a quick audio/video recording test but you can also test with "sound recorder" or the skype test call etc...
That should do it!

Setting brightness, contrast, color etc. on some webcams

When fidling with webcam software one may inadvertently screw up the settings in VIDIOCGPICT. This often results in a very bright / dark picture, or a "greenish" / "blueish" picture.
After spending hours on the 'Net trying to solve this, I found a very easy solution: luvcview . Simply install (it's in the repositories) and run. It is a simply webcam app that uses the webcam to make a video, BUT.... it allows you to change the settings in VIDIOCGPICT. Hardly an elegant solution, but it does the job.

Additional software

This software is not supported by Ubuntu, and is not available in the repositories.
Camera Monitor shows a tray icon letting you know when your webcam is on.
Previous
Next Post »