junkpile

19 · Tauri v2 Webcam Compositor

A standalone Tauri v2 + raw WebGL 1 example for combining a live webcam with background replacement, key mattes, graphics overlays, recording, and native export.

What this example teaches

Signal chain

Camera texture
  ↓
Foreground framing + color grade
  ↓
Chroma/luminance key matte
  ↓
Background (procedural, image, or video)
  ↓
Transparent overlay
  ↓
WebGL preview → MediaRecorder / PNG export

Features

Camera

Background

Key matte

Foreground

Overlay

Output

Native media paths

Images and videos intentionally use different native paths:

Native image → Rust bytes → Blob URL → WebGL texture
Native video → authorized asset URL → video element → WebGL texture

This prevents WKWebView from marking native image textures as insecure while preserving streaming playback for video files.

Run

npm install
npm run dev

Press Start camera and approve the operating-system permission prompt. For chroma keying, use a green or blue background, select the corresponding preset, then inspect Matte while tuning threshold and softness.

macOS permission files

src-tauri/Info.plist provides NSCameraUsageDescription, and src-tauri/entitlements.plist enables the camera entitlement. The bundle configuration points to the entitlement file.

Notes