Canvas Animation to Video Converter
Convert HTML5 Canvas animations to downloadable WebM video files directly in your browser using MediaRecorder API. No server required.
About
Recording an HTML5 Canvas animation to a distributable video file has historically required server-side FFmpeg pipelines or frame-by-frame PNG export followed by manual stitching. Both approaches introduce latency, storage overhead, and deployment complexity. This tool eliminates that dependency entirely by leveraging the browser-native captureStream(fps) method on the <canvas> element, piping the resulting MediaStream into a MediaRecorder instance configured for VP8/VP9 WebM encoding. The output is a standards-compliant video file generated with zero server round-trips. Recording fidelity depends on the client GPU and the complexity of the draw loop. Frame drops occur when the compositor cannot maintain the requested fps under heavy fill-rate pressure. This tool approximates constant-framerate output, but the WebM container uses variable frame timing internally. For production pipelines requiring H.264/MP4, the exported WebM can be transcoded offline via FFmpeg.
Formulas
The canvas stream capture pipeline follows a direct data flow from the rendering context to an encoded video container:
Estimated output file size can be approximated by:
where S is file size in bits, bitrate is the encoder output rate in bps, and t is duration in seconds. For VP8 at default quality on a 720p canvas:
Frame timing within the animation loop uses delta-time normalization to decouple rendering speed from monitor refresh rate:
where ฮด is the elapsed time in seconds, used to scale all position updates. This ensures consistent animation speed whether the display runs at 60 Hz or 144 Hz.
Reference Data
| Parameter | Value / Range | Notes |
|---|---|---|
| Output Format | WebM (VP8 / VP9) | Browser-dependent codec selection |
| Canvas Stream FPS | 1 - 60 | Higher values increase file size linearly |
| Max Resolution | 4096 ร 4096 | GPU texture limit on most devices |
| Typical Bitrate (720pโ30fps) | โ 2.5 Mbps | VP8 default quality |
| Color Space | sRGB (8-bit) | Canvas 2D default; no HDR |
| Alpha Channel | Not supported | MediaRecorder drops alpha |
| Audio Track | None (silent) | Can be muxed post-export |
| captureStream() Support | Chrome 51+, Firefox 43+, Edge 79+ | Safari 14.1+ partial |
| MediaRecorder Support | Chrome 47+, Firefox 25+, Edge 79+ | Safari 14.1+ (WebM limited) |
| Max Duration (practical) | โ 300 s | Limited by available RAM for blob chunks |
| VP8 Profile | Constrained Baseline | Hardware-accelerated on most GPUs |
| VP9 Profile | Profile 0 | Better compression, slower encoding |
| Chunk Interval | 100 ms | timeslice parameter for ondataavailable |
| File Size (10s @ 720p) | โ 3 - 5 MB | Varies with scene complexity |
| Particle Animation | 200 particles | Configurable count |
| Wave Animation | Sine superposition | 3 overlapping waves |
| Geometry Animation | Rotating polygons | 3 - 8 sided |
| Gradient Animation | HSL rotation | 360ยฐ cycle |
| Browser Memory Limit | โ 2 GB | Chrome per-tab limit; long recordings may OOM |