ffmpeg.wasm: Uncaught ReferenceError: createFFmpegCore is not defined
As you can see the
import React from "react";
import { createFFmpeg, fetchFile } from "@ffmpeg/ffmpeg";
const ffmpeg = createFFmpeg({
log: true,
});
function App() {
const [ready, setReady] = React.useState(false);
const load = async () => {
await ffmpeg.load();
setReady(true);
};
React.useEffect(() => {
load();
}, []);
.
.
.
I got a Bad memory error too! How to fix this?
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 24
- Comments: 30 (1 by maintainers)
For anyone using
react-scripts
orcreate-react-app
to run React, you can send headers manually by using a customized middleware (https://create-react-app.dev/docs/proxying-api-requests-in-development/#configuring-the-proxy-manually).First, install
http-proxy-middleware
:or
Then, create
src/setupProxy.js
file and put our logic in there:Hello, using this versions in my package json it worked just fine:
This started to work for me in NextJS when I removed the
http://localhost:3000/public
part. I copied thenode_modules/@ffmpeg/core/dist
folder into public and renamed itffmpeg_core_dist
for clarity. Thenworked locally. But on production I got the error
Uncaught (in promise) ReferenceError: SharedArrayBuffer is not defined
which I was able to fix by adding these headers to next.config.js:But this is not a perfect solution because
SharedArrayBuffer is not defined
still happens sometimes on page load and a reload is needed to get ffmpeg to load. Also it has other issues mentioned here. This all has to do with the security of SharedArrayBuffer that goes above my head.Try
corePath: "https://unpkg.com/@ffmpeg/core@0.10.0/dist/ffmpeg-core.js"
I had the same problem in React app, those version worked for me
@ffmpeg/core: ^0.10.0 and @ffmpeg/ffmpeg: ^ 0.9.8
Thank you! this works for me as well!
Just want to add that you will also be able to use version 0.11.0
Next.js (JavaScript)
It worked for me thank you @discretegames !
My setting:
@ffmpeg/core==0.10.0
@ffmpeg/ffmpeg==0.10.1
Thank you again 😃
I am facing the same issue, whether running with or without
corePath
. None of the above workarounds work for me. I am building a Next.js PWA. Any ideas how we can avoid this and use this supercool module?Did anyone find a solution for this? I guess downgrading @ffmpeg/ffmpeg to 0.9.8 and @ffmpeg/core to 0.9.0 for now is the way to go 🤷♂️
I found a fix! You have to go to node_modules/@ffmpeg/core/dist/ and copy all the files from there and paste them in the root folder, preferrably in the public folder if you’re using NextJS. Then use: