Loading video...

Video Failed to Load

Go Home

I've done so many scrubbed video sequences on scroll over the years, that I thought it would be helpful to share some pro tips in this thread:

70,247 views • 2 years ago •via X (Twitter)

10 Comments

Josh Kirk's profile picture
Josh Kirk2 years ago

Generally the process looks like this: 1. Get your source video at 1.2-1.5x the width where it will be used, compress using a tool like 2. Use ffmpeg to cut the video into frames. Make sure to have a different frame set for desktop and mobile.

Josh Kirk's profile picture
Josh Kirk2 years ago

3. Do whatever you can do decrease the frame file size. If you have some frames that don't require transparency, they should be jpeg/webp. 4. Load said frames as blob images using a javascript webworker (see image) which moves the fetching and decoding off the main thread.

Josh Kirk's profile picture
Josh Kirk2 years ago

5. Once you have all your images back from the worker, draw the first frame to your canvas and watch for the section to be in view. 6. While in view, determine the percentage of the animation you've scrolled through, making sure to not draw the same frame twice in a row.

Josh Kirk's profile picture
Josh Kirk2 years ago

And that's pretty much it in terms of implementation. But it's worth mentioning that there are some optimizations that can happen before even getting to development. For example, consider advising your art directors to prioritize:

Josh Kirk's profile picture
Josh Kirk2 years ago

1. Shots with simple color palettes, avoiding complex image data. A mostly-black frame will be significantly smaller than a frame from a video with grass and leaves.

Josh Kirk's profile picture
Josh Kirk2 years ago

1a. Sequences that focus on the main subject.. Try to remove all background objects & scenery (replace with a solid color) 2. Smooth movements that can be cleanly expressed with lower framerates. Lots of fast movements/cuts require framerates that are hard to tie to scroll.

mitch.'s profile picture
mitch.2 years ago

This is great! A video tutorial would be awesome, do you have one?

Meris's profile picture
Meris2 years ago

Nice tips, it comes down to loading speed and every small detail is important

Thom Aufresne's profile picture
Thom Aufresne2 years ago

Very insightful thank you! In your experience, is using a video file an option? I'm often battling weird behaviors/animation getting stuck when scrubbing a video

Terkel Gjervig's profile picture
Terkel Gjervig2 years ago

Wow, I've implemented this countless times, but I've learned a few tricks from your insights. Thanks for sharing!

Related Videos