VideoTextureScrub Op
Playing a video file with scrubbing
Playing a video file with scrubbing
Summary (oneliner)
Technical Report: Optimized Video Scrubbing in WebGL
1. Core Concept
This operator is a WebGL video texture player specifically engineered for fluid, zero-latency scrubbing on the web.
- The Video Format (GOP = 1): Standard videos compress data by calculating changes between frames, which causes heavy lag when scrubbing. Encoding the video with a GOP of 1 saves every frame as a complete picture, guaranteeing instant visual access.
- The Memory Trick (RAM Caching): Rapid scrubbing floods the browser with cancelled network requests. This operator solves this by downloading the entire video into local memory (RAM) upfront, bypassing the internet entirely during interaction.
2. Code Modifications
- Blob Fetching: Replaced the standard video URL with a
fetch()command to download the entire file into memory as a Blob. - Virtual URL: Used
URL.createObjectURL()to link the video player directly to this local memory chunk. - Memory Cleanup: Added
URL.revokeObjectURL()to delete the memory chunk when the video is changed or removed, preventing memory leaks. - Command Throttling: Added a check (
videoElement.seeking) to ignore new slider movements if the player is still decoding the previous frame. - Auto-Catchup: Added an
onSeeked()event to instantly snap the video to the latest mouse position once the player finishes its current task.
- Ops.Patch.Pm4qOeu.VideoTextureScrub
- Patch Op - visible in this patch only
- MIT
- Sep 4, 2026 at 10:23
- interactionneededbutton
- cgl
Documentation (markdown)
Issues
Example patch id
Youtube ids (comma seperated)
Op Licence
Caniuse query
Real time Video scrubbing
Understanding WebGL Video Scrubbing
When building interactive media experiences on the web, users expect instant, fluid control when scrubbing through a video timeline. However, standard HTML5 video elements are designed for linear playback. When a user rapidly drags a time slider, standard streaming creates a bottleneck of cancelled network requests and heavy decoding lag.
To achieve frame-accurate, zero-latency scrubbing, two critical pieces must align:
- The Video Encoding (GOP = 1): Standard codecs save space by calculating changes between frames, forcing the browser to perform heavy math during a seek. By encoding the video with a GOP of 1 (All-Intra), every single frame becomes an independent keyframe, allowing instant visual access.
- The Memory Strategy (RAM Caching): Instead of relying on live streaming which stutters under rapid input, downloading the entire file upfront into a local memory Blob completely bypasses network latency.
By combining a properly encoded MP4 file with an optimized WebGL texture operator (VideoTextureScrub), developers can achieve perfectly smooth, responsive video control in real-time.
INPUT PORTS
File to play
Start playback
Loop file when it reaches the end
Audio
Audio volume
mute audio
Texture
Flip the texture
Timing
Speed of playback
Set time to trigger playback from
Load into memory - useful when loading from a URL
OUTPUT PORTS
Texture out
Duration of loaded media
Playback progress
Width of texture
height of texture