ffmpeg.wasm
ffmpeg.wasm copied to clipboard
Default core path can be incorrect
Describe the bug
Similar to https://github.com/ffmpegwasm/ffmpeg.wasm/issues/374, the defaultOptions method (which is called as a side-effect upon importing the library) can trigger the following error in a development environment:
error - ../../node_modules/@ffmpeg/ffmpeg/src/browser/defaultOptions.js:7:0
Module not found: Can't resolve '/node_modules/@ffmpeg/core/dist/ffmpeg-core.js'
Import trace for requested module:
../../node_modules/@ffmpeg/ffmpeg/src/browser/index.js
../../node_modules/@ffmpeg/ffmpeg/src/index.js
To Reproduce
- try and import the library in a development environment like next.js where the assets are hashed
Expected behavior
- I am overriding the
corePathmyself increateFFmpegand will never be using thesedefaultOptions-- perhapsdefaultOptionsshould be lazily evaluated when needed, instead of being assigned immediately upon importing the library
How did you end up overriding this? By simply importing @ffmpeg/ffmpeg into my next.js project I get this error.
I managed to fix it in my Next.js app, by overriding the webpack config:
// next.config.js
const nextConfig = {
// Solve misconfigured/missing imports from canvas-record
webpack: (config) => {
config.resolve.alias['/node_modules/@ffmpeg/core/dist/ffmpeg-core.js'] =
'/node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.js';
config.resolve.alias['fs'] = false;
return config;
},
}
module.exports = nextConfig;