提问人:Hima 提问时间:7/14/2023 更新时间:7/21/2023 访问量:111
ReferenceError:使用 ffmpeg.wasm 时未定义 SharedArrayBuffer
ReferenceError: SharedArrayBuffer is not defined while using ffmpeg.wasm
问:
<!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>
使用上面的代码,我试图制作一个 tiktok 视频下载器,但我不断收到 SharedArrayBuffer 错误。我正在用 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();
});
我尝试在我的应用程序 .js 中添加上述两行,但问题仍然存在。
答:
0赞
Bharat Gupta
7/21/2023
#1
可能您的浏览器不支持 ffmpeg.wasm。以下是支持的浏览器列表 https://caniuse.com/sharedarraybuffer
评论