5

I am using Ubuntu 16.04 on an ASUS N61JQ laptop. When I use video call from viber or facebook (through chrome) my webcam feeds an inverted image. I am wondering how to fix it. Because two separate applications (Viber and Chrome) have this I am thinking it is not application specific.

While looking for a fix in the internet I have found many cases giving instructions on how to fix this for skype. I have run

sudo apt-add-repository ppa:libv4l/stable
sudo apt-get update
sudo apt-get upgrade

which installed libv4l-0 libv4lconvert0 and retested but no fix.

I have not followed further those solutions (e.g. here ) because viber and chrome are not 32-bit applications. I did check that viber is indeed 64-bit with the method provided here.

I am including the lines of the files that I expect I should change if I were to do something similar to the skype fix:

$ cat /usr/share/applications/viber.desktop | grep Exec
Exec=/opt/viber/Viber

and

$ cat /usr/share/applications/google-chrome.desktop | grep Exec
Exec=/usr/bin/google-chrome-stable %U
Exec=/usr/bin/google-chrome-stable
Exec=/usr/bin/google-chrome-stable --incognito

I am not sure how to modify those lines and where to find libv4l package for 64-bit, in order to implement a workaround that will make viber and chrome work properly.

In my quest to fix the underlying problem I started by looking for camera/video settings in Unity's "Search Your Computer" System Settings. But I found nothing. I also run:

$ ls /dev/video*
/dev/video1

but I don't know what to make out of that result. Also after running

sudo lshw -sanitize

I get, somewhere along a huge output:

*-usb:0
                  description: Video
                  product: USB2.0 UVC 2M WebCam
                  vendor: USB2.0 UVC 2M WebCam
                  physical id: 2
                  bus info: usb@1:1.2
                  version: 2.02
                  serial: [REMOVED]
                  capabilities: usb-2.00
                  configuration: driver=uvcvideo maxpower=500mA speed=480Mbit/s

I tried to find the driver from this but found nothing. For example:

$ ll /lib/modules/4.4.0-28-generic/kernel/drivers | grep uvcvideo

returns nothing. I also run:

$ lsmod | grep uvcvideo
uvcvideo               90112  0
videobuf2_vmalloc      16384  1 uvcvideo
videobuf2_v4l2         28672  1 uvcvideo
videobuf2_core         36864  2 uvcvideo,videobuf2_v4l2
videodev              176128  4 uvcvideo,v4l2_common,videobuf2_core,videobuf2_v4l2
media                  24576  2 uvcvideo,videodev

which (according to the internet) shows the status of the drivers. Can't interpret it though.

There should be a file of a driver somewhere that I could tinker to fix it but how do I find it?

5

I continued researching on this and I came up with a temporary solution. Information from this answer also helped.

The main difference here is that applications are 64-bit, so I could not fully follow previous solutions. After installing libv4l I needed to find an appropriate path for a 64-bit version compat file to set the LD_PRELOAD variable. After looking around I found out I could do this with:

 $ dpkg -L libv4l-0 | grep compat
 /usr/lib/x86_64-linux-gnu/libv4l/v4l1compat.so

This and Veazer's answer helped me complete the workaround by changing viber.desktop file. Important, before making changes make a backup, for example:

sudo cp /usr/share/applications/viber.desktop /usr/share/applications/viber.desktop-original

After that we have all the information we need to change the viber.desktop file. We only need to change one line. The following changes fix the problem in viber:

$ cat /usr/share/applications/viber.desktop | grep Exec
Exec=sh -c 'export LIBV4LCONTROL_FLAGS=2 && LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libv4l/v4l1compat.so /opt/viber/Viber'

Note the integer value 2 for camera inversion.

I expect the same approach to also fix chrome but I ll work on it later. Unless somebody can help me fix the underlying problem with the webcam drivers.

2
  • But unfortunately it won't work since 2017 because Skype was rewritten. Now AFAIK there is none software solution available. – G. Demecki Jun 16 '18 at 17:18
  • 2
    This worked for me for skype and firefox. Not worked for chrome. I have LinuxMint 18 which is based on Ubuntu 16.04 and Asus Laptop. – Karioki Jul 12 '18 at 11:34
5

1) Install utilities:

$ sudo apt-get update
$ sudo apt-get install v4l-utils
$ sudo apt-get install v4l2loopback-utils

2) Download v4l2loopback

3) Uncompress 'v4l2loopback-master' folder

4) Compile v4l2loopback module:

$ make

5) Install:

$ sudo make install

6) Enable device:

$ sudo modprobe v4l2loopback exclusive_caps=1

7) Check if device is enabled:

$ v4l2-ctl --list-devices

Dummy video device (0x0000) (platform:v4l2loopback-000):
  /dev/video1

USB2.0 UVC 2M WebCam: USB2.0 UV (usb-0000:00:1a.0-1.2):
  /dev/video0

8) Copy the webcam video stream to it via ffmpeg:

$ ffmpeg -f v4l2 -i /dev/video0 -vf "vflip" -f v4l2 /dev/video1

9) Open you prefered video application (skype, hangouts, zoom, ...) and select 'Dummy video device'

You can see for more details about paramters:

https://ffmpeg.org

https://www.ostechnix.com/20-ffmpeg-commands-beginners/

https://github.com/qTox/qTox/wiki/Video

3
  • I didn't need to download and compile v4l2looback after installing v4l2loopback-utils on Kubuntu 18.04. Anyway, thank you for this clever solution! – MD-11 Sep 8 '19 at 13:27
  • In my case (Ubuntu 18.04.4) the v4l2loopback module included in v4l2loopback-utils didn't work as "v4l2" output device for ffmpeg, but the v4l2loopback compiled from master worked – rbarriuso Mar 24 '20 at 22:00
  • This has worked great for me too, thank you. Is the only way to stop the stream ctrl+c once it started or is there another possibility? – Andyc Apr 13 at 10:51
3

Regarding fixing inverted/flipped laptop webcam video in Chrome/Chromium based browsers - a few days ago I updated ASUS P52F laptop to Linux Mint 18 XFCE that is on par with Ubuntu 16.04.1 now. I faced "upside down" webcam WebRTC video on hangouts and facebook using Chrome web browser only. Firefox works fine. Cheese also displays video properly.

After some googling I found this bug report. In the comment 22 you can see that 2 years ago there was a 0001-Use-libv4l2-for-Linux-V4L-grabber.patch proposed that fixes Chrome/Chromium behavior. For more then a year now libv4l2 is added to Chromium, but is not enabled for Linux. You can see the whole discussion in the bug report thread. Long story short it looks like they are not actively working on fixing this for almost a year now. However, there is some ugly workaround...

You can add Flip this extension to Chrome. It allows you to flip your webcam video or any other element of a webpage. It will flip it only locally, so people who you talk to via Chrome also need to use the same trick. It's not pretty, but it's working... well, kind of ; ) After all switching to Firefox maybe a better and more comfortable solution. Cheers!

1
  • Exactly. So since probably it will never be fixed, I've just bought an external web camera.. So the problem is solved. And finally I realized that built-in camera in Asus K-series laptops was of exceptionally low quality :) I guess almost any external camera will be better. – G. Demecki Jun 16 '18 at 16:59
3

I use Debian, and this is the solution I applied and working fine:

  1. Make sure you have the package libv4l-0 is installed, (source:v4l-utils)
  2. Locate the file: /usr/lib/x86_64-linux-gnu/libv4l/v4l1compat.so
    or /usr/lib/x86_64-linux-gnu/libv4l/v4l2convert.so
  3. Open your terminal and enter the below:

    LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libv4l/v4l1compat.so  /usr/bin/skypeforlinux
    

It will start your Skype, you login as usual, and once open, your cam should be fixed.

Good luck!!

1
  • +1 easy and working (Xubuntu_19.10@ASUSU36SD), thanks! – crysman Mar 29 '20 at 22:24
2

This worked for me on:

  • Ubuntu Desktop,
  • Ubuntu 18.04 LTS,
  • ASUS F3Eseries

Issue:

  • Skype video camera upside down
  • Skype Version 8.48

Resolve:

sudo nano  /usr/bin/skypeforlinux

Update the last line.

#!/bin/sh

SCRIPT=$(readlink -f "$0")
USR_DIRECTORY=$(readlink -f $(dirname $SCRIPT)/..)

SKYPE_PATH="/usr/share/skypeforlinux/skypeforlinux"
SKYPE_LOGS="$HOME/.config/skypeforlinux/logs"

mkdir -p $SKYPE_LOGS

echo "$SKYPE_PATH"

# was this
#nohup "$SKYPE_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > "$SKYPE_LOGS/skype-startup.log" 2>&1 &

# changed to
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libv4l/v4l1compat.so /usr/share/skypeforlinux/skypeforlinux  > "$SKYPE_LOGS/skype-startup.log" 2>&1 &
2

Install the v4l-utils package which contains the v4l2-ctl utility:

sudo apt-get install v4l-utils

Verify if your video device supports the vertical_flip option:

v4l2-ctl --list-ctrls

In the output, verify you see the control vertical_flip.

If so, then edit your .profile:

nano ~/.profile

And add to the end:

# Flip webcam video
v4l2-ctl -c vertical_flip=0
v4l2-ctl -c vertical_flip=1

(the double command is intentional)

1
  • 10
    unknown control 'vertical_flip' – Eduardo May 24 '18 at 14:44
1

Since, the Skype version 8 and above is basically a web app, the old trick with libv4l library will no longer work. I've lost many hours to just find out it's not possible anymore.

So since the software solution doesn't exist, I went towards a hardware one. I've bought an external web camera... and it works flawlessly.
Moreover: I finally realized that built-in camera in Asus K-series laptops was of exceptionally low quality. My external one is sooo much better. Finally, after many years, my callers can see me clearly, and more importantly: correctly :-)

0

I've an Asus K70IO Notebook with Ubuntu 16.04. I've faced this issue for long time.

With the LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libv4l/v4l1compat.so I've fixed the issue for Skype and MS Teams, but not Chrome.

To fix thevertical flip issue with Chrome I've written a short bash script, based on Lucio Anibal Criollo Rivera answer.

I run it before opening chrome.

#!/bin/bash

trap ctrl_c INT

function ctrl_c() {
    sudo mv /dev/video0 /dev/video1
    sudo mv /dev/video2 /dev/video0
}

sudo modprobe v4l2loopback exclusive_caps=1

sudo mv /dev/video0 /dev/video2
sudo mv /dev/video1 /dev/video0

ffmpeg -f v4l2 -i /dev/video2 -vf "vflip" -f v4l2 /dev/video0

It will create the dummy webcam and set it as the default one (this is the improvement that finally fixed the issue to me).

Tried on https://iorestoacasa.work/ and no more headaches for my colleagues.

Not the answer you're looking for? Browse other questions tagged or ask your own question.