Using Node to Stream Video in HTML5

I played with node and websites and created a small test application that broadcasts audio using websockets. The server breaks mp3 using createReadStream, throttles the stream using node-throttle and accepts binary data using the "ws" module. On the client side, I pick up the pieces on the websocket and use decodeAudioData ( http://www.html5rocks.com/en/tutorials/webaudio/intro/ ) to decode and play the fragment. Everything works relatively normal.

What I was interested to do next was to stream video in the same way as the HTML5 tag. But I can not find any reference material on the Internet to achieve this in the same way as my audio test above.

Is there a video equivalent for "decodeAudioData"?

Can I transfer pieces of data to a video tag?

I have a similar sample that I took from ...

https://gist.github.com/paolorossi/1993068

But this is not quite what I am looking for. First of all, this does not seem to me streaming. The client downloads everything before playing. In addition, like my audio test, I want the stream to be throttled on the server side, so that when a new client connects, they join the video at any time in which it is currently located. those. 30 minutes or something else.

thanks

+3
source share
1 answer

Ok

I found a solution to this after repeatedly searching.

The MediaSource API is what I was looking for ...

var mediaSource = new MediaSource(); var sourceBuffer = mediaSource.addSourceBuffer('video/webm; codecs="vorbis,vp8"'); sourceBuffer.append(new Uint8Array(data)); 

This link provided a solution ...

http://html5-demos.appspot.com/static/media-source.html

+8
source

All Articles