85
votes

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?

4
Gert G: What would you recommend? I'd prefer to keep memory consumption relatively low, that's why JS (updating a HTML5 canvas) seems like a better option, if it can offer a good enough speed.SMiLE
Oops, forgot to mention that I'm interested in live streaming, not just streaming of some video stored in a file. Can <video> offer that?SMiLE
I wouldn't be so concerned about the streaming part, but rather how you'd render video streamed in such a way. Is that even possible?deceze♦
To the speed naysayers, these are examples of fast frame and video rates using HTML 5: The Wilderness Downtown (Chrome, video) thewildernessdowntown.com and Quake in HTML 5 (Chrome, frame rate) techcrunch.com/2010/04/01/google-html5-quake A couple proofs of concept. It's only going to improve. Somebody will jump on the bandwagon soon enough and reap the benefits of being an early player in the market, if somebody hasn't already. Would I hold my breath for IE? I dunno'John K
Thanks for the examples, John K.SMiLE

4 Answers

84
votes

Is WebSockets over TCP a fast enough protocol to stream a video of, say, 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 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 a Media Stream Transceiver to control the related media processing and transport.

1
votes

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

0
votes

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?

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.

-1
votes

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.