Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Smooth Scrubbing Web Video FFMPEG Mega Command
ffmpeg -i input.mp4 -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3 -an -vf "scale=-1:1440, reverse" -preset veryslow -g 2 output.mp4
// -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3
// Encode for web with a good balance of browser compatibility and compression ratio
// -an
// Strip audio tracks
// -vf "scale=-1:1440, reverse"
// Scale video to 1440px wide, maintaining aspect ratio
// And reverse the video (remove if not necessary)
// -preset veryslow
// Longer encode time on machine, better quality output
// -g 2
// SUPER IMPORTANT
// -g specifies the interval of Key Frames, in this case make every 2nd frame a Key Frame
// Standard compressed videos that just play through normally or continuously loop
// should have a low Key Frame count to save on file size. But a high number of keyframes
// is crucial for smooth scrubbing and forward/reverse playback.
// -g 1, meaning every single frame is a KeyFrame would be the smoothest, but basically doubles the file size.
// -g 2, seems like a good balance of very smooth playback with decent file size.
// -g values much higher than two will start to produce noticeable lag between key frames when scrolling.
@ryandoss

This comment has been minimized.

Copy link

commented Feb 6, 2019

Glorious... bless you for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.