Running Real-ESRGAN video upscaling in a browser tab with WebGPU
Most browser-based video upscalers aren't actually browser-based. They upload your video to a backend GPU, queue it up, and send back a file. For personal clips or old family footage, uploading to a random site feels wro
Most browser-based video upscalers aren't actually browser-based. They upload your video to a backend GPU, queue it up, and send back a file. For personal clips or old family footage, uploading to a random site feels wrong, and waiting on upload bandwidth gets old fast.
When building ToHD, I wanted the free version to run entirely on the user's own GPU inside a browser tab: no install, no signup, no watermark, and the file stays on disk.
I extracted the core in-browser pipeline into a small MIT repository: webgpu-video-upscaler. It's 3 TypeScript files on top of Mediabunny and ONNX Runtime Web.
Quick note on licensing so there's no confusion: the in-browser AI pipeline is MIT, and the model weights keep Real-ESRGAN's BSD 3-Clause license. The ToHD website itself, its Fast mode, and the optional paid cloud service are not open source.
How the pipeline actually works in a tab
Each frame goes through five steps inside the browser:
- Mediabunny decodes the frame and draws it to a canvas (this also handles rotation metadata from phone videos).
- The canvas pixels are turned into a tensor.
- ONNX Runtime Web runs Real-ESRGAN (
realesr-general-x4v3) over the whole frame in a single pass using the WebGPU backend. No tiling. - The 4x frame is resized to the target output (e.g. 1080p or 4K).
- Mediabunny encodes back to H.264, copies the original audio track untouched, and streams the MP4 into the browser's private file storage (OPFS) so long videos don't blow up tab RAM.
One nice side effect: decoding and encoding take almost no time compared to GPU inference. Measuring 3 frames up front gives a reliable estimate for the whole clip on whatever machine the user happens to be using.
The shader-f16 surprise (benchmarks)
I benchmarked the pipeline on an Apple M2 Max in a Chromium browser (Nov 8, 2026):
| Input | Output | fp16 (shader-f16) |
fp32 fallback |
|---|---|---|---|
| 360p | 720p | 206 ms/frame | 1,067β1,765 ms/frame |
| 360p | 1080p | 200 ms/frame | not measured |
| 480p | 1080p | 360 ms/frame | not measured |
| 720p | 1080p | 830β870 ms/frame | not measured |
At 30 fps, upscaling a 30-second 360p clip to 720p took about 3 minutes.
The biggest takeaway was shader-f16. When WebGPU supports shader-f16, fp16 looked identical to fp32 in our tests while running 5 to 8 times faster. Without it, falling back to fp32 makes browser upscaling painful. I haven't measured integrated laptop GPUs or phones yet, though they will obviously be much slower.
What works and what doesn't
I tested four stock clips that were downscaled or blurred first:
- Low-res clips (360p/480p to 720p/1080p) get noticeably sharper. Text, whiskers, and thin edges come back cleanly.
- Slightly out-of-focus footage improved on all four clips.
- 720p to 1080p only gives a small bump.
- Heavily compressed clips get smoothed out, so macro-blocking looks less harsh, but missing detail doesn't magically return.
- Motion blur isn't fixed at all. Streaks stay streaks.
- Fine skin details like freckles can end up slightly smoothed.
If you want to inspect the outputs yourself, the test clips, before/after results, and notes are on Hugging Face, and the technical write-up is on tohd.video/open-source-video-upscaler.
Where the repo ends and ToHD begins
The MIT repo is just the raw upscaling pipeline. On ToHD, we added a 3-frame preview with a local speed estimate, desktop browser upscaling up to 4K with no length cap, a free in-browser 1080p upscaler, and optional paid cloud GPUs (one-time credit packs starting at $5, no subscription) for slower machines, batch jobs up to 200 clips, and old VHS/camcorder restoration.
If you're tinkering with WebGPU, ONNX Runtime Web, or Mediabunny, feel free to fork webgpu-video-upscaler or leave a comment with what kind of frame times you get on your GPU.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.