How to make nextjs & multithreading work? #744
Unanswered
lauridskern
asked this question in
Q&A
Replies: 3 comments
-
@lauridskern @jeromewu |
Beta Was this translation helpful? Give feedback.
0 replies
-
I've managed to get Nextjs 14 work with multithreading ( TLDR:
/** @type {import('next').NextConfig} */
const nextConfig = {
async headers() {
return [
{
source: "/:path*",
headers: [
{
key: "Cross-Origin-Embedder-Policy",
value: "require-corp",
},
{
key: "Cross-Origin-Opener-Policy",
value: "same-origin",
},
],
},
];
},
};
export default nextConfig; pnpm add @ffmpeg/core-mt // Utilize webpack assets modules to trigger bundle https://webpack.js.org/blog/2020-10-10-webpack-5-release/#asset-modules
// - ONLY `umd` works (`esm` doesnt work for some reason)
// - must be static (dont extract into variable! - limitation of webpack)
// - must be relative path (adjust based on current file directory)
const ffmpegCoreMtUrl = new URL(
"../node_modules/@ffmpeg/core-mt/dist/umd/ffmpeg-core.js",
import.meta.url
).href;
const ffmpegCoreMtWasmUrl = new URL(
"../node_modules/@ffmpeg/core-mt/dist/umd/ffmpeg-core.wasm",
import.meta.url
).href;
const ffmpegCoreMtWorkerUrl = new URL(
"../node_modules/@ffmpeg/core-mt/dist/umd/ffmpeg-core.worker.js",
import.meta.url
).href; await ffmpeg.load({
coreURL: ffmpegCoreMtUrl,
wasmURL: ffmpegCoreMtWasmUrl,
workerURL: ffmpegCoreMtWorkerUrl,
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
Once I had all this figured out, ffmpeg was initializing but not actually doing any encoding. Turned out to be this issue and adding |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have tried just about everything I could find to make this work with nextjs and multithreading.
I tried:
It either throws the error with "SharedArray buffer is not defined", doesn't load at all with no errors thrown or throws a CORS error.
Did anyone manage to get this to work?
Beta Was this translation helpful? Give feedback.
All reactions