Javascript blob video source

I want to display a video from a stream;

I have a nodeJS server sending an ogg video stream to the websocket port, and when the client connects to this port, it starts to receive the video stream data, but the following method does not seem to correctly understand the data as video ...

In the following context, β€œcamera” is the identifier of the html5 video tag:

function connectWS() { var client = new BinaryClient('ws://192.168.161.193:8088'); client.on('stream', function(stream, meta) { stream.on('data', function(data) { var arrayBuffer = []; arrayBuffer.push(data); var video = new Blob([new Uint8Array(arrayBuffer)], { type: "video/ogg" }); document.getElementById('camera').src = (window.URL || window.webkitURL).createObjectURL(video); }); }); } 

Someone seems to already have a video block running, but I can't find how ...

Display Javascript Blob Video

Thanks!

+4
source share
1 answer

stream.ondata launched every time a new piece of data is received.

You tried to create a new block several times in stream.ondata .

I think you could create a new blob only once in client.onstream and insert data into it several times.

+3
source

Source: https://habr.com/ru/post/1500300/


All Articles