Dynamically Chroma Keying Youtube videos

Posted by Pockets Dev Team on Tuesday, September 3rd, 2024 - 7:25am

This is a simple demo of using an SVG for chroma keying a youtube video embed.

This code applies a custom color filter to a YouTube video using an SVG filter with an <feColorMatrix> element. The <feColorMatrix> transforms the colors of the
video by manipulating its red, green, and blue channels according to the matrix values provided. In this case, the matrix adjusts the colors to create a "green screen" effect by altering the color intensity, which can isolate or remove specific colors.

To apply the filter, the code generates a unique ID for the filter and references it in the filter style property of the video container. The SVG filter is defined within a hidden <svg> element in the HTML, and the unique filter ID ensures that it can be applied specifically to the targeted video element without affecting other elements on the page.

Example code:

Warning! Some videos may contain flashing lights!

And here's some more random chroma keyed videos with static background images.

Here's some with animated gifs for backgrounds.

Related Posts

How to use grid to animate size transitions without setting dimensions Published Saturday March 7th, 2026 11:39am

This article discusses how CSS Grid can be used to smoothly animate size changes that normally can’t be animated in CSS, such as transitions between collapsed and expanded content. It explains how animating grid-template-rows or grid-template-columns with fr units allows elements to grow or shrink fluidly without relying on fixed heights or JavaScript.

How to stack elements without using position absolute Published Wednesday March 4th, 2026 12:03pm

This article discusses how to stack elements using grid, instead of using position absolute.

Using a Custom Element to create re-usable VUE apps Published Friday September 6th, 2024 5:56am

This article covers how to create a custom element that can be used to create VUE instances automatically when the element is in the DOM.