最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Using websocket to stream in video tag - Stack Overflow

programmeradmin3浏览0评论

I'm trying to stream a (WebM or MP4) video from Node.js to HTML5 using websockets (the websocket library is Socket.IO on both server and client). The browser in use is the latest version of Chrome (version 26.0.1410.64 m).

I saw here that it's possible to push a video stream in the video tag from a file using the MediaSource object.

My idea is to read chunks of data from the websocket instead of a file. Can someone please post an example using websockets to acplish that or explain me how to do it?

Thanks in advance.

I'm trying to stream a (WebM or MP4) video from Node.js to HTML5 using websockets (the websocket library is Socket.IO on both server and client). The browser in use is the latest version of Chrome (version 26.0.1410.64 m).

I saw here that it's possible to push a video stream in the video tag from a file using the MediaSource object.

My idea is to read chunks of data from the websocket instead of a file. Can someone please post an example using websockets to acplish that or explain me how to do it?

Thanks in advance.

Share Improve this question edited May 23, 2017 at 11:48 CommunityBot 11 silver badge asked May 10, 2013 at 16:36 MastErAldoMastErAldo 6743 gold badges14 silver badges30 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

In addition to the text (string) messages, the WebSocket API allows you to send binary data, which is especially useful to implement binary protocols. Such binary protocols can be standard Internet protocols typically layered on top of TCP, where the payload can be either a Blob or an ArrayBuffer.

// Send a Blob
var blob = new Blob("blob contents");
ws.send(blob);

// Send an ArrayBuffer
var a = new Uint8Array([8,6,7,5,3,0,9]);
ws.send(a.buffer);

Blob objects are particularly useful when bined with the JavaScript File API for sending and receiving files, mostly multimedia files, images, video, and audio.

Also i suggest to see WebRTC (Technology associated with WebSockets) Web Real-Time Communication (WebRTC) is another effort to enhance the munication capabilities of modern web browsers. WebRTC is peer-to-peer technology for the Web. The first applications for WebRTC are real-time voice and video chat. WebRTC is already a pelling new technology for media applications, and there are many available sample applications online that enable you to test this out with video and audio over the Web. Please check this link

发布评论

评论列表(0)

  1. 暂无评论