现在是否可以使用GetUserMedia API从网络摄像头读取视频流并将其直接发送到服务器进行进一步广播? [英] Is it possible now to use GetUserMedia API to read video stream from web camera and send it directly to server for further broadcasting?

查看:566
本文介绍了现在是否可以使用GetUserMedia API从网络摄像头读取视频流并将其直接发送到服务器进行进一步广播?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要构建一个使用WebRTC获取网络摄像头视频流和麦克风音频流的Web应用程序,并立即将其转换为服务器,以便进一步向多个客户端广播。该应用必须实时全双工。我的意思是这将是一种实时视频聊天。这将是某种教育应用程序。
所以问题是:现在有可能吗?我应该使用哪些技术?
我应该在后端使用WebRTC和WebSocket以及Node.js吗?或者我可以使用PHP而不是节点?我可以使用Socket.io吗?有没有其他方法来实现这一目标?可能是flash?

I need to build a web application that uses WebRTC to get web camera video stream and mic audio stream and immediatelly translate it to the server for further broadcasting to multiple clients. The app must do it in real time in full duplex. I mean it would be a kind of live video chat. It would be some sort of educational app. So the question is: is it possible now? What technologies should I use? Should I use WebRTC with WebSocket and Node.js on the backend? Or can I use php instead of node? Can I use Socket.io for that? Is there any other ways to achieve this? May be flash?

推荐答案

WebRTC中的PeerConnection API不需要后端服务器来在对等体之间进行一个或多个连接。

The PeerConnection API in WebRTC does not require a back-end server for conducting one or more connections between peers.

您唯一需要后端服务器的是作为中介来首先建立对等体之间的连接。为此,您可以使用WebSocket API,Ajax或实现此目的所需的任何其他方法。此外,是的,您可以使用PHP为WebSocket编写服务器端(或者您希望用于建立对等连接的任何方法)。这完全取决于你。

The only thing you need a back-end server for is to serve as a mediator for first establishing the connections between the peers. To that end, you can use the WebSocket API, Ajax, or any other means necessary to achieve that. Also, yes, you can use PHP to write the server-side for WebSocket (or whatever method you want to use to establish the peer-to-peer connection). It's really up to you.

目前,只有Chrome和Firefox支持足够的WebRTC API才能进行视频聊天。很快,Opera很可能会加入这个组合,但是没有人确定WebRTC是否会被添加到IE11中,而且Apple似乎无意很快就将WebRTC添加到Safari中(因为他们拥有自己的专有技术)那听起来很熟悉?!)。

At the moment, only Chrome and Firefox support enough of the WebRTC APIs to make video chatting a possibility. Very soon though, Opera will likely join the mix, but no one's sure yet whether WebRTC will be added to IE11 or not, and Apple seems to have no intention of adding WebRTC to Safari any time soon (because they have their own proprietary technology for that; sound familiar?!).

无论如何,WebRTC是你最好的选择。作为补充说明,我认为不可能使用JS将视频和音频发送到服务器,然后让服务器将该数据转发给其他对等方。相反,您需要使用WebRTC建立点对点连接,然后从那里开始。

Anyway, WebRTC is your best bet. As an added note, I don't think it's possible to use JS to send video and audio to a server, and then have the server forward that data to the other peer(s). Instead, you need to use WebRTC to establish peer-to-peer connections, and then go from there.

编辑:如果您使用的话TURN服务器,您可以通过服务器重新路由您的音频和视频数据,但这实际上是最不理想的情况,如果您使用的是WebRTC API,您仍然可以这样做。

Edit: If you use a TURN server, you can reroute your audio and video data through a server, but that's actually the least ideal situation, and you can still only do that if you're using the WebRTC APIs.

这篇关于现在是否可以使用GetUserMedia API从网络摄像头读取视频流并将其直接发送到服务器进行进一步广播?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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