How Browsers Export Video Without a Server
Canvas draws frames, MediaRecorder encodes them, a blob becomes a file. What WebM and MP4 support really means, and what it costs.
Until a few years ago, turning an animation into a video file required a server: render frames, encode them with ffmpeg, send the result back. Modern browsers ship their own encoder, which means a five-second clip can be produced on the device that draws it — no upload, no queue, no watermark, no cost per export.
The three pieces
The pipeline has exactly three moving parts, and they are all standard APIs:
- Canvas 2D renders each frame. Same drawing calls as a static image, repeated at a changing timestamp.
- captureStream exposes the canvas as a live media stream at a requested frame rate.
- MediaRecorder encodes that stream into a container the operating system already knows how to play.
A fourth step is often needed in practice: the recording has to be driven by the same clock as the drawing, otherwise frames are dropped at unpredictable moments. In practice that means calling the encoder's frame loop from a requestAnimationFrame callback and stopping it on a timer.
Why recording is real-time
MediaRecorder encodes a live stream. It cannot be told "render 30 frames as fast as possible and stitch them together". A five-second clip therefore takes five seconds to produce, plus a fraction of a second of tail so the last frame is definitely captured.
For a text animation that is a good trade: the wait is predictable and short, and nothing leaves the machine. For a two-minute explainer it would be the wrong tool — that is still a job for a server-side encoder.
WebM and MP4, in practice
Browser support is uneven, but the pattern is stable:
- Chrome, Edge, Firefox: WebM with VP9 or VP8 video. Small files, wide support, no licensing fee.
- Safari: MP4 with H.264. Larger files, but the format every platform accepts.
Every platform you would post to re-encodes the upload anyway, so the container matters less than the bitrate and the frame size. WebM uploads are transcoded on arrival; nothing is rejected for being WebM.
The correct implementation asks the browser what it supports rather than guessing, because a hard-coded "video/webm" fails silently on the one browser that does not offer it.
What bitrate buys you
Text on a flat background is easy to encode: large areas of identical colour, sharp edges, little noise. Around 8 Mbps at 1080p is generous for this content and produces a five-second file of roughly five megabytes.
Going higher mostly stores artefacts of the encoder rather than detail. Going much lower starts to soften letter edges — the first thing viewers notice, because they are reading.
Frame rate
30 frames per second is the sane default. Text animation has no fast lateral motion, so the difference from 60 is small, while the file size and the encoding load are halved. Drop to 24 only if you want a deliberately cinematic feel.
Do not record at 60 and assume the platform keeps it. Most feeds serve 30, so the extra frames are discarded on arrival.
What can go wrong
- Canvas not attached to the document. Some engines stop producing frames for a detached canvas. Attaching it off-screen before capturing fixes it.
- Tab in the background. requestAnimationFrame throttles, so the recording loses frames. Keep the tab visible while it records.
- No MediaRecorder at all. Old browsers and some embedded webviews. The polite fallback is a still frame as PNG rather than an error message.
- Long recordings. The encoded chunks accumulate in memory. A five-second clip is nothing; a two-minute one is a crash on low-end phones.
Why this matters beyond convenience
Client-side rendering changes what the tool can promise. There is no upload, so the text never reaches a server and nothing needs a privacy policy paragraph about storage. There is no render farm, so the site has no per-export cost and can stay free without a watermark. And there is no account, because there is nothing to track.
The trade-off is bounded: the format suits short, simple, type-led clips. Within that boundary — which is exactly the boundary of a text animation — the browser is now the better place to do the work.