使用 JavaScript 通过 websocket 进行视频流传输
使用 JavaScript 传输直播视频的最快方法是什么? TCP 上的 WebSockets 是否是足够快的协议来传输 30fps 的视频?
What is the fastest way to stream live video using JavaScript? Is WebSockets over TCP a fast enough protocol to stream a video of, say, 30fps?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的..是的,看看这个项目。 Websockets 可以轻松处理高清视频流。但是,您应该选择自适应流。我此处解释如何你可以实现它。
目前,我们正在开发一款基于网络的即时消息应用程序,支持聊天、文件共享和视频/网络摄像头。通过一些技巧和技巧,我们通过 websockets 获取流媒体(使用 HTML5 Media Capture 从我们的网络摄像头获取流)。
您需要构建一个
stream API
和一个Media Stream Transceiver
来控制相关的媒体处理和传输。Yes.. it is, take a look at this project. Websockets can easily handle HD videostreaming.. However, you should go for Adaptive Streaming. I explain here how you could implement it.
Currently we're working on a webbased instant messaging application with chat, filesharing and video/webcam support. With some bits and tricks we got streaming media through websockets (used HTML5 Media Capture to get the stream from our webcams).
You need to build a
stream API
and aMedia Stream Transceiver
to control the related media processing and transport.媒体源扩展 已提议允许自适应比特率流实现。
The Media Source Extensions has been proposed which would allow for Adaptive Bitrate Streaming implementations.
回答这个问题:
是的,Websocket可以用于传输超过30 fps甚至60 fps。
Websocket 的主要问题是它是低级别的,除了传输视频块之外,您还必须处理其他问题。总而言之,它是视频和音频的绝佳传输方式。
To answer the question:
Yes, Websocket can be used to transmit over 30 fps and even 60 fps.
The main issue with Websocket is that it is low-level and you have to deal with may other issues than just transmitting video chunks. All in all it's a great transport for video and also audio.
传输音视频时,WebSocket协议不存在瓶颈。
When transmitting audio and video, the bottleneck does not exist in the WebSocket protocol.
这绝对是可以想象的,但我不确定我们是否已经实现了。同时,我建议使用类似 Silverlight 和 IIS 平滑流式传输。 Silverlight 是基于插件的,但它可以在 Windows/OSX/Linux 上运行。有一天 HTML5
元素 将是可行的方法,但这将在一段时间内缺乏支持。
It's definitely conceivable but I am not sure we're there yet. In the meantime, I'd recommend using something like Silverlight with IIS Smooth Streaming. Silverlight is plugin-based, but it works on Windows/OSX/Linux. Some day the HTML5
<video>
element will be the way to go, but that will lack support for a little while.