Hi!
So i'm trying to import FFMPEG into my app on the client side (i first made it just pure Preact but moving to NextJS.
I use this code:
const ffmpegRef = useRef<FFmpeg | null>(null);
const messageRef = useRef<HTMLParagraphElement | null>(null);
useEffect(() => {
const loadFFmpeg = async () => {
const { FFmpeg } = await import('@ffmpeg/ffmpeg');
const { toBlobURL } = await import('@ffmpeg/util');
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core-mt@0.12.10/dist/esm';
const ffmpeg = new FFmpeg();
ffmpeg.on('log', ({ message }) => {
if (messageRef.current) messageRef.current.innerHTML = message;
});
await ffmpeg.load({
coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
workerURL: await toBlobURL(`${baseURL}/ffmpeg-core.worker.js`, 'text/javascript'),
});
ffmpegRef.current = ffmpeg;
setLoaded(true);
};
loadFFmpeg();
}, []);
But i get the error:
Uncaught (in promise) Error: Cannot find module as expression is too dynamic page.tsx:30:19
loadFFmpeg page.tsx:30
AsyncFunctionThrow self-hosted:804
(Async: async)
useEffect page.tsx:40
react_stack_bottom_frame react-dom-client.development.js:23668
Who can help?