Website background video: size, format and performance
How to make a background video that loads fast and reads well: length, resolution, H.264 and AV1, the poster and LCP, autoplay rules, contrast and motion.
- For
- Developers and designers adding video behind a page
- Written for
- Claude CodeCodexCursorGitHub CopilotGemini CLIOpenCodeAny agent that reads SKILL.md folders
- Time
- 6 min read · updated Oct 26, 2026
The short answer
- Keep it short and silent: a 5 to 15 second loop, 1080p at most on desktop and smaller on phones, with no audio track.
- Serve an H.264 MP4 that plays everywhere, add an AV1 version first for browsers that can play it, and give the video a light poster image.
- Use
autoplay muted loop playsinline, keep text at 4.5:1 contrast over every frame, show the poster with reduced motion, and offer a pause button.
A background video is decoration. Visitors came for the words on top of it, so every choice below comes from one rule: the video must never make the page slower to show, harder to read or harder to use. For the step-by-step build with an agent, see Add a video background hero with Claude Code. This page is the reference behind it.
Length and content
- 5 to 15 seconds is enough for a loop. Longer clips cost more bytes and nobody watches a background to the end.
- Slow, steady motion loops better and compresses smaller than fast cuts. Busy footage behind text is also harder to read.
- A calm area where the headline sits, or a darker grade, saves you from a heavy overlay later.
- A clean loop: cut where the last frame flows into the first, or fade both ends to the same color.
Resolution and file size
Encode at 1920 pixels wide at most for desktop and about 1280 for phones. A background is usually covered by text and an overlay, so it can be softer than a video people watch. Drop the frame rate to 24 or 30 if the source is higher.
There is no single right size. Compare the video with the rest of the page: if it weighs more than everything else on the first screen together, shorten it, lower the resolution or raise the compression.
Formats: H.264 and AV1
Encode the H.264 file with FFmpeg. -an drops the sound, -pix_fmt yuv420p keeps it playable in Safari, and +faststart lets playback begin before the file has fully arrived:
Then an AV1 version, if your FFmpeg has the SVT-AV1 encoder (ffmpeg -encoders | grep svtav1). Its -crf runs from 0 to 63; higher is smaller and softer:
List the AV1 file first, with its codecs string, so browsers that can’t play it move on to the H.264 file:
The poster and Largest Contentful Paint
Google’s Largest Contentful Paint (LCP) counts a video by whichever comes first: its poster image loading or its first frame showing. A good LCP is 2.5 seconds or less. So the poster matters more than the video for how fast the page feels:
- Save the first frame as a compressed WebP or JPEG poster:
ffmpeg -i public/hero.mp4 -frames:v 1 -q:v 3 public/hero-poster.jpg. - Make the poster the same frame the video starts on, so nothing jumps when playback begins.
- Keep the headline as real HTML text over the video, not baked into it. Text can be the LCP element itself, and it doesn’t wait for the video.
The preload attribute is only a hint, and autoplay takes precedence over it, so a video that autoplays starts downloading anyway. For a video far down the page, leave out autoplay and start it with JavaScript when it scrolls into view.
Autoplay rules
- Muted: browsers reliably autoplay only video without sound. Without
muted, most first visits get no autoplay. - playsinline: iPhones need it to play the video inside the page instead of full screen.
- loop repeats it; without it the video stops on its last frame.
- Plan for no autoplay at all. Power-saving modes and some settings block it, and then the poster is all visitors see. It has to work on its own.
Text over video
Text needs a contrast of at least 4.5:1 against what is behind it (3:1 for large text) on every frame, not just the first. A dark gradient behind the text is the usual fix. Check the brightest moment of the clip, not the one in your screenshot.
Motion and control
- Respect
prefers-reduced-motion: show the poster and don’t play. - Add a visible pause button that works with the keyboard. WCAG’s Pause, Stop, Hide rule requires a way to pause motion that starts on its own and lasts more than five seconds.
- Mark the video
aria-hidden="true"when it is decoration, so screen readers skip it.
Examples you can build with an agent
These Lookbk skills build a hero with moving footage and handle the poster, the fallback still, the phone layout and the checks for you. Each card plays the skill’s real rendered preview.
Scroll Film Hero takes your own clip and plays it as the visitor scrolls. The Footage Heroes ship their own film and show a still if the film fails, autoplay is blocked or it takes more than 8 seconds to start. See the best video background hero sections for all of them.
Common questions
- What is the best format for a website background video?
- An H.264 MP4 with no audio, because every current browser plays it. Add an AV1 MP4 before it for a smaller file where the browser supports it.
- How big should a background video be?
- As small as still looks right behind your text. Start at 1920 pixels wide for desktop and about 1280 for phones, 5 to 15 seconds long, and compare its weight with the rest of the page.
- Does a background video hurt SEO?
- Not by itself. What can hurt is a slow page: LCP counts the poster or first frame, so a light poster and real HTML text keep it fast.
- Should I host it on YouTube or Vimeo?
- Not for a background. An embedded player adds its own scripts and controls and takes away your control of the poster. Serve the MP4 from your own site or CDN.
Sources
What this guide says about other companies’ tools comes from their own documentation, checked on Oct 26, 2026.
- web.dev: Largest Contentful Paint (opens in a new tab)
- MDN: web video codec guide (opens in a new tab)
- MDN: the codecs parameter (opens in a new tab)
- MDN: the video element (opens in a new tab)
- Chrome for Developers: autoplay policy in Chrome (opens in a new tab)
- WebKit: new video policies for iOS (opens in a new tab)
- MDN: prefers-reduced-motion (opens in a new tab)
- W3C: Understanding WCAG 2.2, Contrast (Minimum) (opens in a new tab)
- W3C: Understanding WCAG 2.2, Pause, Stop, Hide (opens in a new tab)
Did this guide help?
Read next
All guidesHow to add a video background hero with Claude Code
Put a looping video behind your headline with Claude Code: prepare the file with FFmpeg, markup that autoplays, contrast, reduced motion and page weight.
Text-behind-subject website heroes: how they work and how to make one
How the text-behind-subject effect works on a web page: a cut-out of the subject drawn over real HTML text, for a photo or a video, and how to build one.
How to make videos with Claude Code
Three ways to make MP4 videos with Claude Code: Remotion’s skills, HyperFrames, or a ready-made video skill. Setup, a first render and fixes.
See a skill’s result before you install it.
Every skill page shows what it makes, what it needs and which agents can run it.



