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

Provide a way to pass the WASM and Core file content directly to the library instead of URLs.

Open mainrs opened this issue 9 months ago • 3 comments

Is your feature request related to a problem? Please describe. I am trying to write a userscript for Greasymonkey/Violentmonkey that requires media conversion. Due to the nature of the ecosystem, I cannot use the NPM package. Calling ffmpeg.load({coreUrl, wasmUrl}) doesn't work, since websites usually have CORS enabled and I therefore cannot fetch the content from unpkg or other CDNs.

Describe the solution you'd like These engines are able to load arbitrary JS dependency from CDNs by adding a metadata header field called @require. This works for the core JS file. But the WASM file cannot be loaded that way: under the hood, these extensions call eval, which won't work for WASM modules.

It would be great if the library could offer an option called wasmBlob that contains the raw WASM binary blob. The option could be exclusive or take precedence over wasmUrl. If it exists, ffmpeg would not fetch the WASM binary but try to load the provided blob.

This would work in my case, since these userscript extensions provide a custom HTTP fetch method called GM_xmlHttpRequest that can circumvent CORS restrictions.

Describe alternatives you've considered There aren't any that I am aware of.

Additional context

mainrs avatar Apr 12 '25 14:04 mainrs

Why not create blob dynamically and pass an URL to that blob? Checkout URL

domlija avatar Apr 21 '25 20:04 domlija

Why not create blob dynamically and pass an URL to that blob? Checkout URL

Could you elaborate more? I checked out the documentation but didn't understand your suggestion. Internally, ffmpeg.wasm seems to rely on fetch to get the wasm blob, which is the problem I am facing. I can provide the blob, as the extension can fetch it and inject it into the userscript, but the user script cannot access the wasmURL, because that would hit CORS restrictions.

mainrs avatar Apr 22 '25 09:04 mainrs

I was thinking about storing wasm file in a string in your userscript. Then you can create blob file and provide the URL from the blob you created. Not the prettiest way to do it but I think you shouldn’t face CORS issues

Lijep pozdrav, Mislav Đomlija


Šalje: Sven @.> Poslano: Tuesday, April 22, 2025 11:48:10 AM Prima: ffmpegwasm/ffmpeg.wasm @.> Kopija: Mislav Đomlija @.>; Comment @.> Predmet: Re: [ffmpegwasm/ffmpeg.wasm] Provide a way to pass the WASM and Core file content directly to the library instead of URLs. (Issue #865)

Why not create blob dynamically and pass an URL to that blob? Checkout URLhttps://developer.mozilla.org/en-US/docs/Web/API/URL

Could you elaborate more? I checked out the documentation but didn't understand your suggestion. Internally, ffmpeg.wasm seems to rely on fetch to get the wasm blob, which is the problem I am facing. I can provide the blob, as the extension can fetch it and inject it into the userscript, but the user script cannot access the wasmURL, because that would hit CORS restrictions.

— Reply to this email directly, view it on GitHubhttps://github.com/ffmpegwasm/ffmpeg.wasm/issues/865#issuecomment-2820781689, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASFX56YWGHSNLKDRA2B6NDT22YF5VAVCNFSM6AAAAAB3ACLD5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMRQG44DCNRYHE. You are receiving this because you commented.Message ID: @.***>

[https://avatars.githubusercontent.com/u/5113257?s=20&v=4]mainrs left a comment (ffmpegwasm/ffmpeg.wasm#865)https://github.com/ffmpegwasm/ffmpeg.wasm/issues/865#issuecomment-2820781689

Why not create blob dynamically and pass an URL to that blob? Checkout URLhttps://developer.mozilla.org/en-US/docs/Web/API/URL

Could you elaborate more? I checked out the documentation but didn't understand your suggestion. Internally, ffmpeg.wasm seems to rely on fetch to get the wasm blob, which is the problem I am facing. I can provide the blob, as the extension can fetch it and inject it into the userscript, but the user script cannot access the wasmURL, because that would hit CORS restrictions.

— Reply to this email directly, view it on GitHubhttps://github.com/ffmpegwasm/ffmpeg.wasm/issues/865#issuecomment-2820781689, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASFX56YWGHSNLKDRA2B6NDT22YF5VAVCNFSM6AAAAAB3ACLD5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMRQG44DCNRYHE. You are receiving this because you commented.Message ID: @.***>

domlija avatar Apr 22 '25 10:04 domlija