New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 3769 link

Starred by 15 users

Issue metadata

Status: Untriaged
Owner: ----
NextAction: ----
OS: ----
Pri: 2
Type: Patch

issue chromium:494698

Show other hotlists

Hotlists containing this issue:

Sign in to add a comment

Webcam upside down on Fujitsu T730 running Ubuntu 14.04

Reported by, Sep 2 2014

Issue description

On the apprtc demo my webcam is upside down.
I'm using a Fujitsu T730 laptop running Ubuntu 14.04 (64 bit).

In desktop apps like Cheese the webcam orientation is correct.

In Firefox 31 the webcam is upside down like in Chrome but with lib4vl it is fixed:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libv4l/ && firefox

When running Chrome with libv4l the webcam video is black:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libv4l/ && google-chrome
Project Member

Comment 1 by, Sep 3 2014

First of all, WebRTC requests v4l2 on Linux.
Could this cam work properly on Win?

Yes, on the same laptop, the cam works properly with Windows 7 in Chrome.
Project Member

Comment 3 by, Sep 3 2014

Could you please help to debug this problem since you can reproduce it at your side, to see if it's a problem in its driver or in webrtc? I suppose the easiest way is to try with webrtc standalone.
Do you mean compiling webrtc as explained here?
Or is there A binary I can download for standalone webrtc?
Project Member

Comment 5 by, Sep 4 2014

Yes, you can build webrtc on Linux according to the getting-started page. And test/debug with ./out/Debug/vie_auto_test. The capture codes is at 
Since it sounds like a target specific issue and you have the replication, so please help to figure it out and possibly work on a patch.
I've built webrtc and run ./out/Debug/vie_auto_test.
When running the simple loopback call I see the webcam upside down.

Do you want me to run other tests?
How do you want me to debug it?
Project Member

Comment 7 by, Sep 5 2014

I suppose you could start to debug with Try to compare the capture format/data with a working case. 
Also try a external USB camera to see if it works on that machine or not.
I think it's important to figure out if this is a system issue or a webrtc issue.
There is a known problem with laptops that have the camera mounted upside down.

The V4L2_IN_ST_VFLIP is set when the camera should be flipped:
And it is used here:

Should v4l2 do it automatically or should WebRTC flip the camera when the flag is set?
Project Member

Comment 9 by, Sep 8 2014

Good to know!
From the post, it seems that the libv4l would do the flip for the App. And your test shows libv4l won't work for Chrome. Would it work with vie_auto_test?

+devs for more comments!
External USB camera works fine.
The camera is upside down in the "simple loopback call" in vie_auto_test.

There are probably two options:
- libv4l knows that the camera is upside down but Chrome need to ask it to fix it.
- Chrome uses an older version of libv4l than that installed in Ubuntu 14.04 which makes cheese (desktop app) work and Firefox work with
So Chrome currently ignore 

Brave, can you file a Chrome issue and assign to magjed? 
Project Member

Comment 12 by, Sep 9 2014

Project Member

Comment 13 by, Sep 10 2014

It should be same for Chrome to handle V4L2_IN_ST_VFLIP directly or handle it through libv4l(which doesn't work well with Chrome currently).

@ofirr, since we don't have such a device to verify the fix here, it's better for you to help on it. Here is the proposed patch to handle the flip inside chrome, If you have a chromium building, you can apply it and test directly. If you don't, please merge and test it with vie_auto_test with webrtc standalone.
I've applied the patch but the webcam is still upside down.
When I replace the patch and force SetRotation(180) it does flip the camera vertically so something is wrong with the if statement.
Project Member

Comment 15 by, Sep 11 2014

@ofirr, could you please help on the patch and upload it? Since you are the only one having the target device.
@ofirr, can you replace the patch with:

// Check sensor orientation
struct v4l2_input input;
input.index = 0;
if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_ENUMINPUT, &input)) == 0) {
  LOG(ERROR) << "###### SENSOR ORIENTATION: 0x" << std::hex << input.status
             << " #######";
} else {
  LOG(ERROR) << "###### Failed to enumerate video input ######";

Compile and run 
./out/Debug/chrome ''
and look for the error messages in the terminal. I get
[12413:12520:0911/] ###### SENSOR ORIENTATION: 0x0 #######
on the first line in the terminal. Hopefully you will get something different from 0x0.

I'm getting the same
[16837:16914:0911/] ###### SENSOR ORIENTATION: 0x0 #######

Comment 18 by, Sep 11 2014


This wont work that way. Chromium must use libv4l to benefit from the upside down table logic. You can see a boilerplate patch here:

If I find time during weekend I'll try to come up with a patch.


Comment 19 by, Sep 13 2014


I have problems compiling Chromium on my Debian Sid. Something with the NaCl crt stuff fails to build. Therefor the attached patch is compile tested only.

With this patch the media library utilizes the libv4l2 library to handle webcams. libv4l2 contains mostly two things:
1) An upside down table: if a notebook (DMI information) and the built-in webcam is known to be upside down then libv4l flips the image to the correct orientation

2) Colorspace converter: some cheap webcams only deliver an obscure internal format like raw Bayer patterns or even more quirky things. It is general understanding that these fomrats should not be handled in kernel level but in userspace instead. libv4l known how to convert these formats to YUV and RGB. During the enumeration it adds fake pixel formats to the cameras supported list and does the conversion on the fly.

libv4l is bundles in most distributions since 2009. It is utilized by vlc, gstreamer, xawtv, etc. It's license is LGPL2.1+ so adding it a a Chromium dependency should be safe.

Ofir, could you please build and test the patch?

I've applied the patch but the camera is still upside down.
This is what I've tried:
git apply chromium-use-libv4l2.diff 
ninja -C out/Debug chrome
out/Debug/chrome --no-sandbox

Comment 21 by, Sep 14 2014


Mea Culpa. The ifdef guard contained an extra underscore. Could you please test with the new patch? At my remote system it looks much better:

$ nm out/Debug/chrome|grep v4l2
                 U v4l2_close
                 U v4l2_ioctl
                 U v4l2_mmap
                 U v4l2_munmap
                 U v4l2_open

13.0 KB Download
This patch fixes the camera for me (0001-Use-libv4l2-for-Linux-V4L-grabber.patch).

In the previous patch I saw a problem with installing the libv4l package when running but you probably fixed that.

Thank you for your awesome fix.

Project Member

Comment 23 by, Sep 15 2014

@per & Pmagjed, please help to evaluate the patch in #21. If it's good to go, I could help to file a crbug for it.

Comment 24 by, Sep 29 2014

Labels: Area-GetUserMedia-Webcam
Project Member

Comment 25 by, Dec 17 2014

Labels: -Type-Bug Type-Patch
Project Member

Comment 26 by, Jan 7 2015

Labels: -Area-GetUserMedia-Webcam Area-Webcam
Project Member

Comment 27 by, Mar 12 2015

Magnus - can you take a look at the patch in #21?
Project Member

Comment 28 by, Mar 16 2015

I think it's best to ask posciak about this. libv4l2 is added to Chromium now, at least for ChromeOS, see: http://crbug/405861.
Yes, use of libv4l should fix this. We have not enabled it for linux. Please feel free to do so.

Comment 30 by, May 31 2015

I hope v4l to be enabled for linux cause my camera is upside down. I'm using firefox because i don't have a choice. It works fine with v4l , but i don't like that heavy and buggy browser. I love Chrome! ;)

Comment 31 by, Sep 23 2015

One year later and still nothing??
Sorry, I’m not working actively on this. The patch looks simple, but I don’t know what's the best way to enable libv4l2 for linux and how to modify the build dependencies.

posciak@ - Can you enable libv4l2 for linux?
Any progress on this? Any way to work around it without having to compile?
I fear my patch fell victim to code changes since September 2014 and is not applicable anymore.

As far as I can tell libv4l gets used for some input/output conversion in Chromium or Chrome OS. This patch would have to play nicely with that other code path.

If some committers could give me advise or prepare a patch to add the libv4l dependency properly I would start working on the issue, again.
Project Member

Comment 35 by, Apr 15 2016

posciak@ - Can you prepare a CL to properly add the libv4l dependency, or triage to someone who can?
Blockedon: chromium:494698
Blocking: chromium:494698
Blockedon: -chromium:494698
2 years and still no progress? 

I'm forced to use external webcam for Chrome + GoToMeeting for a few years already (Ubuntu 14-16 on Asus U36 laptop)

Please help.
Owner: ----
Status: Available (was: Unconfirmed)
Project Member

Comment 41 by, May 25 2016


Comment 42 by, Dec 24 2016

I'm interested in seeing libv4l used under Linux, as I have a laptop (Asus K40AB) on which the webcam image is displayed correctly in libv4l2 applications (cheese, etc.) and in Firefox with the LD_PRELOAD, but is flipped in Chromium.
Same issue here with chromium, chrome and electron based apps (e.g. wire-desktop), on Asus U36SG and 4.8.17-1-MANJARO x86_64.
This issue is now causing problems with the webcam in skypeforlinux, as it seems that it uses chromium on linux as backend. Was there any development in the last time? 
Project Member

Comment 45 by, Dec 7

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

Sign in to add a comment