t-mullen / Web-Broadcasting-Software

Broadcasting software for the web. (WBS)
https://t-mullen.github.io/Web-Broadcasting-Software/
MIT License
141 stars 25 forks source link

Incorrect video feed for UVC devices in Chrome on Linux and ChromeOS #14

Open maks opened 5 years ago

maks commented 5 years ago

Hi it seems that UVC attached devices such as usb webcams or in my case hdmi->usb dongles are not even working properly in Chrome, both on a couple of Chromebooks I have here (pixelbook on beta channel v68) and on a ubuntu 16.04 laptop running Chrome 69, though the devices are accessible just fine via native linux apps (eg. OBS) in ubuntu on same laptop. I can't try OBS on the Pixelbook as the linux container functionality there does not yet supported access to usb devies within the containers.

Interesting thing is that in Chrome on Ubuntu and on the Pixelbook, using the live demo for WBS the UVC device does show up in the list of available audio/video sources, but if selected, the video feed that is displayed is actually just for the builtin webcam not from the UVC source.

I suspect this is a bug in Chrome, but wanted to raise this here in case this is due to a bug in WBS, before I went ahead and filed bugs reports in the Chromium bugtracker.

t-mullen commented 5 years ago

Can you verify that the problem device isn't present in the array printed by this code:

window.navigator.mediaDevices.enumerateDevices().then(devices => console.log(devices))
t-mullen commented 5 years ago

Sorry, is the issue that you can see the device in the sources list, but the feed is from the default camera?

maks commented 5 years ago

Yes, sorry I didn't make that more clear. That's exactly it, I have 2 UVC devices, they both show up in the sources list but selecting them just displays the built-in webcams actual video content.

t-mullen commented 5 years ago

Alright, let's make sure WBS isn't just grabbing the wrong stream. Get the device ID of the UVC device with the above snippet, and plug it into here (with dev console):

DEVICE = '78da83489276ec70f0068cba07fa4b6d797afd8b131017f72f11cb4308980ef8';  //<-- deviceId

window.navigator.getUserMedia({audio:{exact:DEVICE}, video:{exact:DEVICE}}, (stream) => {
  var vid = document.createElement('video');
  vid.srcObject = stream
  vid.controls = true
  document.body.appendChild(vid)
}, (err) => console.error(err))

If the created video element shows your UVC stream, we know it's just a logic bug. Otherwise, we have a nice way to reproduce with Chrome.

maks commented 5 years ago

Thanks. I don't have access to the devices at the moment so I'll try this once I have them again tomorrow.

maks commented 5 years ago

Sorry to take so long to reply, I didn't have access to my gear for a little while. In the meantime I got a simpel uvc webcam (Logitech c270) which demonstrates exactly the same issue I was seeing wit my other devices.

I've done some tests with the snippets above and it shows the same (first video src) each time, despite using a different videoinputs deviceId.

However I have been able to hack up a version of the webrtc sample demo which does allow me to ahve both video inputs displaying in separate

I'll keep investigating more the next time a have a chance.