Input sources
Input sources determine where anInput reads data from. All sources support lazy loading - only the bytes needed for the requested operation are read.
BufferSource
Reads from an in-memoryArrayBuffer.
BlobSource
Reads from aBlob or File.
UrlSource
Fetches data from a remote URL over the network.Retry logic
Customize retry behavior when requests fail:- Infinite exponential backoff, capped at 16 seconds
- No retries if a CORS error is suspected
FilePathSource
Reads from a file path. Requires Node.js, Bun, or Deno.StreamSource
A general-purpose, callback-driven source for reading data from anywhere.Prefetch profiles
- none
- fileSystem
- network
No prefetching - only requested data is loaded. Use for random access patterns.
ReadableStreamSource
Reads from aReadableStream of Uint8Array for incrementally streaming files.
This source is unsized - calls to
.getSize() will throw. Only use with sequential access patterns like reading all packets or doing conversions.Using with MediaRecorder
CombineMediaRecorder with ReadableStreamSource to stream recorded data into Mediabunny:
Monitoring reads
All sources support anonread callback to inspect which areas of the file are being read:
Output targets
Output targets determine where anOutput writes data.
BufferTarget
Writes all data to a single in-memoryArrayBuffer.
StreamTarget
Writes data to aWritableStream in chunks.
Chunked mode
Enable chunked mode to reduce write frequency:Backpressure
The output automatically respects backpressure applied by theWritableStream:
Using with File System Access API
StreamTargetChunk is compatible with FileSystemWritableFileStream:
FilePathTarget
Writes to a file at the specified path. Requires Node.js, Bun, or Deno.finalize() or cancel() is called.
Pros: Simple API for writing to disk in server environments
Cons: Server-side only
NullTarget
Discards all data. Useful when extracting data through other means (format callbacks, encoder events).Monitoring writes
All targets support anonwrite callback: