All answers · Motion and code · 55 questions

Video backgrounds, answered.

This page answers the questions people ask when they put moving footage behind a hero or scrub a film with the scroll. It is for designers, developers and AI builders who want cinematic video that loads fast, plays on phones and respects visitors who prefer less motion.

How do I add a video background to a website hero?

Place a video element inside the hero with the attributes autoplay, muted, loop, playsinline and a poster image, position it absolutely behind the content, and set object-fit: cover so it fills the area. Put the headline and buttons in HTML above it with a dark overlay for contrast. Keep the clip short and compressed, and show only the poster to visitors who prefer reduced motion.

Video background templatesCinematic backgrounds

Why won't my background video autoplay?

The most common reason is that the video is not muted. Chrome, Safari and Firefox allow autoplay with sound only after a user interaction or under site-specific rules, but they allow muted autoplay. Add the muted attribute together with autoplay, and on iPhone also add playsinline. Other causes are a blocked file type, iOS Low Power Mode, a browser setting that blocks all autoplay, or an error in the source URL.

Video background templatesScroll-scrubbed video hero

Why does my background video autoplay on desktop but not on iPhone?

On iPhone, a video autoplays only when it is muted and has the playsinline attribute, otherwise Safari waits for a tap or tries to play full screen. Low Power Mode can also stop autoplay and show the poster instead. Add muted, playsinline and autoplay together, make sure the file is H.264 MP4 or another format the phone can decode, and always set a poster so the hero looks finished either way.

Fast animation on phonesVideo background templates

What does the playsinline attribute do on a video?

The playsinline attribute tells mobile browsers, mainly Safari on iPhone, to play the video inside the page instead of switching to the full-screen player. Without it, an iPhone will not autoplay a background video in place. For hero backgrounds always combine playsinline with muted, autoplay and loop. In React, the attribute is written as playsInline in JSX.

Video background templatesCinematic backgrounds

Do I need a poster image for a background video?

Yes. The poster is what visitors see while the video loads, when autoplay is blocked, on slow connections and when they prefer reduced motion. Use a compressed still of the first frame, so the switch to video is not noticeable, in WebP or AVIF at the display size. The poster is also an image the browser can treat as the Largest Contentful Paint element, so make it light and load it early.

Video background templatesPerformance answers

How big should a background video file be?

Aim for a few megabytes at most, and under about 3 MB for the version phones download, with smaller always better. That is a suggested budget, not a standard. A short loop at 720p with no audio and a constant rate factor around 26 to 30 often fits. File size grows with resolution, length, motion and grain, so a calm, short shot compresses far better than handheld footage.

Fast animation on phonesCinematic backgrounds

What is the best video format for website backgrounds?

H.264 in an MP4 file is the safest choice because it plays in every current browser and has hardware decoding on almost every device. WebM with VP9 and MP4 with AV1 give smaller files at the same quality, so you can list one of them first and H.264 MP4 last as the fallback. The browser plays the first source it supports.

Video background templatesScroll-scrubbed video hero

Should I use MP4 or WebM for a background video?

Use both if you can: WebM with VP9 first for smaller files, then H.264 MP4 as the universal fallback. If you ship only one file, choose H.264 MP4, because it plays everywhere, including older iPhones. VP9 typically saves a noticeable share of the bytes at the same visual quality, but encoding takes longer. Test both on a real phone before deciding.

Video background templatesFast animation on phones

Is AV1 a good codec for website background videos?

AV1 gives the smallest files of the common web codecs at the same quality, but it encodes slowly and older devices lack hardware decoding. Apple devices support AV1 only on newer chips with hardware decode, and software decoding drains battery. Offer AV1 as the first source with a type attribute, followed by VP9 or H.264, so devices that cannot play AV1 fall back automatically.

Video background templatesPerformance answers

How do I offer several video formats so each browser picks one?

Put several source elements inside the video element, each with a src and a type attribute, smallest codec first. For example, list an AV1 or VP9 WebM file, then an H.264 MP4. The browser checks the type values and plays the first source it can decode, so the order matters. Do not set src on the video element itself, because it overrides the source children.

Video background templatesScroll-scrubbed video hero

What bitrate should a website background video use?

Roughly 1 to 2 Mbps is often enough for a 720p background loop, and around 2 to 4 Mbps for 1080p in H.264, as a rule of thumb. Background footage sits under text and overlays, so it can take more compression than a feature video. Prefer a constant rate factor over a fixed bitrate, because it spends bits where the shot needs them and keeps calm scenes small.

Fast animation on phonesCinematic backgrounds

What CRF value should I use in ffmpeg for web video?

For H.264 with libx264, a CRF between 23 and 28 suits most website video, and 26 to 30 works for backgrounds under text. Lower numbers mean higher quality and bigger files; the libx264 default is 23 on a scale of 0 to 51. VP9 uses a different scale from 0 to 63, typically with -b:v 0 for constant quality. Compare a few values on the real page.

Scroll-scrubbed video heroVideo background templates

What ffmpeg command compresses a video for a website background?

A solid starting point is ffmpeg -i input.mov -an -vf scale=1280:-2 -c:v libx264 -crf 27 -preset slow -pix_fmt yuv420p -movflags +faststart hero.mp4. The -an flag drops audio, scale sets the width and keeps an even height, yuv420p keeps the file playable everywhere, and faststart moves the index to the front so playback starts sooner. Make a 1920 wide version for large screens the same way.

Scroll-scrubbed video heroFast animation on phones

What does the faststart flag do in ffmpeg?

The -movflags +faststart option moves the MP4 index, called the moov atom, to the front of the file in a second pass. Without it the index often sits at the end, and the browser has to fetch the end of the file before it can start playing. For web video, background loops and scroll-scrubbed heroes, always encode with faststart. It does not apply to fragmented MP4 output.

Scroll-scrubbed video heroVideo background templates

What resolution should a background video be on phones?

Around 720p is usually plenty for phones, and many sites use a portrait or square crop around 720 pixels on the long or short side for small screens. A phone screen is small and the video sits under text, so 1080p adds bytes the visitor cannot see. Serve a 1080p file only to large screens, choosing the source with a media query check in JavaScript before setting src.

Fast animation on phonesVideo background templates

How long should a hero background video be?

Short loops of a few seconds to about 15 seconds work best for hero backgrounds. A shorter clip is a smaller file, loops more often without anyone noticing, and keeps the hero calm under the headline. Choose one continuous shot with slow movement, such as a push in, a drifting camera or moving water. AnimatedWebs cinematic loops are short, seamless clips made for this use.

Cinematic backgroundsVideo background templates

How do I make a seamless looping background video?

Make the last frame match the first. Either film or generate a shot that returns to its start, or crossfade the end of the clip into its beginning in an editor so the cut disappears. Avoid people walking out of frame and sudden light changes. Add the loop attribute to the video element. AnimatedWebs offers original seamless film loops on its cinematic backgrounds page, with new loops added every week.

Cinematic backgroundsAnimated backgrounds

Why does my looping background video jump or pause at the loop point?

A visible jump usually means the last frame does not match the first, so the cut shows. A short pause can come from an audio track that is longer than the video, extra frames added during export, or the browser restarting playback. Drop the audio with -an, trim the clip to exact frames, and blend the end into the start. For a perfect join, crossfade two video elements in JavaScript.

Cinematic backgroundsVideo background templates

Should a background video have an audio track?

No. Remove the audio track entirely, for example with the -an flag in ffmpeg. A background video must be muted to autoplay anyway, so an audio track only adds bytes the visitor never hears. Without audio, the video also needs no captions for speech, though it still needs a pause control if it moves for long.

Video background templatesScroll-scrubbed video hero

How do I make a video cover the whole hero like background-size: cover?

Give the video position: absolute, inset: 0, width: 100%, height: 100% and object-fit: cover inside a hero with position: relative and overflow hidden. Object-fit: cover crops the video to fill the box while keeping its aspect ratio, just as background-size: cover does for images. Use object-position to choose which part stays visible when a phone crops the sides.

Video background templatesTailwind templates

Can I use a video as a CSS background-image?

No. CSS background-image accepts images and gradients, not video files. Use a real video element positioned behind the content with object-fit: cover, which gives the same result and supports a poster, autoplay and pausing. Animated GIFs work as CSS backgrounds but are far heavier than video and cannot be paused, so they are a poor substitute for a hero.

Video background templatesAnimated backgrounds

How do I keep text readable over a background video?

Put a semi-transparent dark or brand-colored overlay between the video and the text, or a gradient that is darkest behind the headline. Check contrast against the brightest frame, not the average one, because WCAG asks for 4.5 to 1 for normal text and 3 to 1 for large text. Calm footage without bright flashes helps, and a text shadow can rescue thin spots.

Video background templatesStyles

What is a scroll-scrubbed video?

A scroll-scrubbed video is a clip that never plays on its own: scroll position is turned into a time, and the page sets the video's currentTime to that time. Scrolling down plays forward, scrolling up plays backward and stopping freezes the frame. It is usually placed in a sticky stage inside a tall section, so the visitor scrolls through the film while text arrives over it.

Scroll-scrubbed video heroScroll film templates

Why does my scroll-scrubbed video stutter or lag?

Scrubbing stutters because every scroll step is a seek, and normal video stores full pictures only at keyframes that can be seconds apart. To show one frame, the decoder jumps back to the last keyframe and decodes forward. Fix it by encoding with a short keyframe interval, lowering resolution, serving the file with byte-range support, and setting currentTime at most once per animation frame.

Scroll-scrubbed video heroScroll animation answers

What keyframe interval should I use for a scroll-scrubbed video?

Use a short interval, from a keyframe every frame up to one every 15 frames or so. In ffmpeg with libx264, set -g 15 for a keyframe every 15 frames, or -g 1 to make every frame a keyframe. Shorter intervals seek faster and more precisely but make the file larger. Test on a phone, because a desktop decoder hides problems a phone chip shows.

Scroll-scrubbed video heroScroll film templates

What is all-intra video encoding?

All-intra encoding stores every frame as a keyframe, with no frames that depend on others. In ffmpeg you get it with -g 1 for libx264. Any frame can then be decoded on its own, which makes seeking instant and exact, ideal for scroll scrubbing. The cost is a much larger file than normal encoding, so keep all-intra clips short and at modest resolution.

Scroll-scrubbed video heroScroll film templates

Should I use an image sequence instead of video for scroll scrubbing?

Use an image sequence when frame accuracy matters more than download size. Drawing numbered frames onto a canvas makes every scroll position exact and instant, with no video decoding, but the total download is usually larger than a compressed video and every frame must load. Video wins on bytes and an image sequence wins on precision. AnimatedWebs scroll-film templates use compressed WebP frames drawn on a canvas.

Scroll film templatesScroll-scrubbed video hero

How do I build a canvas frame sequence animation on scroll?

Export the clip as numbered WebP or AVIF frames, preload them into Image objects or ImageBitmaps, and draw the frame that matches scroll progress onto a canvas inside requestAnimationFrame. Load the first frame and a sparse set early, then fill in the rest, so the effect works before every file arrives. Size the canvas to the screen and cap the pixel ratio to keep drawing cheap.

Scroll film templatesScroll animation guide

How many frames should a scroll image sequence have?

A few seconds of footage at 24 to 30 frames per second, often somewhere around 100 to 200 frames, is a common range. More frames feel smoother on slow scrolls but add download weight, and fewer frames can still look fine on fast scrolls. Consider fewer frames for phones, compress each frame hard, and keep the visible size modest, since every frame is a full picture.

Scroll film templatesFast animation on phones

Does my server need byte-range support for video?

Yes, for smooth seeking. Browsers request parts of a video file with a Range header, and a server that supports it answers 206 Partial Content with a Content-Range header. A server that ignores ranges sends the whole file with status 200, and seeking gets slow or stalls, which ruins scroll scrubbing. Most static hosts and CDNs support ranges by default, but custom proxies sometimes break it.

Scroll-scrubbed video heroHosting

How do I set currentTime smoothly from scroll?

Do not set currentTime inside the scroll event. Store a target time from scroll progress in the event, and inside a requestAnimationFrame loop move the current time a fraction of the way toward the target each frame. Skip the seek when the change is smaller than one frame. This gives at most one seek per frame and makes the film glide instead of stepping with each wheel notch.

Scroll-scrubbed video heroScroll animation guide

Is video.fastSeek() better than setting currentTime?

Not for most sites. HTMLMediaElement.fastSeek() seeks quickly by trading precision for speed, often landing on a nearby keyframe, but it is not supported in all widely used browsers. Setting currentTime is precise and works everywhere, so it is the dependable choice for scroll scrubbing. If seeks are slow, fix the encoding with shorter keyframe intervals rather than relying on fastSeek.

Scroll-scrubbed video heroScroll film templates

Should I use a video background or a WebGL background?

Use video for real footage and photographic looks, and WebGL for abstract, interactive or resolution-independent effects. Video costs a fixed download but plays cheaply with hardware decoding. A WebGL shader is often a tiny download, reacts to cursor and scroll and stays sharp on any screen, but it uses the GPU every frame. AnimatedWebs offers both: cinematic film loops and live-code backgrounds built from a prompt.

Cinematic backgroundsShader templatesThree.js and WebGL answers

Is an animated GIF a good alternative to a background video?

No. An animated GIF is usually many times larger than the same clip as an MP4, is limited to 256 colors per frame, and cannot be paused from CSS. A short muted, looping, playsinline video gives better quality at a fraction of the size. If you need an image tag, animated WebP or AVIF are lighter than GIF, but video is still the better choice for a hero.

Video background templatesAnimated backgrounds

Do background videos hurt Core Web Vitals?

They can hurt Largest Contentful Paint if the video or poster is slow to load, and they compete for bandwidth with the rest of the page. They rarely hurt layout shift if the hero has a fixed size. Keep the poster small and load it early, compress the video, serve a smaller file to phones, and start loading the video after the main content has painted.

Performance answersPerformance data

Can a background video be the Largest Contentful Paint element?

Yes. The poster image of a video element is an LCP candidate, and Chrome can also use the first painted frame of the video. A hero video is often the largest element on the screen, so its poster usually decides LCP. Make the poster a compressed WebP or AVIF at display size, consider preloading it with fetchpriority high, and avoid hiding the hero behind a fade-in.

Performance answersFast animation on phones

How do I lazy load a background video?

Set preload="none" and leave out src, or keep the source URL in a data attribute, then assign it and call play() when an IntersectionObserver reports the video is near the viewport. For a hero at the top of the page, show the poster first and start the video after the page has loaded. Keep autoplay, muted, loop and playsinline on the element so play() is allowed.

Fast animation on phonesVideo background templates

Does loading="lazy" work on video elements?

No. The loading attribute works on img and iframe elements, not on video. To delay a video, use preload="none" or preload="metadata" and set the source with JavaScript when an IntersectionObserver sees the element. A video with preload set to none downloads nothing until it plays, though browsers treat preload as a hint and may differ in detail.

Fast animation on phonesVideo background templates

How do I serve a smaller background video on phones?

Encode two or more versions, such as 720p for phones and 1080p for large screens, then pick one in JavaScript with matchMedia before setting the src, so only one file downloads. Hiding one video with CSS may not stop the browser from downloading it. A portrait crop for phones often looks better and is smaller than shrinking a wide landscape clip.

Fast animation on phonesVideo background templates

Should I skip the background video on slow connections?

Yes, it is good practice. In Chromium browsers, navigator.connection.saveData is true when the visitor asked for data saving, and navigator.connection.effectiveType gives a rough connection class. These APIs are not available in every browser, so treat them as hints. When they signal a slow or metered connection, show the poster as a still image and skip the video download.

Fast animation on phonesPerformance answers

How do I make a background video accessible?

Give visitors a visible pause button, show the poster instead of the video when prefers-reduced-motion is set to reduce, keep text contrast high over every frame, and avoid flashing more than three times a second. Mark a purely decorative video with aria-hidden="true" so screen readers skip it. Any information the footage carries should also appear as text on the page.

Reduced motion and performanceAccessibility

Does a looping background video need a pause button?

Yes, under WCAG 2.2 Success Criterion 2.2.2 Pause, Stop, Hide, which is Level A. Moving content that starts automatically, lasts more than five seconds and appears alongside other content needs a way to pause, stop or hide it. A looping hero video meets all three conditions. Add a keyboard-reachable button that calls video.pause() and changes its label to Play.

Reduced motion and performancePerformance answers

How do I respect prefers-reduced-motion with a background video?

When window.matchMedia('(prefers-reduced-motion: reduce)') matches, do not autoplay the video: pause it or never set its source, and show the poster as a still image. In CSS you can hide the video inside a @media (prefers-reduced-motion: reduce) block and show a background image instead. Listen for the media query's change event, because visitors can switch the setting while the page is open.

Reduced motion and performancePerformance answers

Does a decorative background video need captions?

No, not if it has no audio and carries no information, such as ambient footage behind a headline. Captions are for speech and meaningful sound. Hide a purely decorative video from screen readers with aria-hidden="true". If the footage shows something visitors need, like a product demo, describe it in nearby text, and if it has speech or meaningful sound, add captions.

AccessibilityVideo background templates

Why does muted autoplay fail for video in React?

React sets muted as a DOM property, and server-rendered HTML may not include the muted attribute, so some browsers block autoplay before hydration or treat the video as unmuted. A reliable fix is to keep muted, autoPlay, loop and playsInline in JSX, then in an effect set videoRef.current.muted = true and call play(), catching the promise in case the browser still refuses.

Next.js templatesVideo background templates

Should I embed a background video from a video platform or self-host the file?

Self-host the file for a background loop. A video platform embed loads a full player with its own scripts, adds requests, can show branding or controls, and gives you less control over autoplay, poster and looping. A self-hosted MP4 or WebM on a host or CDN with byte-range support is lighter and behaves predictably. Streaming formats such as HLS are rarely needed for a short loop.

HostingVideo background templates

How do I pause a background video when it scrolls off-screen?

Watch the video with an IntersectionObserver and call video.pause() when it leaves the viewport and play() when it returns, unless the visitor paused it with your button. Also pause on the visibilitychange event when the tab is hidden. Paused off-screen video saves decoding work and battery, and it keeps the main thread freer for the content the visitor is reading.

Fast animation on phonesReduced motion and performance

What is on the AnimatedWebs video backgrounds page?

The AnimatedWebs page at /video-backgrounds has two parts: cinematic backgrounds, which are original seamless film loops with new ones added every week, and live-code animated backgrounds built from a single prompt. Previews of the film loops are watermarked. Pro members can copy a link to the clean file or download it, ready for commercial use. The live-code backgrounds are shown with a free or Pro badge.

Cinematic backgroundsAnimated backgrounds

Can I use AnimatedWebs cinematic video loops on client websites?

Yes, with Pro. AnimatedWebs Pro members copy or download the clean, watermark-free seamless loop files, which are ready for commercial use, including client sites. Public previews are watermarked. Pro costs $19 a month or $149 a year, which works out to about $12.42 a month on the yearly plan. Lifetime is $199 for the first 100 members, then $299.

Cinematic backgroundsPricingPricing and licensing answers

How do I use an AnimatedWebs video loop in Lovable, v0 or Claude?

Copy the loop's link from the AnimatedWebs cinematic backgrounds page as a Pro member and paste it into your prompt, asking for a muted, looping, playsinline hero video with a poster and a dark overlay under the headline. Lovable, v0, Bolt and Claude can then place the video directly. You can also download the MP4 and add it to your project's public folder.

Cinematic backgroundsAnimatedWebs for LovableAnimatedWebs for v0

What is a scroll-film website template?

A scroll-film template is a full website whose hero is a short cinematic film that plays forward and backward with the scroll, frame by frame, while chapters of copy pin and change over it. AnimatedWebs scroll-film templates draw compressed WebP frames on a canvas capped at the screen's pixel ratio, and visitors who prefer reduced motion see a single still. Many have a live demo to play first.

Scroll film templatesScroll-scrubbed video hero

Does AnimatedWebs have website templates with video backgrounds?

Yes. AnimatedWebs has a video background collection of full websites that open on moving footage, some scrubbed as you scroll, and 114 of its 629 live demos are built around video. Each template comes with a live demo where one exists, a full build prompt for your AI tool and a design system. The prompts ask for a compressed clip, a poster, a smaller phone file and a reduced-motion still.

Video background templatesScroll film templates

Can I reuse the footage from an AnimatedWebs template demo?

No. Photos and videos in AnimatedWebs live demos are licensed for display only under Terms section 4.4, so replace them with your own footage before you publish. The build prompt explains how the footage is used, so you can keep the look with a clip of your own place or product. The separate cinematic loops on the video backgrounds page are licensed for commercial use to Pro members.

TermsWhat's includedCinematic backgrounds

How do I prompt an AI coding tool to build a video hero?

Ask for the exact element and limits: a video with autoplay, muted, loop and playsinline, a WebP poster of the first frame, object-fit cover, a dark overlay for contrast, a smaller file for phones, a visible pause button, pausing off-screen, and a still poster when prefers-reduced-motion is set. AnimatedWebs build prompts for video templates spell these details out, and you can fetch them through the MCP server.

Prompt AI for better animationMCP server

Are AnimatedWebs video backgrounds free?

The previews are free to watch, but the clean seamless loop files are for Pro members. The live-code animated backgrounds on the same page include free ones, usable on personal and commercial sites with a free AnimatedWebs account. Across the catalog, 365 of 1,777 items are free and 171 are backgrounds. There is no free trial of Pro.

Cinematic backgroundsFree templatesPricing