41

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!)

PulseLab
  • 1,577
  • 11
  • 15
  • 1
    What camera and what OS? You may have to post a bug in the browser's corresponding bug trackers. – Benjamin Trent Nov 29 '14 at 18:56
  • @BenjaminTrent thanks - edited my question to add the OS and camera info in. I feared it might end up with going to the browsers trackers, but as neither Chrome nor Firefox seems to want to know I just wondered if maybe it was something I was doing rather than a similar problem in both browsers, anyone more versant in WebRTC than me could offer up anything I missed! E.g. does webRTC in those browsers not like certain types of input, e.g. PAL maybe? – PulseLab Nov 30 '14 at 10:08
  • 1
    @PulseLab: Can you please confirm if you have the latest drivers installed for both **StarTech SVID2USB2NS** and **Panasonic NV-DS35B** ? – Qarib Haider Dec 09 '14 at 08:30
  • Hi @SyedQarib, yes I do have the latest drivers for the StarTech device installed. The Panasonic camera doesn't have any drivers as such, it's just an S-Video out which connects through the StarTech device. Windows doesn't see what's on the other end of the StarTech device, as far as it's concerned, StarTech "is" the camera in question... – PulseLab Dec 09 '14 at 09:56
  • @PulseLab Just coming across this question, and wondered: did you try to run this through a file:// url? – mauritslamers Apr 23 '15 at 18:50
  • Is `window.URL.createObjectURL(stream);` being called only once ? – guest271314 May 04 '15 at 20:35
  • 1
    Did you try it with another WebRTC service such as https://opentokrtc.com/ok – taco May 05 '15 at 20:59
  • Are you able to access the webcam through the recommended desktop software for them (just to make sure the webcam is installed properly) ? – nha May 08 '15 at 08:56
  • such issues are hard to solve remotely if it involves hardware , anyway there are many possible solutions , so lets start to identify the issue first , please visit this url :https://www.webrtc-experiment.com/demos/MediaStreamTrack.getSources.html , and let me know if the video usb adapter gets detected . – ProllyGeek May 08 '15 at 20:57

1 Answers1

2

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 StarTech 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.

djvg
  • 11,722
  • 5
  • 72
  • 103
DavidDomain
  • 14,976
  • 4
  • 42
  • 50
  • Is there a way to get otg usbwebcam as video input on chrome mobile.? I only see smartphone embedded front and back cameras .... – kristoph Nov 20 '20 at 05:34