
Chroma key video
Remove a solid background color from a video, frame by frame, replacing it with transparency, a flat color or a black-and-white matte. In the browser only, like video-watermark, because compositing needs a decoded frame from WebCodecs, which Node has no equivalent of. Nothing is uploaded.
Chroma key video pulls one flat background colour from every frame and swaps it for transparency, a solid fill, or a monochrome matte, over a tolerance from 0 to 100. Each frame is decoded, composited and re-encoded through WebCodecs, which is why this stays browser-only. Transparent results save as WebM, since MP4 has no alpha channel; the other two modes write MP4.
Questions
What colour does it key out by default?
A pure green, #00ff00, the common chroma key colour. You can set keyColor to any 6 digit hex value to match your actual background.
What does tolerance control?
How close a pixel has to be to keyColor to count as background, from 0 to 100. A higher tolerance keys out a wider range of similar colours, which can also eat into edges of your subject.
What is the difference between the three modes?
background fills the key colour with a solid backgroundColor and writes MP4. transparent keeps an alpha channel and writes WebM, since MP4 cannot store one. matte writes plain white where the key matched and black elsewhere.
Why does it only run in a browser?
Because compositing needs a decoded frame drawn on a canvas for every single frame of the video, and that decode runs through WebCodecs, which Node has no equivalent of.
What does the result text tell me?
The percentage of pixels across the whole video that matched the key colour, which is a rough check on whether your tolerance and colour choice were close.
Compare
| Tool | Runs on the CLI | Live as you type |
|---|---|---|
| Chroma key video | No | No |
| Watermark video | No | No |
| Burn in subtitles | No | No |
| Extract subtitles from video | Yes | No |