Record the element as video.
Adds toMp4(), which records the live element through MediaRecorder. The returned Blob's type identifies the recorded container.
npm install @zumer/snapdom@latest @zumer/snapdom-plugins@latestUsage
import { snapdom } from '@zumer/snapdom';
import { videoExport } from '@zumer/snapdom-plugins/video-export';
const el = document.querySelector('#target');
const result = await snapdom(el, { plugins: [videoExport({ fps: 30, duration: 4000 })] });
const blob = await result.toMp4();
// Or download directly:
await result.toMp4({ download: true });
The plugin tries supported MP4 codecs first, then WebM. A WebM fallback logs a warning; the default download filename matches the recorded .mp4 or .webm container. Explicit filenames and download strings are used as supplied.
Options
| Option | Type | Default | Description |
|---|---|---|---|
fps | number | 10 | Frames per second |
duration | number | 2000 | Total duration in ms (ignored if frames is set) |
frames | number | none | Explicit frame count (overrides duration) |
background | string | '#ffffff' | Color composited under transparent pixels |
scale | number | capture's scale | Capture scale |
bitrate | number | none | videoBitsPerSecond passed to MediaRecorder |
filename | string | none | Download filename; the default follows the recorded .mp4 / .webm container |
Requires MediaRecorder and canvas.captureStream(), which may be unavailable in headless environments. Per-call opts override constructor options and accept download (boolean | string). Recording starts at the call and preserves capture options as GIF recording does. MediaRecorder uses a real-time clock, so slow captures can stretch duration.