使用 JavaScript 通过 websockets 传输视频

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4241992/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 11:32:50  来源:igfitidea点击:

Video streaming over websockets using JavaScript

javascriptvideo-streamingwebsocket

提问by SMiLE

What is the fastest way to stream livevideo using JavaScript? Is WebSockets over TCP a fast enough protocol to stream a video of, say, 30fps?

使用 JavaScript流式传输实时视频的最快方法是什么?TCP 上的 WebSockets 是一种足够快的协议来流式传输 30fps 的视频吗?

采纳答案by Wouter Dorgelo

Is WebSockets over TCP a fast enough protocol to stream a video of, say, 30fps?

TCP 上的 WebSockets 是一种足够快的协议来流式传输 30fps 的视频吗?

Yes.. it is, take a look at this project. Websockets can easily handle HD videostreaming.. However, you should go for Adaptive Streaming. I explain herehow you could implement it.

是的..是的,看看这个项目。Websockets 可以轻松处理高清视频流。但是,您应该选择自适应流。我在这里解释你如何实现它。

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

目前,我们正在开发一个基于网络的即时消息应用程序,支持聊天、文件共享和视频/网络摄像头。通过一些技巧,我们通过 websockets 获得了流媒体(使用 HTML5 媒体捕获从我们的网络摄像头获取流)。

You need to build a stream APIand a Media Stream Transceiverto control the related media processing and transport.

您需要构建一个stream API和一个Media Stream Transceiver来控制相关的媒体处理和传输。

回答by Nick Desaulniers

The Media Source Extensionshas been proposed which would allow for Adaptive Bitrate Streaming implementations.

媒体来源扩展已经提出了将允许自适应比特率流媒体实现。

回答by quarks

To answer the question:

要回答这个问题:

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?

使用 JavaScript 流式传输实时视频的最快方法是什么?TCP 上的 WebSockets 是一种足够快的协议来流式传输 30fps 的视频吗?

Yes, Websocket can be used to transmit over 30 fps and even 60 fps.

是的,Websocket 可用于传输超过 30 fps 甚至 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 的主要问题是它是低级的,除了传输视频块之外,您还必须处理其他问题。总而言之,它是视频和音频的绝佳传输方式。

回答by Josh Stodola

It's definitely conceivable but I am not sure we're there yet. In the meantime, I'd recommend using something like Silverlightwith IIS Smooth Streaming. Silverlight is plugin-based, but it works on Windows/OSX/Linux. Some day the HTML5 <video>elementwill be the way to go, but that will lack support for a little while.

这绝对是可以想象的,但我不确定我们还没有做到。与此同时,我建议使用Silverlight 之类的东西和IIS Smooth Streaming。Silverlight 是基于插件的,但它适用于 Windows/OSX/Linux。有朝一日HTML5<video>元素将成为主流,但会暂时缺乏支持。