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.

Wednesday, February 13, 2013

Create an All-in-One Boot USB Disk

Recently, A friend of mine was locked out of his Windows laptop due to a certain virus. While I have always found that the best anti-virus solution has been Microsoft Security Essentials, we are talking about the "cure" here rather than "prevention". I knew what was in store - I had to use a rescue disk and check the drive. And then (possibly) perform a repair of the Windows installation. If the above two processes didn't work,  I would have to use a Live CD to extract the important data and then format the HDD. The problem - I had only one USB drive! If I had to go through all of these steps, I would waste a tremendous amount of time just making different disks. Not to mention, I would require access to a running computer throughout.

Enter YUMI.With this brilliant tool, you can install multiple distributions on your USB drive. Moreover, it supports a huge list of anti-virus tools and system tools apart from the popular Windows and Linux distributions. It is extremely use this tool in Windows and it can run (without the format drive feature) in Linux through Wine. A detailed documentation along with a list of known issues has been provided on their  web page. Of course, a large USB disk is also required. I would suggest keeping at least the following on your All-in-One Boot Disk:

1. Operating System
Because I have a dual boot on my laptop with Windows 7 and Ubuntu 12.04, I have kept copies of both of these. The advantage of keeping Ubuntu is that it comes with a Live CD that will help you recover data in case of a major Windows meltdown. If you do not have any version of Linux installed and do not have enough space for Ubuntu on your USB disk, you can make use of the extremely small Linux distributions like Damn Small Linux (~50 MB) or TinyCore (~12 MB).

2. Antivirus Tools
These are a must-have because of all the vulnerabilities your Windows is prone to. Even with a fully functional antivirus on your computer, the importance of a rescue disk cannot be emphasized enough. For this the ISOs offered by Kaspersky, AVIRA and BitDefender are good options. Some people have complained about problems with using Kaspersky's Rescue Disk, though.

3. System Tools
These are good to have in case you want to partition hard disks, diagnose for certain hardware failures or to simply crack your computer's password for the forgetful ones. There are a lot of tools available for this purpose, the most popular ones being GParted, Ultimate Boot CD and OPhcrack. The number of tools offered for this purpose is so vast that it could be a separate blog post in itself.

There is also an ISO available called Hiren's Boot CD. It has a lot of tools included onto a Windows XP boot disk. Even though there have been certain references to it being illegal, I will not recommended it for completely different reasons. In my experience, this particular ISO comes with so many needless tools that it actually makes the recovery process more painful than a plain format and reinstall. Use this only if you don't have any clue about what is wrong with your computer.

Lessons learnt:
1. Always have an anti-virus installed on your Windows PC
2. Always keep a regular backup of your important data, either on an external drive or using a service like Dropbox/Ubuntu One/Google Drive
3. Always keep your OS partition separate from your data partition
4. An all-in-one USB disk makes a quick-fix repair easy and painless