Understand ScrollyVideo playback methods
mainScrollyVideo uses three different methods to animate video based on browser support and scroll direction:
- WebCodecs and Canvas: The most performant method. It extracts frames using the WebCodecs API and draws them to a canvas. It is currently only available in Chrome and requires time to process frames on load.
- HTML5 Video and playbackRate: A fallback for browsers without WebCodecs. It modulates the
playbackRateof an<video>tag. This is very smooth for forward scrolling but does not work for reverse scrolling becauseplaybackRatecannot be negative. - HTML5 Video and currentTime: The fallback for reverse scrolling or when other methods fail (e.g., Mobile Safari). It jumps to specific frames using
currentTime. For best performance, videos should be encoded withkeyframe = 1to avoid quality drops or large file sizes.