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

使用ffmpeg.wasm时遇SharedArrayBuffer未定义错误求助

TikTok直播下载器开发遇到SharedArrayBuffer未定义错误

我正在用以下HTML代码开发TikTok直播下载器,基于Node.js运行,但一直遇到ReferenceError: SharedArrayBuffer is not defined错误。我已经在app.js里添加了启用SharedBuffer的中间件,设置了相关跨域头,但问题还是没解决。相关代码如下:

HTML代码

<!DOCTYPE html>
<html>
  <head>
    <title>TikTok Live Downloader</title>
  </head>
  <body>
    <h1>TikTok Live Downloader</h1>
      <label for="username">Username:</label>
      <input id="txt" type="text" name="username" id="username" required>
      <button type="submit">Download</button>
  </body>
<script src="ffmpeg.js"></script>
<script>
const downloadButton = document.querySelector('button[type="submit"]');
downloadButton.addEventListener('click', async () => {
const ffmpeg = FFmpeg.createFFmpeg({
     corePath: new URL('ffmpeg-core.js', document.location).href,
     workerPath: new URL('ffmpeg-core.worker.js', document.location).href,
     wasmPath: new URL('ffmpeg-core.wasm', document.location).href,
     log: true
   });
   await ffmpeg.load();
const liveUrl=document.getElementById("txt").value;
ffmpeg.run('-i', '${liveUrl}', 'c','copy','test.mp4');
const dwnLink = document.createElement('a');
dwnLink.download = `output${'test.mp4'}`;
dwnLink.href= encodedData;
dwnLink.click();
});
</script>
</html>

Node.js中间件代码

// middleware to enable SharedBuffer to be used
app.use(function(req, res, next) {
  res.header("Cross-Origin-Embedder-Policy", "require-corp");
  res.header("Cross-Origin-Opener-Policy", "same-origin");
  next();
});

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 15:27:14