npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chromakey-video-react

v0.1.1

Published

Real-time chroma key (green screen) video in React. GPU-powered WebGL shader. No FFmpeg, no pre-processing, works everywhere.

Readme

chromakey-video-react

npm version license bundle size

Real-time chroma key video in React. No FFmpeg, no pre-processing, runs on the GPU.

Drop a green-screen video into your React app and get instant transparency, rendered frame-by-frame on the GPU with a single WebGL shader. No server, no WASM, no waiting.

Try the playground →

Install

npm install chromakey-video-react

Quick Start

import { ChromaKeyVideo } from 'chromakey-video-react';

function App() {
  return (
    <ChromaKeyVideo
      src="/presenter-greenscreen.mp4"
      className="w-[400px]"
    />
  );
}

That's it. The green background is gone.

The Story Behind This

I needed a 3D animated mascot for my product's website. No budget for a designer, no patience for Blender. So I generated the character image with AI (Higgsfield.ai), then animated it into a 5-second looping video using Kling 2.5. The trick was rendering it on a solid green background so I could remove it later.

This is what the raw video looks like:

Now I needed to remove that green background. The obvious route: run FFmpeg with a chroma key filter, export a WebM with alpha transparency. Tried it. The results were rough. Green bleeding around the edges of the character, and WebM with alpha doesn't even work on Safari. File sizes balloon when you add a transparency channel.

So I wrote a WebGL fragment shader that does it in real-time, in the browser, on the GPU. It plays the original MP4 through a hidden video element, checks every pixel for "is this green?", and sets matching pixels to transparent. The result renders on a canvas with a transparent background. Cleaner output, works everywhere, and you can tweak the thresholds without re-encoding anything.

Here's what the final result looks like, green background completely gone, running live in the browser:

Why Not FFmpeg / WebM with Alpha?

| | This package | FFmpeg pre-processing | WebM alpha | |---|---|---|---| | Setup | npm install, done | Need FFmpeg pipeline, server or build step | Need to re-encode video | | File size | Regular MP4 | Same or larger | 2-5x larger (alpha channel) | | Browser support | All (WebGL) | N/A | Chrome/Firefox only (no Safari) | | Runtime cost | GPU shader, ~0ms CPU | None (pre-processed) | Decode cost for larger file | | Flexibility | Adjust threshold live | Re-encode to change | Re-encode to change | | Any key color | Change via prop | Different preset per color | Baked in |

The sweet spot: keep your regular MP4 files (small, compatible everywhere), and the GPU does the keying at 60fps.

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | src | string | required | Video source URL | | color | string | "#00ff00" | Hex color to key out (e.g. "#00ff00" for green, "#0000ff" for blue) | | similarity | number | 0.35 | How aggressively to match the key color (0-1). Higher = more removal. | | blend | number | 0.15 | Soft edge blending range (0-1). Higher = softer edges. | | despill | boolean | true | Remove color spill/tint from edges of the subject | | loop | boolean | true | Loop the video | | autoPlay | boolean | true | Auto-play the video (always muted for browser autoplay policy) | | className | string | — | CSS class applied to the <canvas> element |

Advanced Usage

Blue Screen

<ChromaKeyVideo src="/blue-screen.mp4" color="#0000ff" />

Fine-tuning

<ChromaKeyVideo
  src="/tricky-footage.mp4"
  similarity={0.4}  // more aggressive removal
  blend={0.2}       // softer edges
  despill={true}    // clean up color fringing
/>

Tips

  • Background color matters. Use a color far from anything in your subject. Green (#00ff00) is standard. If your subject has green, use magenta (#FF00FF).
  • Keep everything opaque. Semi-transparent elements in the video (holographic effects, glass, etc.) will cause issues with chroma removal.
  • CORS headers. If your video is cross-origin, make sure it's served with proper CORS headers or WebGL can't read the frames.

Browser Support

Works in all browsers that support WebGL (97%+ global coverage).

Read More

📖 How I built real-time green screen removal in the browser

Credits

Built by @_itsanl (Alfredo Natal) while building TCT, a Chrome extension that helps traders grade their setups before entering.

License

MIT