feat: allow passing binary data directly to load()#937
Open
JacobiusMakes wants to merge 1 commit intoffmpegwasm:mainfrom
Open
feat: allow passing binary data directly to load()#937JacobiusMakes wants to merge 1 commit intoffmpegwasm:mainfrom
JacobiusMakes wants to merge 1 commit intoffmpegwasm:mainfrom
Conversation
Add support for passing ArrayBuffer, Uint8Array, or Blob directly to load() via new coreData, wasmData, and workerData config options. When provided, binary data takes precedence over URL strings and is converted to Blob URLs internally, enabling use cases where fetch is unavailable (e.g. userscripts with CORS restrictions). Closes ffmpegwasm#865 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ Deploy Preview for ffmpegwasm canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
coreData,wasmData, andworkerDataoptions toFFMessageLoadConfigacceptingArrayBuffer | Uint8Array | BlobURL.createObjectURL()Motivation
Closes #865
Environments like userscript extensions (Greasemonkey/Violentmonkey) can fetch WASM binaries via
GM_xmlHttpRequest(which bypasses CORS), but cannot pass the result to ffmpeg.wasm becauseload()only accepts URL strings. This change lets callers pass pre-fetched binary content directly:Implementation
The conversion happens in the main thread (
classes.ts) before the config is sent to the worker viapostMessage. A smalltoBlobURLhelper creates a Blob URL from the binary data using the appropriate MIME type (text/javascriptfor core/worker JS,application/wasmfor WASM). The worker receives plain URL strings as before, so no worker-side changes are needed.Test plan
load()still works (no regression)load({ wasmData: new Uint8Array(...) })loads successfullyload({ wasmData: new Blob([...]) })loads successfullyload({ coreData: ..., wasmData: ... })with both binary options workswasmURLandwasmDataare provided🤖 Generated with Claude Code