Blank camera on Linux

Discussions about using Linux guests in VirtualBox.
Post Reply
Souravgoswami
Posts: 3
Joined: 27. Feb 2021, 10:30

Blank camera on Linux

Post by Souravgoswami »

I am trying to enable my webcam. Both my guest and host OS are running ArchLinux x86_64. I have followed these steps:

1. Downloaded VirtualBox Extension Pack from virtualbox dot org.

2. Added the user to the vboxusers and re-logged in.

3. Enabled USB 2.0 from the USB option from VM settings.

4. Added my Logitech C270 webcam.

Now when I launch the virtual machine, and run applications like cheese or visit sites like webcamtests dot com, the webcam turns on, the green LED on the camera lights up. But the image is completely blank.

System details:

• Host:

1. VirtualBox Version 6.1.18 r142142

2. Kernel:

Code: Select all

$ cat /proc/version
Linux version 5.10.16-xanmod1-cacule-1-cacule (souravgoswami@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Sat, 20 Feb 2021 17:39:12 +0000
3. vboxmanage list webcams

Code: Select all

Video Input Devices: 2
.3 "Integrated_Webcam_HD: Integrate"
/dev/video2
.4 "Integrated_Webcam_HD: Integrate"
/dev/video3
I also ran this command:

Code: Select all

$ vboxmanage controlvm "Archlinux" webcam attach /dev/video2
$ vboxmanage controlvm "Archlinux" webcam attach /dev/video3
4. Webcam list:

Code: Select all

$ vboxmanage controlvm "Archlinux" webcam list
/dev/video2
/dev/video3
• Guest:
1. Kernel:

Code: Select all

$ cat /proc/version 
Linux version 5.10.4-xanmod1-cacule-1-cacule (souravgoswami@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Sat, 02 Jan 2021 02:50:59 +0000
2. Output from lsusb:

Code: Select all

$ lsusb

Bus 001 Device 002: ID 046d:0825 Logitech, Inc. Webcam C270
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
3. Output from `v4l2-ctl --list-devices`

Code: Select all

$ v4l2-ctl --list-devices
UVC Camera (046d:0825) (usb-0000:00:0b.0-1):
	/dev/video0
	/dev/video1
If I use ffmpeg to capture the camera, same behaviour, the camera turns on, but nothing is recorded (can't play the video file).

I have also tried adding the laptop's integrated camera as well, which also has the same behaviour. The white indicator LED lights up, but no video stream.

How do I run my webcam with VirtualBox?
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Blank camera on Linux

Post by fth0 »

Thanks for your detailed description. You did not mention it, but: In the case that you created a USB capture filter, remove that. It is not only unnecessary, but could cause problems with webcams.

The standard way to use a webcam inside a VirtualBox VM is to configure nothing webcam-related for the VM, and to simply use the Devices > Webcam menu from the VM's window.
Souravgoswami
Posts: 3
Joined: 27. Feb 2021, 10:30

Re: Blank camera on Linux

Post by Souravgoswami »

Sorry I forgot to mention, I have removed the filters from the USB section before writing this.

Thanks for the info, I see the Devices -> Webcam option, which lists 2 of my webcams. I enabled one, and started a photo capturing and video recording app called cheese, but same behaviour.

Both the cameras work on the host system.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Blank camera on Linux

Post by fth0 »

I'd expect that you cannot use a webcam simultaneously on the host and in the guest (USB is a point-to-point connection), so you may have to make sure nothing is using the webcam on the host. Please reproduce the problem, shut down the guest and post a zipped VBox.log file.
Souravgoswami
Posts: 3
Joined: 27. Feb 2021, 10:30

Re: Blank camera on Linux

Post by Souravgoswami »

Well, so the problem was solved by the following:
1. Go to virtualbox's menu, look for "Devices", go to "USB", uncheck all the USB webcams.
2. Go to "Devices" -> "Webcams" -> Check the desired webcam(s).

The problem now is that, the software cheese will say no camera detected, but the camera works on Firefox, so on online meetings and exams.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Blank camera on Linux

Post by fth0 »

Souravgoswami wrote:The problem now is that, the software cheese will say no camera detected, but the camera works on Firefox, so on online meetings and exams.
I've seen other notebooks with webcams, where cheese does not work, but guvcview does, but I don't know why.
multiOS
Volunteer
Posts: 825
Joined: 14. Sep 2019, 16:51
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: WIN11,10, 7, Linux (various)
Location: United Kingdom

Re: Blank camera on Linux

Post by multiOS »

Is this of any help in identifying the problem? - https://gitlab.gnome.org/GNOME/cheese/-/issues/108
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Blank camera on Linux

Post by fth0 »

multiOS wrote:Is this of any help in identifying the problem? - https://gitlab.gnome.org/GNOME/cheese/-/issues/108
Thanks for the info, much appreciated. :)

I can confirm that using GST_V4L2_USE_LIBV4L2=1 cheese works inside a Linux Mint 20 VM in VirtualBox 6.1.18 on a Lenovo T590 notebook. Interestingly enough, this setting is not necessary in the Linux Mint 20 running natively.
Post Reply