Skip to content

Oct 25, 2026

Depth Capture

Depth Anything V2 Small, in the browser. The clip keeps its size and its sound.

depth
video

Upload a clip. Mediabunny reads it and writes it back. Each frame goes through Depth Anything V2 Small, here in the browser, through Transformers.js.

Closer is brighter. The depth is relative: each frame's 2% to 98%. The range shifts only a little from the last frame, so the shot doesn't flicker. Gamma is 0.8. The map is the small model's size, scaled up to the clip.

The file matches the clip's display size. An odd edge gains one pixel, so H.264 will take it. Sound stays: AVC in an MP4 first, WebM if that would drop the audio. If the browser can't keep the sound, it stops. Past 12 seconds, the rest is cut. WebGPU when the browser has it, WASM otherwise. The model downloads once and stays on this device.

How it works

The model is Depth Anything V2 Small in ONNX. Nothing loads with the page. Transformers.js comes in only when you hit render, and the pipeline is kept for the next clip.

Mediabunny opens the file and hands over one frame at a time. The frame is drawn to an offscreen canvas, read by the model, and the depth is painted back on the same canvas. That canvas is what gets encoded.

Backends

On WebGPU it tries fp16 first, then fp32 for adapters without half precision. On WASM it runs q8. If all three fail, the next try starts clean.

Keeping it steady

Raw depth means little from one frame to the next. So each frame is sampled, sorted, and cut at 2% and 98%. The range then eases toward the new one by 0.15 a frame. Something bright walks in and the scale moves over a few frames, not all at once.

Limits

Cancel works at any point. The map is soft at the edges, since it comes from a small model scaled up. It tells near from far. It doesn't measure meters.

Preview

Inspired by

Depth Anything V2: relative inverse depth. This is the small ONNX build, not a metric depth.