Flipped images from your webcam in Ubuntu?
Posted on November 5th, 2009 at 18:07, in How To, Linux, Ubuntu.
Some of you (and me also) have experienced problems with certain laptop webcams on Ubuntu because some of them were mounted upside down. I have posted a solution for fixing this on the blog, but apparently it’s not quite the best way to obtain the desired results because it involves patching the kernel. And since the kernel changes from time to time, the patches must be refactored accordingly. So this is clearly a kind of cat and mouse game.
Unfortunately for some time this has been the only solution to the problem. Until Hans de Goede decided that he can improve things dramatically. Basically he pushed the fixes for those specific webcam models that were mounted upside down into the libv4l, a video library for Linux that handles various devices. He did that by asking people having problems for two files that could help him make the needed changes into his library.
With the 0.6.0 release, the library managed to handle correctly the upside down webcams. Because Hans works for Red Hat, he built the packages for Fedora and the only way you could have installed the library in Ubuntu was to remove every trace of the default libv4l and then recompile and reinstall it from his sources. But apparently somebody took care to build the packages for Ubuntu too. Just add the sources for your release and then take care to install / update the libv4l-0 package.
You can follow these steps in order to do so:
echo -e "\n# libv4l PPA\ndeb http://ppa.launchpad.net/libv4l/ppa/ubuntu `lsb_release -c | awk '{print $2}'` main" | sudo tee -a /etc/apt/sources.list sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C3FFB4AA sudo apt-get update sudo apt-get install libv4l-0
Now, whenever you want to run one of the applications that use your webcam you should launch them using a command like
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so application_name
A more elegant solution would be to edit the menu launchers to directly set the content of the above variable like this:
- create a wrapper script like the one below and save it in
~/bin/webcamWrapper.sh:#!/bin/bash LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so $1 exit 0
- edit the menu launchers for the applications that use your webcam so that their command entry looks like
webcamWrapper.sh "previous command w/ args"
- if you haven’t had that
binfolder created by now, log out and log back in so that it would be automatically added to yourPATHvariable
For Skype though there is no need for setting a custom launcher.
If you have followed precisely these instructions and your webcam still doesn’t display your images with the right orientation, then you should check with Hans that your webcam is included in his library, by providing him the two files I wrote about earlier.
Similar Posts:
- Resolving vertically flipped images from webcams in Ubuntu
- How to install VMware Server 2.0.x on Ubuntu 9.10 Karmic Koala
- How to install VMware Server on 2.6.31 kernels
- Adobe Reader in Ubuntu
- How to install Oracle Database 10g XE and OC4J on Ubuntu



54 Comments
Alchemist said
on November 13th, 2009,
at 03:51 hours
Perfect.
I’ve struggled with this for so long. None of the kernel patches worked (and I really don’t like patching my kernel)
This has worked like charm (Asus B50A, Ubuntu 9.10, KDE)
Thanks a mighty lot, from Nairobi, Kenya.
TataLor said
on November 14th, 2009,
at 21:15 hours
Hello,
Thanks for the solution!
Works on Asus N50vc.
Alchemist said
on November 14th, 2009,
at 21:51 hours
Wait! After a restart it’s upside down again!
Radu said
on November 14th, 2009,
at 22:19 hours
@Alchemist: I forgot to add the line regarding the
LD_PRELOADvariable. It should work now.vacant79 said
on November 17th, 2009,
at 02:01 hours
this doesn’t seem to work for me (i cut and past the four commands as you have them into terminal, but the cam is still flipped).. i have a n10e (running karmic)…
so i guess i should check with hans whether the cam is in his library… but i’m not sure how to get the info he needs from the 2 files (sorry, i’m still new at all this linux stuff).. on the site you link to he says:
If you have such a laptop can you please mail the output of the following commands:
lsusb > lsusb.log
dmidecode > dmi.log
…when i type those two commands (as written there) into terminal, nothing happens… am i supposed to add something to those commands to make something happen?
thanks
Radu said
on November 17th, 2009,
at 02:18 hours
When you ran those commands, their output was written in those two files (
lsusb.loganddmi.log). The files can be found in the folder where you have run the commands (if you just opened a terminal, that folder should be your home directory).vacant79 said
on November 17th, 2009,
at 02:24 hours
excellent, they are, thanks.
Christian said
on November 18th, 2009,
at 02:07 hours
I copypasted everything – it didn’t work (ASUS X5DIJ, Karmic Koala). Then I checked the preloader of Hans’ webpage. It is shorter:
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype
(in the case of Skype)
No it works perfectly. Thank you very much!
vacant79 said
on November 18th, 2009,
at 14:11 hours
it also works for me now (on my n10e) with the shorter pre-loader mentioned in the christian’s post above (i also first sent the two files to hans, who then i think updated the library)… and as with the post above, i do need to use the preloader to get the webcam flipped right way up for skype.
radu, you mention a ‘more elegant solution’ to using terminal to launch…. i was hoping i could just put LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype into the command line in skype (properties) under main menu (admittedy, i don’t really know what i am doing)… but that does not seem to work…i don’t suppose you could tell me how to do it.
thanks.
Radu said
on November 18th, 2009,
at 14:20 hours
You can make a Skype wrapper script like this:
which could be saved in
~/bin/skypeWrapper.sh, as this folder is automatically added to thePATHvariable. Remeber to make the script executable. Then, for the Skype launcher in the main menu use this wrapper script.Radu said
on November 18th, 2009,
at 14:29 hours
Or better yet… Make a general wrapper for all webcam applications similar to the one above:
Save the script in
~/bin/webcamWrapper.sh, make it executable and then for each application that needs the library loaded in its menu entry, for the command field, write something likevacant79 said
on November 18th, 2009,
at 21:35 hours
that works perfectly, thanks.
Michael said
on November 18th, 2009,
at 22:08 hours
Hello Radu,
your patch is great and I thank you for providing it.
I implemented it right now ( using debian lenny with 2.6.30-bpo.2-amd kernel) and it works the first time on my laptop
after a couple of weeks headache.
Regards Michael
Saso said
on November 21st, 2009,
at 19:35 hours
I did everything and works fine. I don’t even have to write the command:
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so application_name
It just works. Thank you a lot.
Nicholas said
on November 22nd, 2009,
at 00:46 hours
From the cli I ran
nicholas@cc-ubuntu-nicholas:~$ webcamWrapper.sh skype
ERROR: ld.so: object ‘/usr/lib/libv4l/v4l1compat.so’ from LD_PRELOAD cannot be preloaded: ignored.
Gtk-Message: Failed to load module “canberra-gtk-module”: /usr/lib/gtk-2.0/modules/libcanberra-gtk-module.so: wrong ELF class: ELFCLASS64
[]
And the cam is still upside down. Any ideas on this error?
Radu said
on November 22nd, 2009,
at 01:04 hours
It seems that the library hasn’t created that file. What system are you running: 32-bit or 64-bit?
Xiang-Jun said
on November 22nd, 2009,
at 23:35 hours
Thanks for the post. I have struggled for a couple of hours elsewhere. I followed the instructions here, but my webcam image is still upside down in Skype. For reference, I have a laptop SONY VAIO VGN-FZ140N, running Ubuntu 9.10. The webcam model is:
Bus 001 Device 002: ID 05ca:1837 Ricoh Co., Ltd Visual Communication Camera VGP-VCC4 [R5U870]
I have sent Hans an email with the two log files requested, and will report back when I make any progress.
Best regards,
Xiang-Jun
amer said
on December 3rd, 2009,
at 13:44 hours
it si all working fine but i can only run skype from terminal.
i cant make this script? can you help me. i did all from this how to. but it dose not work.
can you explain it to me a bit more, i am a noob in ubuntu.
Bwsmith7 said
on December 6th, 2009,
at 12:56 hours
Thank you so much! I just started using Linux last week and this has been the most frustrating problem for me. Thanks for making it so simple that a person who is completely computer-retarded could understand and implement it:-) This removes the last obstacle to my total adoption of Ubuntu!
Radu said
on December 6th, 2009,
at 12:58 hours
Another happy Linux user!
Bwsmith7 said
on December 6th, 2009,
at 13:05 hours
I admit that towards the end I was copying and pasting your suggestions somewhat at random (I’m still trying to understand what a repository is), but somehow it all worked out. I used the preload and Skype worked fine, I then opened Cheese normally, w/out the preload, and it also worked fine. I didn’t create the wrapper script either, if that matters. Anyway, thanks again!
glavkos said
on December 10th, 2009,
at 22:27 hours
I try to fix that problem but when i give the following command , i get this output:
What shall i do next?
Radu said
on December 10th, 2009,
at 22:39 hours
Make the script executable:
chmod +x webcamWrapper.shglavkos said
on December 10th, 2009,
at 22:44 hours
glavkos@glavkos-laptop:~$ chmod +x webcamWrapper.sh
chmod: αδυναμία πρόσβασης του «webcamWrapper.sh»: No such file or directory
No such file exists in my directory…What should i do to create it?
Radu said
on December 10th, 2009,
at 22:59 hours
I wrote in the post that you should create a script (which basically means to write a text file with that contents) and then use it as indicated. You are trying to run commands against a file that isn’t there… Btw, for how long are you using Linux?
glavkos said
on December 10th, 2009,
at 23:16 hours
Well i am a newbie…
I tried to create such a file with Gedit and to save it to bin directory , but i get a message that my try is cancelled or smth like that….
thank you very much for your help anyway…
Radu said
on December 10th, 2009,
at 23:29 hours
~/stands for your home directory, which according to your comments is/home/glavkos. Therefore~/binmeans/home/glavkos/bin, which is different from/binwhich is thebinfolder inside of/.As a conclusion, create that
webcamWrapper.shin/home/glavkos/bin. Before messing your system, try learning the Linux file & folders structure and learn some basic terminal commands.glavkos said
on December 11th, 2009,
at 17:23 hours
* edit the menu launchers for the applications that use your webcam so that their command entry looks like webcamWrapper.sh “previous command w/ args”
Which are the menu launchers …(i use skype , ekiga and cheese) …would you be so kind to explain?
Radu said
on December 11th, 2009,
at 21:56 hours
Yeah… Go to System -> Preferences -> Main Menu… You should be okay from here.
glavkos said
on December 12th, 2009,
at 11:33 hours
I am so grateful to you Radu…you are fantastic.
This was my last hardware bug and noone could give me an answer. (not in lauchpad or in greek ubuntu forum)….
In addition i must comment that i had cleared my windows partition , depending only on Ubuntu Karmic (because this time i was decided to jumb to linux).
I am very grateful to you (if you will need anything from Greece or something else i can do for you , do not hesitate to ask me ) …
My best regards , Glavkos
random dude said
on December 19th, 2009,
at 22:47 hours
oh well,
i followed the 3 steps, then created webcamWrapper.sh and tried running webcamWrapper.sh cheese with old results, my camera still flipped upside down
Mark said
on December 19th, 2009,
at 23:48 hours
hi,
it seems that my device is not in the list yet, BUT. as far as i understand, the utility v4l2ucp should have the checkbox “flip camera” or something like that inside it too, or no?
do i run some old version of it? or it’s just that the checkbox is not there
can you please check? my screenshot is here
http://i45.tinypic.com/xmogok.png
Radu said
on December 20th, 2009,
at 12:26 hours
@random dude: Maybe your camera isn’t in the list Hans made. Try talking with him…
@Mark: I have installed
v4l2ucptoo and the checkbox you are talking about is missing. Also try to talk with Hans…Good luck to both of you!
random dude said
on December 20th, 2009,
at 20:14 hours
wow… i contacted hans and he replied to me 1 day after immediately. now my webcam is in the flipped devices list
Radu said
on December 20th, 2009,
at 20:33 hours
Yup, Hans definitely is a great performer!
Joseph said
on December 23rd, 2009,
at 22:36 hours
What about *horizontally* flipped images? Does this work for that, too?
Radu said
on December 23rd, 2009,
at 23:06 hours
If you mean mirrored images, that is strange… I mean you cannot mount a webcam in a way to obtain this. But try using the library. There’s nothing to lose.
i8bugs said
on December 26th, 2009,
at 15:22 hours
I installed libv4l-0 successfully (I can cut/paste commands like a pro) but the LD_PRELOAD launch command does not work…I get:
Failed to execute child process “LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so” (No such file or directory)
I’ll admit I have no idea what a wrapper script is. Can you break this down like I’m 6?
My other wish is that Linux application writers would include a “flip image” checkbox like Cheese does.
Radu said
on December 27th, 2009,
at 14:42 hours
If you have a 64-bit system that
v4l1compat.socould be located in the/usr/lib64/...path. Whatever achitecture you have, check that the file is there. If not, something went wrong when you installed the library.ngust said
on December 27th, 2009,
at 20:52 hours
I followed your directions to the letter but my webcam is still flipped. I tried it in VLC and Skype. I have an ASUS laptop and I’m using Karmic Koala. Any advice?
Radu said
on December 27th, 2009,
at 23:41 hours
I quote myself: “If you have followed precisely these instructions and your webcam still doesn’t display your images with the right orientation, then you should check with Hans that your webcam is included in his library, by providing him the two files I wrote about earlier.”
Good luck!
cube said
on December 31st, 2009,
at 18:45 hours
Thank you so much!
Been trying to get my webcam the right way round on my Asus X5DIN with the built-in webcam.
Installed the latest v4l as described above.
However, as I’m using 64-bit Ubuntu and was using the 32-bit version of Skype, I had to specify the lib32 folder.
i.e: LD_PRELOAD=/usr/lib32/libv4l/v4l1compat.so
Thank you for the simple and (very) quick solution!
pmvalente said
on January 5th, 2010,
at 19:38 hours
It works for me, Asus UL30A. Ubuntu Karmic 64 bits.
Thanks.
titi38 said
on January 8th, 2010,
at 00:08 hours
hello,
I have a pc asus X661Cseries and my webcam still doesn’t display my images with the right orientation.
My version of Linux : Ubuntu 9.10 Karmic Koala – Kernel 2.6.31-17-generic-pae 32 bits version.
I have followed precisely yours instructions :
echo -e “\n# libv4l PPA\ndeb http://ppa.launchpad.net/libv4l/ppa/ubuntu `lsb_release -c | awk ‘{print $2}’` main” | sudo tee -a /etc/apt/sources.list
sudo apt-key adv –recv-keys –keyserver keyserver.ubuntu.com C3FFB4AA
sudo apt-get update
sudo apt-get install libv4l-0
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so /usr/bin/cheese
My webcam is referenced : CNF7129
Thanks for your help.
Radu said
on January 9th, 2010,
at 13:12 hours
@Philippe: Try talking to Hans then. Maybe your webcam model isn’t in the library yet…
stéphane said
on January 20th, 2010,
at 23:59 hours
Work find for me, Thank’s very much
On Asus N61VG-JX075V
The webcam is : 04f2:b071 Chicony Electronics Co., Ltd 2.0M UVC WebCam / CNF7129
I just have to read all the thread.
Thank’s again
Florin said
on January 22nd, 2010,
at 11:39 hours
If you use an ATI proprietary graphics driver, you might need to uninstall and reinstall it – you’ll notice this by not getting X started properly after a reboot or log out. It gets damaged (at least on my notebook) whenever there are some significant changes in the system. To uninstall it, run
/usr/share/ati/fglrx-uninstall.sh. To reinstall it, just run the.runfile you downloaded from ATI when you first installed.Nicholas Alipaz said
on January 28th, 2010,
at 01:27 hours
I have tried with both lib32 and lib64 with no flipping of the cam. It also seems that I always receive errors.
I am on Ubuntu 9.04 64bit
Radu said
on January 28th, 2010,
at 01:42 hours
Nicholas, you seem to supply a wrong path for that library. Check to see where you have the
v4l1compat.sofile:Nicholas Alipaz said
on January 29th, 2010,
at 07:49 hours
Thank you very much. That took care of it. You have a great blog btw.
dehumanizer said
on January 29th, 2010,
at 21:27 hours
Thank you very much, Radu!
onemyndseye said
on February 1st, 2010,
at 09:07 hours
For 64bit users:
It is important to note that Skype is NOT a 64bit application:
and as such you much reload the 32bit v4l1compat.so like so:
You cant reload a 64bit lib into a 32bit app:
Thanks for the great info!
Grzesiek2305 said
on March 1st, 2010,
at 00:13 hours
Bus 002 Device 002: ID 064e:a116 Suyin Corp.
my camera dont work is upside down ?:(
koolw said
on March 1st, 2010,
at 03:16 hours
thanks!!!
Think you've got something to say?