DEV Community

Betty Johnson
Betty Johnson

Posted on

How to remove white background from video in browser (No Premier/AE needed)

Ever needed to drop an animation, logo, or green-screen-like clip into your web project, only to realize the source video has a plain white background instead of transparency?

If you're like me, opening Premiere Pro or After Effects just to key out a simple background feels like overkill. So I decided to tackle this directly in the browser.

The Problem with White Backgrounds in Video

Unlike PNGs, standard web video formats (like MP4/H.264) don't natively support alpha transparency out of the box. If you play a video on a modern webpage with dark mode or custom branding, that white rectangle sticks out like a sore thumb.

How it works under the hood

To remove a white background without heavy desktop software, you can leverage the Canvas API or WebGL in JavaScript:

  1. Draw the video frame to an HTML5 <canvas>.
  2. Read the pixel data using getImageData() or run a custom fragment shader.
  3. Calculate color distance: Check how close each pixel's RGB values are to pure white (255, 255, 255).
  4. Adjust Alpha: Set the alpha channel to 0 (transparent) for white pixels, or apply a smooth falloff threshold for off-white edges to avoid jagged borders.
  5. Render frame-by-frame: Hook this logic into requestAnimationFrame().

Want a quick zero-code solution?

If you just want to get the job done right now without writing custom shaders, check out this free online tool to remove white background from video. It processes everything locally in your browser—fast, free, and no upload waiting time.

How do you usually handle video transparency in your web projects? Would love to hear your tricks or performance tips in the comments!

Top comments (0)