Making a looping hero video for your homepage with ffmpeg
Background videos only work if they are tiny and loop without a jump. Both are one ffmpeg command away.
The recipe
Trim to a whole number of seconds, strip audio with -an, scale to 1280 wide, and encode with a high CRF. Then crossfade the last half second into the first for a seamless loop.
- Always strip audio with -an.
- Use -movflags +faststart so it plays before it finishes downloading.
- Add muted and playsinline for autoplay on phones.