Provide a way to pass the WASM and Core file content directly to the library instead of URLs.
Opened this issue · 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
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.