Sunday, February 24, 2013

How to Solve the Ubuntu Webcam Problem

I currently use Ubuntu 12.04 as my primary OS and every now and then I need to use Skype/GTalk for a video chat with my friends and family. Recently I made some major changes to my OS installation - including removing a lot of unused packages. This subsequently led to my webcam not working in either Cheese or Skype/Pidgin.  Because I did not remove any related packages intentionally, my guess is that Ubuntu does it when I use autoremove.

To troubleshoot such problems, the first and most obvious step is to find out where the problem lies - hardware (faulty webcam) or the drivers. I opened up a terminal (Ctrl + Alt + T) and typed in lsusb.

user@pc: ~$ lsusb

The lsusb command lists all the USB devices connected to the computer. I got the following output:

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 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
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 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0bc2:5021 Seagate RSS LLC FreeAgent GoFlex USB 2.0
Bus 002 Device 004: ID 05a9:2640 OmniVision Technologies, Inc. OV2640 Webcam
Bus 003 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 006 Device 002: ID 046d:c05b Logitech, Inc. M-U0004 810-001317 [B110 Optical USB Mouse]
Bus 003 Device 003: ID 413c:8126 Dell Computer Corp. Wireless 355 Bluetooth
Bus 003 Device 004: ID 0a5c:4502 Broadcom Corp. Keyboard (Boot Interface Subclass)
Bus 003 Device 005: ID 0a5c:4503 Broadcom Corp. Mouse (Boot Interface Subclass)

This output clearly shows that my webcam is alive and kicking (on Bus 002 Device 004 - OmniVision Technologies Webcam). So this certainly means that it is not configured correctly or certain drivers are missing. I searched online for similar problems, and most of the answers relate to the infamous Skype problem. But my problem was different because even Cheese would not recognize my webcam. So I just checked for the packages libv4l and v4l-utils. They were missing! autoremove had fucked up. So I reinstalled these packages by using the following command in the terminal.

user@pc: ~$ sudo apt-get install libv4l* && sudo apt-get install v4l*

I used the wildcards(*) because I do not know which ones are required. I know Ubuntu has a way of installing the required dependencies but then again, relying on it had led to this problem in the first place. After installing the above mentioned packages, I restarted my laptop and voila - my webcam was up and running. So for all of you folks who have had a similar problem after an update or other changes to your system, try this method out.

EDIT : Sometimes the problem occurs because the webcam is mounted as video1 instead of the default video0. To be sure that this is the problem , open up a terminal and type in the following command to display the output of your webcam:

user@pc: ~$ vlc v4l2:///dev/video0

Alternatively, you can use mplayer to do the same job:
user@pc: ~$ mplayer -tv driver=v4l2:gain=1:width=640:height=480:device=/dev/video0:fps=10:outfmt=rgb16 tv://

Replace the video0 to video1 in the above commands if you receive an error message like this one (for vlc):
Your input can't be opened:
VLC is unable to open the MRL 'v4l2:///dev/video0'. Check the log for details.
This method is quite powerful and can be used as a sureshot method of finding out if there is a driver issue or not.

However, my problem is that the webcam freezes a few seconds after I launch it using Cheese/Skype/VLC/MPlayer. This seems to be a recurring bug with many users, and a kernel upgrade has been reported to fix this problem.

1 comment:

  1. The content of this blog is very informative.Awesome blog. Related issues visit this website Skype Support and Call +1-800-231-4635 USA (Toll Free).

    ReplyDelete