Open zinkkrysty opened 1 year ago
I'm fixing this issue by overriding the webpack config in my Next.js app:
// 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;
Hi, I am not entirely sure why Next.js would try to load it in the first place as @ffmpeg/core is not a dependency of canvas-record. Maybe a default/side effect of how @ffmpeg/ffmpeg is trying to fetch it with the corePath. I have released v5.0.0-beta.0 with updated @ffmpeg/ffmpeg, if you want to give it a go.
But in any case, you should be able to instance a new Recorder with your chosen encoder in v4 already by passing "encoder" as an option. That's what I do in the example:
It is only automatically guessing the best encoder if options.encoder (assigned as this.encoder) is not set:
I'm trying to use
canvas-record
in a Next.js application. I don't need theffmpeg
encoder as I want to use the WebCodecs instead. Despite this, I get an ugly error regarding importing offfmpeg-core
module.There is a similar issue opened at https://github.com/ffmpegwasm/ffmpeg.wasm/issues/383 however I don't expect
canvas-record
to import any encoders until I decide to use them.I would appreciate the possibility of using this library without automatically loading the ffmpeg module.
Consider letting the user import the encoder they need and passing it to the
Recorder
initialization.