Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebRTC can't get a video feed from a USB input device (readyState goes to ended)

I'm trying to use WebRTC to display a video input on-screen as a live feed. I'm not trying to do any peer-to-peer communications or anything like that, just display a video feed.

The code I have works fine for my laptops integrated webcam, but when I connect an external video input device (in this case an old camcorder connected via S-Video to a USB input using a StarTech converter - model number SVID2USB2NS) I get nothing. I've tried this in both Chrome and FireFox.

Both browsers find the video device and offers me the choice of my integrated webcam or the USB device (listed as "USB 2820" in this case), so they are aware of the device in this case.

In Chrome, when I try to connect, the "success" callback of the getUserMedia call is called, if I .getVideoTracks() I find the MediaStreamTrack, and the moment of the callback, the MediaStreamTrack returns enabled = true and readyState = live. However there's no video input (just a black video panel, and the little red "recording" icon in the Chrome browser tab doesn't appear). If I check the MediaStreamTrack a second later, I find that readyState now = "ended" (although enabled is still true).

In FireFox, again, the device is found, but any attempt to connect to it using getUserMedia just fires the error callback, with a HARDWARE_UNAVAILABLE error.

My getUserMedia call is simply:

navigator.getUserMedia({ audio: false, video: true }, _webRTCsuccessCallback, _webRTCerrorCallback); 

and my success callback is (including some test code to check the MediaStreamTrack immediately and one second later):

function _webRTCsuccessCallback(stream) {     window.stream = stream; // stream available to console     if (window.URL) {         _video.src = window.URL.createObjectURL(stream);     } else {         _video.src = stream;     }     var tracks = stream.getVideoTracks();     if (tracks[0]) {         console.log(tracks[0]);         setTimeout(function () { console.log(tracks[0]); }, 1000);     } } 

(where _video is the html5 object on the page)

Firefox version 31.0

Chrome version 39.0.2171.71 m

OS version: Windows 7 Ultimate (6.1.7601) SP1

S-Video to USB converter: StarTech SVID2USB2NS (http://www.startech.com/AV/Converters/Video/USB-S-Video-Capture-Cable~SVID2USB2NS)

Source camera: Panasonic NV-DS35B (Digital Video Camera)

Does anyone have any ideas what's causing this, and why WebRTC won't play ball with this device?

(in more general terms, I know the device is sending a video signal to the PC, as in IE I have developed an ActiveX control that uses DirectShow to get the video feed, and it collects the feed just fine - different technology I appreciate, but it does give me evidence that the device is there and sending video!)

like image 232
PulseLab Avatar asked Nov 27 '14 15:11

PulseLab


1 Answers

The specs on Media Capture Streams state that during the life-cycle of a MediaStreamTrack the live state may be replaced by zero-information-content if the MST has either been "muted" or "disabled".This will result in rendering black frames.

In other words media can only flow from the source if the MST is both, unmuted and enabled.

The muted/unmuted state reflects if the source provides any media.

The enabled/disabled state determines whether the track outputs media.

Make sure that no other application is using your source device. In your case the StarTrack converter. Close all other applications that might gain access to your capture device while you try to getUserMedia in the browser.

Visit this Working Draft for more information on MST life-cycle and flow.

Another problem may be that your device does not provide media that meets the constraints present on your media track. Your device is capable of delivering NTSC and PAL video signals. So try to adjust the constraints for getUserMedia e.g. for PAL signal like so:

{    audio: false,   video: {     mandatory: {       maxWidth: 768,       maxHeight: 576,       maxAspectRatio: 1.333,       maxFrameRate: 25   } } 

Hope that helps somehow.

like image 53
DavidDomain Avatar answered Oct 11 '22 09:10

DavidDomain