ffmpeg.wasm
ffmpeg.wasm copied to clipboard
Node >16 `TypeError`: Failed to parse URL from @ffmpeg/core/dist/ffmpeg-core.wasm
Describe the bug When running the first example on the README in a NodeJS environment, I get the following error:
❯ node --experimental-wasm-threads index.js
[info] use ffmpeg.wasm v0.11.4
[info] load ffmpeg-core
[info] loading ffmpeg-core
[fferr] TypeError: Failed to parse URL from /path/to/nodeFfmpeg/node_modules/@ffmpeg/core/dist/ffmpeg-core.wasm
/path/to/nodeFfmpeg/node_modules/@ffmpeg/core/dist/ffmpeg-core.js:12
if(l){ra=oa?require("path").dirname(ra)+"/":__dirname+"/";ta=function(a,b){wa||(wa=require("fs"));xa||(xa=require("path"));a=xa.normalize(a);return wa.readFileSync(a,b?null:"utf8")};va=function(a){a=ta(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a};1<process.argv.length&&(ka=process.argv[1].replace(/\\/g,"/"));ja=process.argv.slice(2);process.on("uncaughtException",function(a){if(!(a instanceof ca))throw a;});process.on("unhandledRejection",u);la=function(a){process.exit(a)};f.inspect=
^
RuntimeError: abort(TypeError: Failed to parse URL from /path/to/nodeFfmpeg/node_modules/@ffmpeg/core/dist/ffmpeg-core.wasm). Build with -s ASSERTIONS=1 for more info.
at process.u (/path/to/nodeFfmpeg/node_modules/@ffmpeg/core/dist/ffmpeg-core.js:25:109
To Reproduce Steps to reproduce the behavior:
- Download the attach ZIP containing
package.json
,package-lock.json
,index.js
and the flametest.avi
==> node-ffmpeg-error.zip -
npm install
everything -
node --experimental-wasm-threads index.js
- See error
Expected behavior It's the default example, it should just run.
Desktop:
- OS: Darwin Kernel Version 21.6.0 arm64
NodeJS:
- Version v18.8.0
ffmpeg.wasm
- @ffmpeg/core version: 0.11.0 (latest release rn)
- @ffmpeg/ffmpeg version: 0.11.4 (latest release rn)
Additional context I wrote a lib that uses ffmpeg.wasm, and it works amazingly in the browser, but when running it on Node, despite my best efforts, I keep running into this.
I thought my setup was wrong so I created this minimalist NodeJS app that uses the README code, and lo and behold it shows the same error.
Here is the README code I'm referring to:
const fs = require('fs');
const { createFFmpeg, fetchFile } = require('@ffmpeg/ffmpeg');
const ffmpeg = createFFmpeg({ log: true });
(async () => {
await ffmpeg.load();
ffmpeg.FS('writeFile', 'test.avi', await fetchFile('./test.avi'));
await ffmpeg.run('-i', 'test.avi', 'test.mp4');
await fs.promises.writeFile('./test.mp4', ffmpeg.FS('readFile', 'test.mp4'));
process.exit(0);
})();
Downgrade node.js to v16 should work, not sure why node.js v18 doesn't work at the moment.
Downgrade node.js to v16 should work, not sure why node.js v18 doesn't work at the moment.
Downgrading to Node.js v16.17.0 fixed it! I added the following to my package.json
to be sure:
"engines": {
"node": "<=16.17.0"
},
I think this is still happening on newer node versions, its saying that fetch failed. It seems like this is the new error:
[fferr] TypeError: fetch failed
node_modules/@ffmpeg/ffmpeg/src/createFFmpeg.js:43
Uncaught RuntimeError RuntimeError: abort(TypeError: fetch failed). Build with -s ASSERTIONS=1 for more info.
aka I think it's having a problem grabbing the WASM file
Was stuck on this for hours. Downgrading from Node 19 to 16 worked for me. Geez.
Still no updates?
Downgrade to node 16.x still not work when deployed to Vercel.
Runetime: Node.js 16.x
[info] use ffmpeg.wasm v0.11.6
[info] load ffmpeg-core
[info] loading ffmpeg-core
Error: Cannot find module '@ffmpeg/core'
Require stack:
- /var/task/node_modules/@ffmpeg/ffmpeg/src/node/getCreateFFmpegCore.js
- /var/task/node_modules/@ffmpeg/ffmpeg/src/node/index.js
- /var/task/node_modules/@ffmpeg/ffmpeg/src/createFFmpeg.js
- /var/task/node_modules/@ffmpeg/ffmpeg/src/index.js
- /var/task/.next/server/pages/api/whisper.js
- /var/task/node_modules/next/dist/server/next-server.js
- /var/task/___next_launcher.cjs