Takes That Survive a Closed Tab

Why Roughcast uploads two-second chunks, keeps the raw file immutable, and treats recovery as a first-class state instead of an error.

A recording is a promise that something happened. The tab that captured it is allowed to disappear; the recording is not. Most of the storage design follows from that one sentence.

Chunks Are the Source of Truth

Every two seconds the recorder has another piece of the file. It PUTs that piece under a numbered sequence, then forgets it. The server writes the chunk to disk immediately. Nothing is buffered in memory, nothing waits for a final upload, and the sequence number makes an out-of-order retry harmless.

Finalization is deliberately small. The server sorts the numbered chunk files, concatenates them into raw.webm, records the size, and moves the take from recording to ready. If the tab or the server disappears before that happens, startup recovery finds the recording take, concatenates whatever chunks exist, and marks it partial. The editor can still open it.

That is why the library shows two different states instead of a single green checkmark. ready means the upload closed cleanly. partial means the take survived anyway. A failed take remains visible because deleting the user’s intent would be worse than showing them a broken file.

The Raw File Does Not Change

Editing never rewrites the raw media. Crop, zooms, annotations, freezes, speed ranges, placeholders and export markers all live in a JSON project next to the recording. The poster is a JPEG beside the media. The only time the raw file is touched is at finalization, when it is assembled and its container duration is written.

That boundary is not just a backup strategy. It means an export can be wrong without damaging the source, a project can be reloaded after a failed experiment, and an older editor can still open the same take. The immutable file is the stable part of the system; the project is the part that changes.

The editor’s version of the file is the source of truth for playback, not the browser’s estimate. MediaRecorder WebM often reports duration = Infinity, and append-only WebM has no reason to know its final duration at all. The take metadata carries the recorder’s elapsed time; the editor uses it, falls back to a seek when necessary, and never assumes the <video> element knows the answer.

Local Means Local

SQLite is compiled in. The server binds to loopback. The UI is embedded in the binary. There is no synchronization daemon and no background upload. The five-digit port is the only address the browser needs, and the service worker caches only the UI shell, never the takes.

The cost is that the library is tied to this machine. The benefit is that a recording never leaves it, and a failed experiment is just a project file next to an untouched video.


A recorder that survives a closed tab is not doing anything clever. It is doing the small, repetitive thing that makes recovery possible: write the bytes now, number them, and reconstruct the sequence later.

AI Insights: Recovery Is a State, Not an Exception
Source Code: MPL-2.0 · Content: CC BY-SA 4.0 · Credits & AI Disclosure