ffmpegwasm / ffmpeg.wasm

FFmpeg for browser, powered by WebAssembly
https://ffmpegwasm.netlify.app
MIT License
14.22k stars 831 forks source link

ffmpeg.load() promise never resolves. #557

Closed Parth589 closed 1 year ago

Parth589 commented 1 year ago

Describe the bug Idk whats happening, whenever the ffmpeg.load() function runs, with valid config object, it never resolves or rejects.

To Reproduce

const load = async () => {
        const ffmpeg = ffmpegRef.current;
        ffmpeg.on("log", ({message}) => {
            if (messageRef.current) messageRef.current.innerHTML = message;
        });
        console.log('hello world');
        const fn = (rtrn) => {
            console.log('hello world');
            console.trace();
            return rtrn;
        }
        // toBlobURL is used to bypass CORS issue, urls with the same
        // domain can be used directly.
        const d =  ffmpeg.load({
            coreURL: fn(await toBlobURL(`/ffmpeg-core.js`, "text/javascript")),
            wasmURL: fn(await toBlobURL(
                `/ffmpeg-core.wasm`,
                "application/wasm"
            )),
            workerURL: fn(await toBlobURL(
                `/ffmpeg-core.worker.js`,
                "text/javascript"
            )),
        });
        console.log({d});
        console.log({d:await d});
        setLoaded(true);
    };

Here i am using my own hosted files (ffmeg-core.js, ffmpeg.core.wasm, ffmpeg-core.worker.js) to increse the download speed on development phase. I've checked these files are fine.

thalleshonorato commented 1 year ago

If you use vite I had the same problem and I solved it by adding config below in vite.config.ts

optimizeDeps: { exclude: ["@ffmpeg/ffmpeg", "@ffmpeg/util"], },

I recommend following the example following all the configs in the example

jeromewu commented 1 year ago

Thanks @thalleshonorato for answering the question.