About this Demo
This demo shows how you can stream video frames using the WebCodecs API into Cavalry's web player. It implements a pull-based system where Cavalry requests frames as needed, and the browser decodes and delivers them on demand.
Key Features:
- Chunk-based Prefetching: Frames are decoded in 10-frame chunks as playback progresses, keeping memory usage low
- Arbitrary Frame Seeking: Click anywhere on the timeline - the system finds the nearest keyframe, decodes from there, and displays your requested frame instantly
- Seamless Looping: Video loops automatically when reaching the end
- Browser Adaptation: Automatically detects the fastest frame copy method for your browser (direct copy in Chrome/Edge, canvas fallback in Safari)
- Memory Management: Old frames are automatically evicted from the cache to prevent memory exhaustion on long videos
Please see webcodec-helper.js for more details.