You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firefox中已转移画布的captureStream无法使用问题求助

Firefox中Canvas调用captureStream失败的解决方案咨询

我有如下canvas元素:

<canvas height="500" width="500"></canvas>

可以通过captureStream捕获视频流,再将流传入video元素,同步显示canvas上的绘制内容:

<video autoplay height="500" width="500"></video>

<script>
const video = document.querySelector("video");
const canvas = document.querySelector("canvas");

const stream = canvas.captureStream(25);
video.srcObject = stream;
video.play();
</script>

另外,我还能从该canvas派生OffscreenCanvas,并将其传输到其他帧:

const iframe = document.querySelector("iframe");
const offscreen = canvas.transferControlToOffscreen();

iframe.contentWindow.postMessage(
  {
    type: "canvasTransfer",
    canvas: offscreen
  },
  "*",
  [offscreen]
);

之后在沙箱化的iframe内执行绘制操作。这套逻辑在Chrome中运行正常,但在Firefox中调用captureStream时失败,报错信息如下:

[Exception... "Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: https://2rlmz5.csb.app/src/index.js :: $csb$eval :: line 16" data: no]

请问是否有已知的解决方案?


内容的提问来源于stack exchange,提问作者lorefnon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 15:05:16