ffmpeg.wasm icon indicating copy to clipboard operation
ffmpeg.wasm copied to clipboard

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

Open Allespro opened this issue 11 months ago • 2 comments

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

  • Browser Firefox

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.

Allespro avatar Feb 28 '24 17:02 Allespro

hi May I ask how you solved this problem locally?

yuedud avatar Mar 01 '24 02:03 yuedud

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

Allespro avatar Mar 02 '24 01:03 Allespro