A <video> element inside a canvas

The player below is a <div fx> that holds a <video controls> with a captions track, and an HTML label with a button. All of it is drawn into a canvas through a fragment shader. Use the video's own controls and the button, then change the source and the effect.

Frame 0

Show the code a video under a shader
  1. The markup. The fx attribute puts the <div> and everything in it into a canvas. The video has no drawable attribute of its own.
  2. The CSS. ::cue styles the captions. They're drawn into the canvas with that style.
  3. Two effects written for this page. Each is a GLSL function and the same function in WGSL. tex(p) samples the element, video frame included.
  4. Reading the frame number. requestVideoFrameCallback() runs once per presented frame. Writing the number into the label changes the DOM, and the canvas is repainted with the same frame.
  5. Changing the source. The cross-origin and encrypted sources are here to show what the canvas leaves out.
  6. Clear Key. The licence is a JSON object made in the page.
  7. Inside the library: the upload and the draw.

How it works

Live checks

Each check builds its own small canvas in a corner of the window. The player above isn't touched.

ResultExperimentDetail

Findings

From Chromium 157 with software video decoding and software rendering. The rows above say what your browser does.