Sources for reading
ASource represents where you read media data from. All sources inherit from the abstract Source base class.
source.ts:42-90
BlobSource
Reads from a browserBlob or File object - perfect for file uploads and client-side processing.
source.ts:165-277
- From file input
- From drag and drop
- With cache options
BufferSource
Reads from anArrayBuffer or ArrayBufferView in memory - ideal for small files or pre-loaded data.
source.ts:97-146
UrlSource
Reads from a remote URL using HTTP range requests - perfect for streaming from servers or CDNs.source.ts:362-634
- Basic usage
- With custom headers
- With retry logic
- With cache and parallelism
UrlSource uses intelligent prefetching to minimize latency and optimize for sequential access patterns.
FilePathSource
Reads from a file path on the server - for Node.js, Bun, or Deno environments.source.ts:654-714
StreamSource
A general-purpose, callback-driven source for custom reading logic.source.ts:761-905
- Custom implementation
- S3 example
ReadableStreamSource
Reads from aReadableStream<Uint8Array> - perfect for processing data as it arrives.
source.ts:939-1170
Targets for writing
ATarget represents where you write media data to. All targets inherit from the abstract Target base class.
target.ts:24-38
BufferTarget
Writes to anArrayBuffer in memory - great for small files or when you need the complete buffer.
target.ts:46-54
- Basic usage
- Download file
StreamTarget
Writes to aWritableStream<StreamTargetChunk> - versatile target for streaming, files, or custom destinations.
target.ts:95-129
- File System Access API
- With chunking
- Custom WritableStream
FilePathTarget
Writes to a file path on the server - for Node.js, Bun, or Deno.target.ts:146-191
NullTarget
Discards all data - useful when extracting data through callbacks or events.target.ts:199-204
Choosing the right source and target
- Browser
- Node.js / Bun / Deno
Sources:
- ✅
BlobSource- File uploads, drag-and-drop - ✅
UrlSource- Remote video streaming - ✅
BufferSource- Small files in memory - ✅
ReadableStreamSource- MediaRecorder output
- ✅
BufferTarget- Download files - ✅
StreamTarget- File System Access API, custom streams - ✅
NullTarget- Extract specific data via callbacks
Performance tips
Use appropriate caching
Configure
maxCacheSize based on file size and access patterns. Larger caches reduce I/O but use more memory.Enable chunking
Use
chunked: true for StreamTarget and FilePathTarget to reduce write overhead.Tune parallelism
For UrlSource, increase
parallelism for faster downloads on high-bandwidth connections.Choose prefetch profiles
Use
'network' for remote sources, 'fileSystem' for local files, 'none' for random access.Monitoring reads and writes
Both sources and targets provide callbacks to monitor data flow:Next steps
Input and Output
Learn how to use sources and targets with Input and Output
Formats and Codecs
Understand which formats work with your sources