Open Bug 1622628 Opened 4 years ago Updated 7 months ago

v4l2loopback camera not detected by webRTC

Categories

(Core :: WebRTC: Audio/Video, defect, P3)

74 Branch
defect

Tracking

()

Tracking Status
firefox-esr68 --- ?
firefox75 --- affected
firefox76 --- affected
firefox77 --- affected
firefox78 --- affected
firefox79 --- affected
firefox85 --- affected

People

(Reporter: contact, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0

Steps to reproduce:

I have a setup with 2 physical USB cameras. I use OBS under KUbuntu 18.04 to create a composite video feed from them.

I created a loopback video device with the latest v4l2loopback (compiled from the git repo https://github.com/umlaeute/v4l2loopback) with the exclusive_caps setting on, and I used the v4l2sink plugin for OBS to stream the feed through that video device.

I then tested the setup at https://webrtc.github.io/samples/src/content/devices/input-output/.

Actual results:

Opening the webrtc test page in Chromium 80.0.3987.87 allows me to select the loopback device ; it bears the name that I set up with the card_label option of the v4l2loopback kernel module and the video image is as intended.
I am also able to select that webcam and feed in eg. guvcview.

However, opening the above webrtc test page, or any page that prompts for a camera, does not show that virtual webcam. Only the physical USB cameras are listed, each of them twice (that point is not new and also happens without the virtual cam being created).

Expected results:

I would have expected the virtual webcam to be listed and to be able to use it.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → WebRTC: Audio/Video
Product: Firefox → Core

I am trying to reproduce this, I have left the configuration in the middle. I am doing it with Gstream first because it is used by mochitest and must be working.

Flags: needinfo?(achronop)

In case this is of any help : the latest Skype app also detects the virtual cam while the client for Zoom.us does not.

I've been besting this too and noticed similar problems.

Environment:

  • Debian buster
  • linux 4.19.0-8-amd64
  • v4l2loopback-dkms 0.12.1-1
  • firefox-esr 68.5.0esr-1~deb10u1
  • chromium 79.0.3945.130-1~deb10u1

In short, when using Firefox,

  • it works for some sites based on JsSIP, and JSCommunicator. I tried
    fedrtc.org , freephonebox.net and tryit.jssip.net
  • it didn't work for Jitsi Meet, the virtual webcam doesn't appear in the
    popup asking for authorization

A very basic gstreamer script is being used to feed the loopback device.
The gstreamer script uses the alpha and composite blocks to do
chromakeying, for example, swapping the background. For anybody who wants
to reproduce the problem or simply try the same things
with your webcam, here is the script in Gitlab:
https://gitlab.com/freertc/gstreamer-chroma-key

If I run it at Full HD with a high frame rate and the CPU can't keep
up, the video can be viewed in guvcview but it is very erratic. When
I give the same feed to Firefox, it appears to take a snapshot of the image
when the call begins and then the image never changes after that.

I found Chromium was even more picky than Firefox when using the same
v4l2loopback feed. In Chromium, I went to chrome://setings/content/camera
before making any calls and I couldn't see the virtual webcam listed
there. As this is in the Chromium settings, it is not dependant on
which WebRTC service is being used.

I had a look at the related Chromium bug here:
https://bugs.chromium.org/p/chromium/issues/detail?id=757399

In comment 10, they mention V4L2_CAP_VIDEO_M2M*. I recompiled the
v4l2loopback module commenting out that capability and then
I checked with
v4l2-ctl -d /dev/video2 -D
to see that it was really gone. Nonetheless, Chromium still wouldn't
see the virtual webcam.

Severity: normal → S4
Priority: -- → P3

Byron, thanks for triaging this

As noted, it is working reliably in some sites but not in others: are you aware of anything the devs at Jitsi Meet could change? If they can do something differently, it reduces the imperative for Mozilla to change anything.

YS1 mentioned it doesn't work with Zoom. There are other issues with Zoom not working on Firefox, they are unrelated to v4l2loopback, e.g. audio not working:
https://www.reddit.com/r/firefox/comments/frjk31/when_using_firefox_to_access_the_web_browser/

That isn't related to this particular issue but it suggests that Zoom users will face a number of difficulties.

Any idea why this might be working for some sites, but not others? Is jitsi filtering these out somehow?

Flags: needinfo?(jib)

To clarify, I was stating that the virtual camera is also not detected by the Zoom desktop client while it is by the Skype client. I was not talking about using Skype or Zoom in Firefox or another browser. But since neither of them is open source it will probably be of little help (bar tracing their system calls ?).

(In reply to Daniel Pocock from comment #5)

As noted, it is working reliably in some sites but not in others: are you aware of anything the devs at Jitsi Meet could change?

Hi Daniel. Jitsi requires {min: 320, max: 1280, ideal: 1280} and Firefox doesn't downscale (bug 1286945) so make sure your output is within that. See https://twitter.com/jpetazzo/status/1242549310019063809 for details. If you still have problems please consider filing a separate issue since your symptoms differ from YS1's. Thanks!

YS1, does your device appear in Firefox's native picker? https://jsfiddle.net/jib1/r60bzmrs/show

Flags: needinfo?(jib) → needinfo?(contact)

I've opened a discussion about this in the Jitsi forum too
https://community.jitsi.org/t/jitsi-meet-doesnt-detect-the-v4l2loopback-webcam/51398

YS1, does your device appear in Firefox's native picker? https://jsfiddle.net/jib1/r60bzmrs/show

It does not. Only my two USB cameras are listed, each twice.
This happens even if I set up OBS not to use those cameras (they therefore become usable in Firefox) and to simply output a black image to the virtual camera.

Flags: needinfo?(contact)

The exact resolution is being specified using the command in the README.md file
https://gitlab.com/freertc/gstreamer-chroma-key

v4l2loopback-ctl set-caps "video/x-raw,format=UYVY,width=1280,height=720" /dev/video2

and matching values are used in the gstreamer script (same repository)

As I wrote earlier, JSCommunicator in Firefox can see this webcam but Jitsi Meet doesn't see it.

(In reply to Daniel Pocock from comment #11)

The exact resolution is being specified using the command in the README.md file
https://gitlab.com/freertc/gstreamer-chroma-key

v4l2loopback-ctl set-caps "video/x-raw,format=UYVY,width=1280,height=720" /dev/video2

I tired this and it brought no change in Firefox. It did make my virtual webcam not being able to stream (despite being detected) with some (not all) websites under chromium, though.

Some more observations

In the README.md for the gstreamer-chroma-key example, the command line is for 1280x720

The webcam I've been testing with is a HDSLR that only outputs 1920x1080 @ 25 fps and I had been using that resolution in my local v4l2loopback tests

I added videoscale to the gstreamer command and set

v4l2loopback-ctl set-caps "video/x-raw,format=UYVY,width=1280,height=720,framerate=25" /dev/video2

I tested again with Jitsi Meet in Firefox and now it sees the virtual webcam.

v4l2loopback doesn't currently provide the flexibility to choose resolution at runtime so it would be helpful if sites like Jitsi Meet were more tolerant or if they could give an alert to the user about unsupported resolutions.

Notice I also had to add framerate to the v4l2loopback-ctl command line. Without that, it defaults to 30 and if that doesn't match the source stream, the gstreamer command in the chroma-key script tries to do frame rate conversion which can overload the CPU for some people.

Flags: needinfo?(achronop)

The virtual camera is still not detected in Firefox 79. However the two USB cameras no longer appear each twice but only once as expected.

Virtual camera is detected in Firefox 84 though throws "AbortError" "Starting video failed". Detects and captures on Chromium 89.

Still not detected with FF 85.0.1.

under linux Virtual Camera not detected in FF 95.0.1 tested with OBS-27.1.3-r1 (v4l2loopback-0.12.5-r1)

FWIW we use a v4l2loopback virtual device for our automated tests on linux: https://searchfox.org/mozilla-central/rev/d4b9c457db637fde655592d9e2048939b7ab2854/testing/mochitest/runtests.py#747
The prerequisite to that script is that the v4l2loopback kernel module is loaded.

Also note that our linux camera backend (from libwebrtc) is a bit picky on resolutions -- it has a whitelist. So make sure your configured resolution is one of these.

The bug has a release status flag that shows some version of Firefox is affected, thus it will be considered confirmed.

Status: UNCONFIRMED → NEW
Ever confirmed: true
You need to log in before you can comment on or make changes to this bug.