处理/从WebRTC技术或使用ASP.NET MVC任何基于浏览器捕获机制服务器接收实时视频流的摄像头 [英] Handling / receiving live video webcam stream from WebRTC or any browser based capturing mechanism to the server using ASP.NET MVC
问题描述
我们需要捕捉从WebRTC技术的实时视频流(或来自客户端的网络摄像头的任何其它捕获机制,即使不支持所有的浏览器,但作为在PoC)。
此视频直播需要由服务器组件(ASP.Net MVC /网页API),我想,在服务器上的code会像处理:
[HttpPost]
公众的ActionResult HandleVideoStream(流视频流)
{
//处理实时数据流
}
寻找任何关键字还是很有帮助的链接。
我们已经实施的方式使用Base64 JPG格式发送单个帧,但这是没有作用的,因为base64编码的一个巨大的开销,因为我们可以使用任何视频编码有效地发送视频更多(发送使用VPX -vp8-例如帧之间的差),所需的解决方案需要来自客户端的网络摄像头捕捉的视频和作为流-or发送住(不记录)到服务器(asp.net)数据块重新presenting新的视频数据。 -
您的问题过于宽泛,要求异地资源被认为是题外话#2。为了避免舆论倾向的声明我将限制答案一般概念。
闪光/ RTMP
WebRTC技术
所以目前使用的从浏览器捕捉摄像头输入的应用最广泛的方法是通过一个插件还没有适用于所有浏览器。最常见的解决方案使用的Adobe Flash Player ,不管人们喜欢还是不喜欢。这是由于在最近版本的 H.264
编码的支持,以及 AAC
, MP3
等音频。
流媒体正在使用的最初设计为Flash通信 RTMP协议完成。该协议适用于 TCP
并具有多种口味像 RTMPS
( RTMP
在 TLS / SSL
用于加密), RTMPT
( RTMP
封装在 HTTP
防火墙穿越)。
流通常采用 FLV 容器格式。
您可以很容易地找到使用闪光灯捕捉摄像头输入并将其传输到一个 RTMP
服务器的开源项目。
在服务器端,你有两种选择:
- 实现基本
RTMP
服务器直接对话发送图书馆看书流 - 使用开放源代码的
RTMP
服务器之一,并在ASP
实施只是一个客户端(也可以跨code上取决于你想与您的应用程序做什么)飞输入流。
WebRTC技术
使用 WebRTC技术
您可以:
- 记录小媒体块,并上传到哪里流重构(需要串联并重新冲压块,以避免不连续)在服务器上。 <一href=\"http://stackoverflow.com/questions/25523289/sending-a-mediastream-to-host-server-with-webrtc-after-it-is-captured-by-getuser\">See这个答案的链接的。
- 使用
WebRTC技术
的对等网络通讯功能与服务器作为同龄人。
一个计时器
对于第二种情况,我还没有亲自测试然而,一个可能的解决方案是由亚当·罗奇提供的:
- 浏览器检索与它的JavaScript的网页。
- 浏览器执行JavaScript,其中:
- 获取句柄到相机中使用
getUserMedia
,
- 创建一个
RTCPeerConnection
- 呼叫
createOffer
和setLocalDescription
的
RTCPeerConnection
- 将包含报价(以
服务器的请求SDP
格式)
- 服务器处理报价
SDP
,并产生自己的答案SDP
,
它返回到其响应浏览器。
- 的JavaScript调用
setRemoteDescription
在RTCPeerConnection
启动媒体流动。
- 服务器开始接收
DTLS / SRTP
从浏览器的数据包,
它然后为所欲为就是了,直至并包括存储
在本地硬盘驱动器上的简单易读的格式。
块引用>这将使用
VP8
和Vorbis格式
在的WebM
在SRTP
(UDP
,也可以使用TCP
)。除非你能实施
RTCPeerConnection
直接在ASP
与包装,你会需要一种方法来转发数据流您的服务器应用程序。的
API PeerConnection等
是WebRTC技术
的一个强大的功能。它是目前使用由谷歌视频群聊的WebRTC技术的版本。你可以阅读:如何使用Hangouts WebRTC技术We need to capture a live video stream from WebRTC (or any other capturing mechanism from the client webcam, even if it is not supported on all browsers, but as a PoC).
This live video needs to be handled by a server component (ASP.Net MVC / Web API), I imagine that the code on the server will look like:
[HttpPost] public ActionResult HandleVideoStream(Stream videoStream) { //Handle the live stream }
Looking for any keyword or helpful link.
We have already implemented a way to send individual frames using base64 jpg, but this is not useful at all, because there is a huge overhead of the base64 encoding and because we could use any video encoding to send the video more efficiently (send the difference between the frames using VPx -vp8- for example), the required solution needs to capture a video from the webcam of the client and send it live (not recorded) to the server (asp.net) as a stream -or chunks of data representing the new video data-.
解决方案Your question is too broad and asking for off-site resources is considered off-topic on stackoverflow. In order to avoid opinion-prone statements I will restrict the answer to general concepts.
Flash/RTMP
WebRTC
is not yet available on all browser so the most widely used way of capturing webcam input from a browser currently in use is via a plugin. The most common solution uses the Adobe Flash Player, whether people like it or not. This is due to theH.264
encoding support in recent versions, along withAAC
,MP3
etc. for audio.The streaming is accomplished using the RTMP protocol which was initially designed for Flash communication. The protocol works on
TCP
and has multiple flavors likeRTMPS
(RTMP
overTLS/SSL
for encryption),RTMPT
(RTMP
encapsulated inHTTP
for firewall traversal).The stream usually uses the FLV container format.
You can easily find open-source projects that use Flash to capture webcam input and stream it to an
RTMP
server.On the server-side you have two options:
- implement a basic
RTMP
server to talk directly to the sending library and read the stream- use one of the open-source
RTMP
servers and implement just a client inASP
(you can also transcode the incoming stream on the fly depending on what you're trying to do with your app).WebRTC
With
WebRTC
you can either:
- record small media chunks on a timer and upload them on the server where the stream is reconstructed (needs concatenating and re-stamping the chunks to avoid discontinuities). See this answer for links.
- use the peer-to-peer communication features of
WebRTC
with the server being one of the peers.A possible solution for the second scenario, which I haven't personally tested yet, is offered by Adam Roach:
- Browser retrieves a webpage with javascript in it.
- Browser executes javascript, which:
- Gets a handle to the camera using
getUserMedia
,- Creates an
RTCPeerConnection
- Calls
createOffer
andsetLocalDescription
on theRTCPeerConnection
- Sends an request to the server containing the offer (in
SDP
format)- The server processes the offer
SDP
and generates its own answerSDP
, which it returns to the browser in its response.- The JavaScript calls
setRemoteDescription
on theRTCPeerConnection
to start the media flowing.- The server starts receiving
DTLS/SRTP
packets from the browser, which it then does whatever it wants to, up to and including storing in an easily readable format on a local hard drive.
This will use
VP8
andVorbis
insideWebM
overSRTP
(UDP
, can also useTCP
).Unless you can implement
RTCPeerConnection
directly inASP
with a wrapper you'll need a way to forward the stream to your server app.The
PeerConnection API
is a powerful feature ofWebRTC
. It is currently used by the WebRTC version of Google Hangouts. You can read: How does Hangouts use WebRTC.这篇关于处理/从WebRTC技术或使用ASP.NET MVC任何基于浏览器捕获机制服务器接收实时视频流的摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!