WebRTC无法从USB输入设备获取视频(readyState转到结束) [英] WebRTC can't get a video feed from a USB input device (readyState goes to ended)

查看:590
本文介绍了WebRTC无法从USB输入设备获取视频(readyState转到结束)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用WebRTC在屏幕上显示视频输入作为实时Feed。我不想尝试任何点对点通信或类似的东西,只是显示视频源。

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.

我的笔记本电脑集成网络摄像头的代码工作正常,但是当我连接外部视频输入设备时(在这种情况下,通过S-Video连接的旧摄像机)使用StarTech转换器的USB输入 - 型号SVID2USB2NS)我什么都没得到。我在Chrome和FireFox都尝试了这个。

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.

两个浏览器都找到了视频设备并为我提供了集成网络摄像头或USB设备的选择(列为USB) 2820在这种情况下,所以他们知道这种情况下的设备。

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.

在Chrome中,当我尝试连接时,调用getUserMedia调用的成功回调,如果我.getVideoTracks()我找到 MediaStreamTrack ,以及回调时刻, MediaStreamTrack 返回已启用 = true readyState = live 。但是没有视频输入(只有黑色视频面板,Chrome浏览器选项卡中的红色录音图标不会出现)。如果我稍后检查MediaStreamTrack,我发现 readyState now =已结束(虽然启用仍然是真的)。

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

在FireFox中,再次找到设备,但是任何使用getUserMedia连接到它的尝试都会触发错误回调,并出现HARDWARE_UNAVAILABLE错误。

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.

我的 getUserMedia 电话只是:

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

我的成功回调是(包括一些测试代码来检查 MediaStreamTrack 立即和一秒后):

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);
    }
}

(其中_video是页面上的html5对象)

(where _video is the html5 object on the page)

Firefox版本31.0

Firefox version 31.0

Chrome版本39.0.2171.71 m

Chrome version 39.0.2171.71 m

操作系统版本:Windows 7旗舰版(6.1.7601)SP1

OS version: Windows 7 Ultimate (6.1.7601) SP1

S-Video转USB转换器:StarTech SVID2USB2NS( http://www.startech.com/AV/Converters/Video/USB-S-视频采集电缆~SVID2USB2NS

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

源摄像头:Panasonic NV-DS35B(数码摄像机)

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

有没有人有任何想法导致这种情况,以及为什么WebRTC不会用这个设备玩球?

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

(更一般地说,我知道设备正在向PC发送视频信号,就像在IE中我已经开发了一个使用DirectShow获取视频源的ActiveX控件,它收集了很好的源 - 我欣赏不同的技术,但它确实给了我证据设备在那里并发送视频!)

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

推荐答案

Media Capture Streams上的规范声明在MediaStreamTrack的生命周期中如果MST已被静音或禁用,则可以用零信息内容替换实时状态。这将导致渲染黑帧。

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换句话说,如果MST同时取消静音并启用,则媒体只能从源流出。

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.

确保没有其他应用程序正在使用您的源设备。在你的情况下StarTrack转换器。当您尝试在浏览器中使用getUserMedia时,请关闭可能访问您的捕获设备的所有其他应用程序。

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.

访问此工作草案,了解有关MST生命周期和流量的更多信息。

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

另一个问题可能是您的设备无法提供符合媒体轨道上存在的限制的媒体。您的设备能够提供NTSC和PAL视频信号。因此,尝试调整getUserMedia的约束,例如像这样的PAL信号:

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.

这篇关于WebRTC无法从USB输入设备获取视频(readyState转到结束)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆