Create special WebM files that play different video or audio depending on the browser, by relying on how each browser’s internal parser handles the file.
This project is intended to be run with Bun.
- Install Bun: https://bun.sh/docs/installation
- Install deps:
bun install
| Script | Description |
|---|---|
bun run start |
Run the CLI (recommended for creating files) |
bun run cli |
Run CLI with workspace fix |
bun run web |
Run the web app (Svelte SPA) |
bun run dev |
Watch and serve the web app in dev mode |
bun run build |
Build all packages (CLI + web) |
The CLI uses FFmpeg on your system and is much faster than the web app. Use it to create magic WebM files.
Requirements: FFmpeg must be on your PATH.
Run with no arguments or --help to show usage:
bun run start --
# or
bun run start -- --helpYou must provide three video inputs (Chromium, Firefox, Android). Audio is optional: use either one shared audio track or per-platform audio. If any --audio-* option is used, all three --audio-chromium, --audio-firefox, and --audio-android are required.
Input formats: Video and audio inputs may be in any format that FFmpeg supports (e.g. .webm, .mp4, .mov, .mkv, .opus). Output is always WebM.
Recommended flags: For best compatibility (especially on Android), use --strip-cues or --remove-length in most cases. They avoid Cues-related issues that can cause playback problems. --remove-length is generally recommended.
bun run start -- --chromium chromium.webm --firefox firefox.webm --android android.webm [--audio audio.webm] --output magic.webmPer-platform audio:
bun run start -- --chromium c.webm --audio-chromium ac.webm --firefox f.webm --audio-firefox af.webm --android a.webm --audio-android aa.webm --output magic.webmWith recommended flags:
bun run start -- --chromium c.webm --firefox f.webm --android a.webm --remove-length --output magic.webmA browser-based Svelte app in packages/web lets you create magic WebM files using ffmpeg.wasm (no FFmpeg install required). Run it with bun run web or bun run dev for live reload.
Note: ffmpeg.wasm is currently slow; for faster processing, the CLI is recommended.
piousdeer created the original magic WebM videos that spread on Discord in 2022–2023. I reverse-engineered their work and built this tool. A notable example: piousdeer/magic.webm
This project is approximately 70% AI-generated; all research was done by me (BlackOfWorld). The repo includes an updated 010 Editor template (EBML.bt) for EBML/WebM, updated for newer versions and additional elements; it was used during the research.