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

Help needed solving -> DOMException: Failed to construct 'Worker': Script at 'https://reddit.com/814.ffmpeg.js' cannot be accessed from origin 'https://reddit.com.'

Open Quantumatum opened this issue 1 year ago • 1 comments

Wondering if someone might be able to kindly lend some advice re. an exception I can't seem to solve:

I have written a google chrome extension using local ffmpegwasm files (no need to run a server or download any ffmpegwasm files), which allows users to click an injected 'download' button under Reddit videos (via content_scripts). This was working great on ffmpegwasm v11, but since migrating to v12 (latest version) I have been unable to solve the following exception which is triggered during ffmpeg.load(): as seen in chrome's console log:

DOMException: Failed to construct 'Worker': Script at 'https://www.redditstatic.com/814.ffmpeg.js' cannot be accessed from origin 'https://reddit.com'. At i.load (chrome-extension://ljejfmmefhnpbpdhkhbbajpihfhnbdnm/lib/ffmpeg/umd/ffmpeg.js:1:2918)

I'm a programming beginner and I've been stuck trying to fix this for many, many hours. This exception does not happen and the video downloads if I instead use a feature of my extension which allows entering a Reddit video URL directly into a field in the extensions popup or options window. Also, I have no idea why the 814.ffmpeg.js file is being referenced along with redditstatic.com (from exception to exception, this url seems to randomly change to other reddit url's too), though I imagine this is part of the problem?

I have seen there are a couple of mentions of this error on this github repository, with some fixes involving using the worker814URL and/or classWorkerURL params within ffmpeg.load() and pointing them to the 814.ffmpeg.js file, which I have tried without any success (although I did notice that using classWorkerURL changed https://www.redditstatic.com/814.ffmpeg.js to chrome-extension://ljejfmmefhnpbpdhkhbbajpihfhnbdnm/lib/ffmpeg/umd/814.ffmpeg.js). Though, It seems that previous discussions around this error might not be too helpful for me as those appear geared towards ffmpegwasm running with a server, as apposed to entirely locally within a chrome extension.

Any help would be super appreciated - many thanks

Quantumatum avatar May 18 '24 17:05 Quantumatum

Same, im also hitting this. Im using Angular.

main.ts:11 ERROR DOMException: Failed to construct 'Worker': Script at 'file:///Users/jstenkvi/workspace/dev_projects/MediaGenerator/media-generator-app/node_modules/@ffmpeg/ffmpeg/dist/esm/worker.js' cannot be accessed from origin 'http://localhost:4200'.
    at FFmpeg.load (http://localhost:4200/vendor.js:142:7)
    at http://localhost:4200/main.js:947:26
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (http://localhost:4200/vendor.js:164847:17)
    at _next (http://localhost:4200/vendor.js:164861:9)
    at http://localhost:4200/vendor.js:164866:7
    at new ZoneAwarePromise (http://localhost:4200/polyfills.js:10467:23)
    at http://localhost:4200/vendor.js:164858:12
    at FFmpegService.load_ffmpeg (http://localhost:4200/main.js:965:7)
    at new FFmpegService (http://localhost:4200/main.js:936:12)

Update: I figured it out. You have to use classWorkerURL as explained here #561

MileanCo avatar Aug 27 '24 13:08 MileanCo