HTML5 视频标签是否有 "async" 模式?

Is there an "async" mode for HTML5 video tag?

我想将一些视频从本机 C++ 应用程序流式传输到浏览器。目前,我正在使用 GStreamer 将我的内容(例如,从相机捕获的内容)转换为 theroa ogg 流到 tcp 服务器:

gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! videoscale ! video/x-raw,width=320,height=240 ! theoraenc ! oggmux ! tcpserversink host=127.0.0.1 port=8080

然后我写了一点 html5 页作为:

<!DOCTYPE html>
<html>
  <body>

    <video width="320" height="240" autoplay>
      <source src="http://localhost:8080" type="video/ogg">
      Your browser does not support the video tag.
    </video>

  </body>
</html>

但问题是这个html5视频播放器不是实时视频播放器。它总是尝试缓冲少量的流媒体和播放,导致周期性暂停。缓冲的视频会留在那里,视频的总长度会增加,我们可以找回播放过时的内容(我们可以通过在 video 标签中启用 controls 属性来看到这一点)。

因此,我的问题是:html5 视频播放器中是否有一个 "async mode",以便它始终播放最新帧而忽略历史内容,或者我应该查看其他内容建立这个小型直播服务?

您可以使用 Media Source Extensions 更好地控制缓冲。

https://developer.mozilla.org/en-US/docs/Web/API/Media_Source_Extensions_API

在此模式下,您可以直播并完全丢弃所有旧内容。

在我看来,您实际上需要更大的缓冲区...或者更可能需要更多 CPU。