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

为何我的Chrome浏览器中VideoEncoder不可用?

解决Chrome中"Uncaught ReferenceError: VideoEncoder is not defined"报错

VideoEncoder属于WebCodecs API,Chrome最新版本虽原生支持,但出现该报错通常和以下原因有关,对应解决方法如下:

  • 确保页面处于安全上下文环境
    WebCodecs API受Chrome安全策略限制,仅允许在HTTPS协议或localhost(本地开发环境)下访问。如果页面通过普通HTTP(非localhost)打开,API会被禁用,直接调用就会触发引用错误。切换到HTTPS或本地localhost服务即可。

  • 检查WebCodecs是否被手动禁用
    少数情况可能有人手动关闭了该功能。在Chrome地址栏输入chrome://flags/#enable-web-codecs,确认该选项设置为“Enabled”,之后重启浏览器生效。

  • 代码中增加兼容性判断
    为避免环境不支持导致的报错,建议调用前先判断API是否存在:

    if ('VideoEncoder' in window) {
      // 正确实例化VideoEncoder并配置
      const videoEncoder = new VideoEncoder({
        output: (chunk) => { /* 处理编码后的视频块 */ },
        error: (err) => { console.error('编码错误:', err); }
      });
      videoEncoder.configure({
        codec: 'avc1.42E01E',
        width: 1280,
        height: 720,
        bitrate: 5_000_000,
        framerate: 30
      });
    } else {
      console.error('当前环境不支持VideoEncoder API');
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 00:25:57