使用getUserMedia从多个网络摄像头捕获视频 [英] Capture video from several webcams with getUserMedia

查看:1606
本文介绍了使用getUserMedia从多个网络摄像头捕获视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从连接到我的电脑的多个网络摄像头捕获视频。使用一个网络摄像头很容易,但我如何从多个来源获取视频流?
是否可以选择将哪个摄像头用于一个流?

I would like to capture video from multiple webcams connected to my pc. It is easy enough to use one web-cam, but how can I get video streams from multiple sources? Is it possible to select which camera to use for one stream?

     navigator.getUserMedia ({
         video: true 
     }, function (oMedia) {
         var video = document.getElementById ('tVideo1'); 
         video.src = window.URL.createObjectURL (oMedia); 
     }); 


推荐答案

我对你的问题很感兴趣,所以我开始研究'getusermedia multiple cameras'。

I was intrigued by your question, so I started researching 'getusermedia multiple cameras'.

经过几个小时,当我快要放弃时,我遇到了此谷歌小组讨论

After a couple of hours, when I was almost about to give up, I came across this google group discussion.

我回过头来看你的问题,看看你的目标是来自所有网络摄像头的流应该同时出现,还是你想给用户提供一个选择摄像头的选项。您似乎希望用户选择Feed。如果是后一种情况,那么在上面的链接中,Vikas(在他的8/15/2013消息中)已经描述了实现这一目标的方法。您需要启用WebRTC枚举源标志,然后使用MediaStreamTrack.getSources获取所有源并将sourceId传递给getUserMedia,例如navigator.getUserMedia({video:{optional:[{sourceId:---您的ID在这里 - - }}}},有趣,errfun);.似乎其中一个用户能够成功地使用它。

I referred back to your question to see if your goal was that streams from all webcams should appear simultaneously or if you wanted to present the user an option to choose the camera feed. It seems like you wanted the user to select the feed. If it is the later case, then in the link above, Vikas (in his 8/15/2013 message) had described a way to achieve this. You need to enable WebRTC enumerate sources flag, then use MediaStreamTrack.getSources to get all the sources and pass sourceId to getUserMedia such as navigator.getUserMedia({ "video": {optional: [{sourceId: "---YOUR ID HERE---"}]}}, fun, errfun);. And it seems one of the users was able to get it to work successfully.

这是我看到的源代码
此信息将特定于Chrome金丝雀或Firefox。我只是想我会分享它,以防你还没有碰到过这个,这可能会对你有所帮助。我已经实现了一个应用程序,其中多个网络摄像头在单个屏幕上提供,但它更简单,因为它是一个桌面应用程序。

Here's the sourcecode that I saw. This information would be specific to Chrome canary or Firefox. I just thought I would share it in case you haven't already come across this, something that might help you. I have implemented an application where multiple web camera feeds on a single screen but it was simpler because it was a desktop application.

这篇关于使用getUserMedia从多个网络摄像头捕获视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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