AMBIENT LIGHT PLUGIN FOR HTML VIDEO

Let the <video/> light the page.

Video Lighting (videolight on npm) is an open-source JavaScript and React plugin for HTML video. It turns the colors along a video's edges, on every frame, into a glow, an ambient background or a themed interface. No blurred copy of the picture: just a color for each zone.

Paste the prompt into your AI assistant and it wires Video Lighting into your player.

0:00

This video runs on Video.js 10.

  • React and plain JS: one component or one function per effect
  • Every frame read
  • 3.5 ms on Chrome, 4K, measured
HOW IT WORKS

We read the edges. We don't copy the picture.

YouTube's ambient mode blurs a copy of the frame behind the player, and an Ambilight TV lights the wall from the edges of the screen. Video Lighting does the second, in the browser: one color per edge zone, read on every frame.

12 ZONES ON THE LONG SIDES, 7 ON THE SHORT ONES: THE SAME SIZE EVERYWHERE, EVERY FRAME

● reading
method …
latency …
frames skipped 0
THE COMMON WAYa second picture behind the player
1your video
2copied again, every frame
3stretched and blurred behind
OUR WAY
  • Reads only the edges. One color per zone, every zone the same size, on every frame.
  • Off the main thread. The reading runs in a worker: your page keeps its frames.
  • You get the numbers. Halo, background, interface: you decide what they become.
GET STARTED

Install it, pick an effect, done.

Add an ambient glow to an HTML video in a few lines. Halo lights the edges of the player, Ambient the page background, Theme the colors of your interface, and useColors hands you the raw colors. One read of the video is shared by every effect, and each one is a React component and a plain JavaScript function.

Works on any video your page can read: same-origin, or served with CORS headers.

  1. Install

    No dependencies. Works with any bundler, or without one.

    $ npm install videolight
  2. Pick an effect

    Each effect lights a different part of your page. These previews run on the real plugin, driven by the video above.

    Halo
    Bands of the video's own edge colors fade out around the player.
    Around the player
    Live
    reach
    140
    opacity
    0.85
    Props
    reachnumber
    How far the bands reach, in px. Default 140.
    opacitynumber
    Strength of the bands, 0 to 1. Default 0.85.

    Every effect also takes onError, called if the browser refuses to read the video.

    import { Halo } from "videolight/react";
    export default function Player() {
    return (
    <Halo reach={140} opacity={0.85}>
    <video src="/movie.mp4" controls />
    </Halo>
    );
    }
THE ADAPTIVE ENGINE

It measures your browser instead of guessing.

Browsers and machines disagree about what is fastest: reading a frame on the GPU wins on one, on the CPU on another, and a laptop under load is not the machine it was a minute ago. So Video Lighting tests, decides, and checks again, for as long as the video plays.

  1. 01

    Measure

    The same frames read both ways, through the GPU (WebGL) and the CPU (canvas), inside a worker.

  2. 02

    Pick

    Keep the faster path, only when it wins clearly, so it does not flip-flop between two near-equal paths.

  3. 03

    Watch

    Re-check when the machine slows down or speeds up, when the picture changes size, and on a timer. Then measure again.

No browser sniffing and no hard-coded list, so nothing goes stale when a browser updates. Where workers are not available, Video Lighting falls back to the main thread.

MEASURED, NOT PROMISED

From the frame to the colors, in a few milliseconds.

LATENCY, FRAME TO COLORS, 4K VIDEO
Chrome3.5 ms
x
Safari3.6 to 5.2 ms
x
Firefox10.4 ms
x
iPhone[to be measured]

Bars share one scale: 12 ms = full width. Measured on [machine, browser versions, date].

Off the main thread

Frames are handed to a worker, so scrolling and input stay smooth.

Every frame

Each presented frame is read. None skipped in our end-to-end tests on Chrome, Firefox and WebKit.

FAQ

Before you add it to your player.

Does it work with YouTube or Vimeo embeds?

No. Video Lighting reads the pixels of a <video> element, and a browser does not let a page read inside an iframe from another site. It works with video you host, MP4 or HLS. DRM-protected video is not supported either.

Why is the glow blank on my video?

The browser must be allowed to read the pixels: same origin, or CORS headers plus crossorigin="anonymous" on the <video>. Pass onError to be told when reading is refused.

Which players does it work with?

This page runs on Video.js 10. Video Lighting only needs the <video> element, so a player that exposes it should work. Video.js 10 is the one we have tested so far.

Do I need React?

No. Each effect is a plain JavaScript function: halo(video), ambient(video), theme(video) and watch(video). The React components live in videolight/react (React 18 or later, React 19 tested).

Will it slow my page down?

The reading runs in a worker, off the main thread, and the engine picks the faster of GPU and CPU for each browser. See the measured figures above.

Try it on your own player.

One install, one line per effect. If it earns its place, a star on GitHub helps others find it.

Star on GitHubRead the docs