简体   繁体   English

来自javascript blob的视频源

[英]Video source from javascript blob

I'd like to display a video from a stream; 我想要从流中显示视频;

I have a nodeJS server sending an ogg video stream to a websocket port, and when a client connects to that port, it starts receiving the video stream data, but the following method does not seem to understand the data as video correctly... 我有一个nodeJS服务器发送ogg视频流到websocket端口,当客户端连接到该端口时,它开始接收视频流数据,但以下方法似乎不能正确理解视频数据...

In the following context, "camera" is a html5 video tag id: 在以下上下文中,“camera”是html5视频标记ID:

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 the video blob working, but I can't find how... 有人似乎已经有视频blob工作,但我找不到如何...

Display a video from a Blob Javascript 显示Blob Javascript中的视频

Thank you! 谢谢!

stream.ondata is fired every time a new chunk of data is received. 每次收到新的数据块时都会触发stream.ondata

You tried to create a new blob multiple times in stream.ondata . 您尝试在stream.ondata多次创建新blob。

I think you may wanted to create a new blob only once in client.onstream and push data into it multiple times. 我想你可能只想在client.onstream创建一个新的blob,并将数据多次推送到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM