ffmpegwasm / ffmpeg.wasm

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

Bug with WebWorker loading of 814.ffmpeg.js + solution #694

Open Allespro opened 7 months ago

Allespro commented 7 months ago

Describe the bug There are two errors I get NS_ERROR_BLOCKED_BY_POLICY or something like incorrect origin. This bug when creating new Worker() from multithreaded 814.ffmpeg.js URL

To Reproduce Idk, just upload to server and try to use

Expected behavior WebWorker starting without problems

Additional context So I found solution, in ffmpeg/package/dist/umd/ffmpeg.js instead of:

new Worker(new URL(e.p + e.u(814), e.b),{ type: void 0 })

use:

new Worker(getWorkerURL(new URL(e.p + e.u(814), e.b)),{ type: void 0 })

and getWorkerURL function:

function getWorkerURL(e) {
    const t = `importScripts( "${e}" );`;
    return URL.createObjectURL(new Blob([t], { type: "text/javascript" }));
}

Don't know where I can fix this in whole source code, so leave this as issue. Think that can help someone.

yuedud commented 7 months ago

hi May I ask how you solved this problem locally?

Allespro commented 7 months ago

hi

May I ask how you solved this problem locally?

hi, put ffmpeg.js into prettifier, then found line of code where worker starts from remote url, then convert remote url to Blob object