ClientSideExporter class enables video export directly in the browser using the WebCodecs API and MediaBunny library, without requiring a server or FFmpeg.
Overview
Client-side export is useful for:- Interactive video editors where users can preview and export
- Serverless applications that want to avoid backend rendering costs
- Progressive web apps that work offline
- Quick previews during development
Client-side export requires modern browsers with WebCodecs support (Chrome 94+, Edge 94+). It will not work in Firefox or Safari.
Basic usage
Export options
'mp4' | 'webm' | 'png' | 'jpeg'
default:"'mp4'"
Output format:
'mp4': H.264 video in MP4 container'webm': VP9 video in WebM container'png': Single frame snapshot as PNG'jpeg': Single frame snapshot as JPEG
'auto' | 'canvas' | 'dom'
default:"'auto'"
Capture mode:
'auto': Try canvas first, fall back to DOM'canvas': Capture from HTMLCanvasElement'dom': Capture from DOM using screenshots
string
default:"'canvas'"
CSS selector to find the canvas element in canvas mode
number
Override output width (defaults to composition width)
number
Override output height (defaults to composition height)
number
default:"5000000"
Video bitrate in bits per second (default: 5 Mbps)
boolean
default:"true"
Whether to burn captions into the video
object
Caption styling options:
string
default:"'video'"
Output filename (without extension)
(progress: number) => void
required
Progress callback receiving values from 0 to 1
AbortSignal
AbortSignal to cancel the export
Export workflow
1
Pause playback
The exporter pauses the player to ensure consistent frame capture:
2
Determine capture mode
If mode is
'auto', the exporter attempts to capture from canvas first:3
Initialize MediaBunny output
Create output with the selected format:
4
Setup video track
Configure video encoding:
5
Setup audio track
If audio tracks exist, configure audio encoding:
6
Capture and encode frames
Loop through all frames in the composition:
7
Process audio
Mix all audio tracks into a single buffer:
8
Finalize and download
Complete encoding and trigger browser download:
Image snapshots
Export single frames as images:Caption rendering
Captions are burned into the video by drawing them onto each frame:Example: Interactive export UI
Performance considerations
Frame capture overhead
Capturing frames in the browser is slower than server-side rendering:- Canvas mode: ~10-30ms per frame
- DOM mode: ~50-100ms per frame
- Canvas: ~6-18 seconds
- DOM: ~30-60 seconds
Memory usage
VideoFrames consume memory until closed:Browser limitations
For longer videos, use server-side rendering with theRenderer class.
Codec support
Different browsers support different codecs:
* Firefox and Safari do not support WebCodecs API
Check codec support: