# Longpipe — full documentation > Open-source SDK for real-time video effects in the browser: virtual backgrounds, > background blur, portrait matting, face touch-up, auto-reframe, and microphone > noise removal. WebGPU with a WebGL2 fallback. MIT licensed. npm: `longpipe`. Source: https://github.com/sb2702/longpipe Docs site: https://longpipe.dev/docs Index: https://longpipe.dev/llms.txt Generated from the site's own docs sources at build time. ## Contents 1. Longpipe docs — https://longpipe.dev/docs 2. Getting started — https://longpipe.dev/docs/getting-started 3. API reference — https://longpipe.dev/docs/api 4. Architecture — https://longpipe.dev/docs/architecture 5. Backgrounds — https://longpipe.dev/docs/backgrounds 6. Touch-up — https://longpipe.dev/docs/touchup 7. Auto-reframe — https://longpipe.dev/docs/reframe 8. Audio denoise — https://longpipe.dev/docs/audio 9. Presets & autotune — https://longpipe.dev/docs/presets 10. Model layer — https://longpipe.dev/docs/model-layer 11. Self-hosting weights — https://longpipe.dev/docs/self-hosting --- # Longpipe Open-source video effects SDK for the browser. Real-time virtual backgrounds, face touch-up, auto-reframe and mic noise removal on WebGPU with a WebGL2 fallback. ## What it does Wraps neural matting + compositing into a single class. Hand it a `MediaStream`, get a `MediaStream` back with the effects applied. Runs in a worker by default; audio passes through unchanged unless you ask for denoising. Backgrounds, touch-up and auto-reframe all ride a **single shared encoder pass** — enabling a second effect doesn't cost a second inference. Audio denoise runs in a parallel `AudioWorklet`, off the GPU entirely. ## Quick links - [Getting started](https://longpipe.dev/docs/getting-started) — install + your first effect - [API reference](https://longpipe.dev/docs/api) — `EffectsPipeline` options - [Architecture](https://longpipe.dev/docs/architecture) — one encoder, many heads - [Backgrounds](https://longpipe.dev/docs/backgrounds) — accepted background formats - [Touch-up](https://longpipe.dev/docs/touchup) — skin smoothing - [Auto-reframe](https://longpipe.dev/docs/reframe) — automatic subject framing - [Audio denoise](https://longpipe.dev/docs/audio) — real-time mic noise removal - [Presets & autotune](https://longpipe.dev/docs/presets) — model size knobs - [Model layer](https://longpipe.dev/docs/model-layer) — run the model without the pipeline - [Self-hosting weights](https://longpipe.dev/docs/self-hosting) — point at your own CDN ## For LLMs and agents The docs are published as plain markdown, no HTML parsing needed: - [`/llms.txt`](/llms.txt) — index of every page, with a summary of what Longpipe is - [`/llms-full.txt`](/llms-full.txt) — all documentation concatenated into one file Both are generated from these same pages at build time, so they can't drift. ## Status Early but functional, and under active development — published on npm, with real-time matting that benchmarks well against MediaPipe and frame-to-frame temporal stability from an optical-flow head. Backgrounds, touch-up, multi-face support, auto-reframe and audio denoise all ship today; AR effects and lighting correction are still planned. Expect API changes between versions, and rough edges. Issues + PRs welcome on [GitHub](https://github.com/sb2702/longpipe). --- # Getting started ## Install ```bash npm install longpipe ``` That's it — model weights stream from `cdn.longpipe.dev` on first init, so no extra setup. (If you'd rather host weights yourself, see [Self-hosting weights](https://longpipe.dev/docs/self-hosting).) ## Your first effect ```js import { EffectsPipeline } from 'longpipe' // Get any MediaStream — webcam, captureStream(), getDisplayMedia(), whatever const camera = await navigator.mediaDevices.getUserMedia({ video: true }) const pipeline = new EffectsPipeline(camera, { background: 'blur', // 'blur' | 'none' | image URL | ImageBitmap | { color: '#0a3' } | ... }) // pipeline.stream is a MediaStream — use it anywhere you'd use the original videoElement.srcObject = pipeline.stream await pipeline.ready ``` ## What's happening 1. The constructor returns synchronously. `pipeline.stream` is available immediately and emits passthrough until init completes. 2. The SDK spawns a worker, picks the best model preset for your GPU (autotune), fetches weights, and starts compositing. 3. `await pipeline.ready` resolves when the first composited frame lands. ## Next steps - Pick a [background](https://longpipe.dev/docs/backgrounds) other than blur - Look at the full [API reference](https://longpipe.dev/docs/api) - Tune [presets](https://longpipe.dev/docs/presets) if autotune isn't picking what you want --- # API reference ## `EffectsPipeline` The single public class. Hand it a `MediaStream`, get a `MediaStream` back with the effect applied. The pipeline owns its own worker, weight loading, autotune, frame transport selection, audio passthrough, and adaptive preset swaps — designed so you don't have to wire any of that yourself. Construction returns synchronously: `pipeline.stream` is wired immediately and emits the unprocessed input until the model is ready (~1–3s on cold start, depending on hardware). Use `await pipeline.ready` if you want to wait for the effect to actually be live before consuming the output. ```ts const pipeline = new EffectsPipeline(inputStream, options?) ``` ## Constructor parameters ### `inputStream` **Type:** `MediaStream`  ·  **Required** Any video stream — webcam from `getUserMedia()`, screen capture from `getDisplayMedia()`, or a captured stream from a `