Sunday, January 22, 2012

Skype webcam tip on Ubuntu 10.04

Happy Sunday!

I was messing around with Skype on Ubuntu this morning and realized my webcam didn't produce any video for Skype! I did a little research and got it working and wanted to share the tip.

Note that my webcam *did* work with the "cheese" application. If yours does not, you may need to do some additional research.

The issue seems to be that my webcam is only supported on V4L2 (That's Video-For-Linux-Two), not V4L (Video-For-Linux). Apparently Skype by default only supports V4L.

I found this out with the gstreamer-properties utility (use the video tab).

But, it turns out there is a shared library you can preload with skype which will allow it to use this webcam.

For testing purposes, we're going to run skype from the command line, so fire up a terminal!

You can run skype with the "skype" command, no strange magic there.

To load a separate shared library, we use the "LD_PRELOAD" environment variable.

(Warning: Background ahead)

Linux executables make use of something called dynamically linked libraries. These are often called shared objects or "SO"'s. Not all of the code the executable uses is in the executable itself, for code reuse, we can put it in common libraries that multiple applications share.

When the application is build, it usually specifies what shared libraries it wants to use. When the application is run, the OS will know what libraries to provide it (try it yourself, the "ldd" tools shows you the shared libraries, e.g. ldd /usr/bin/skype).

When the OS goes to look for the shared libraries, it looks in the default location. But, you can over-rule this if you want to using the "LD_PRELOAD" environement variable.

(Background done)

So, to make skype use the webcam, we're going to modify how it's run. Instead of just running the skype command, try this:

32-bit Ubuntu: env LD_PRELOAD=/usr/lib/libv4l/ skype
64-bit Ubuntu: env LD_PRELOAD=/usr/lib32/libv4l/ skype

After that, go into the Skype webcam settings and give it a test! Hopefully you'll see your picture. You can also try making a few calls and seeing if it's handled properly.

If it works for you, make it a permanent change by right clicking on the Ubuntu-menu and saying "Edit menu". Find the skype entry, and modify the "Command" (under Properties") to have the environment preload variable set.

After that, run Skype from the menu as usual and hopefully your video works!

To be fair, it's still not the best picture in the world. The lighting goes from dark to washed out periodically and fellow Skypers have told me my video is choppy (even when theirs is smooth on my end). Not sure if there's anything I can do about this on my end yet (the web cam was pretty cheap). Here's hoping you get better picture.

Best of luck!