agentleFS
reescalderreescalder/claude-skills/scroll-video-hero/SKILL.md

scroll-video-hero

Skill0 starsChanged 4 months agoMITView on GitHub

Generate AI video from a hero image and embed it as a scroll-controlled sticky background in a Next.js page. Use when building website hero sections with cinematic video backgrounds, scroll-scrubbed video playback, sticky pinned headers with video, or AI-generated motion from static images. Covers KIE API image-to-video generation (Veo 3), ffmpeg compression, and the React/Framer Motion scroll-pinned video pattern.

  • Reads credentials
  • Sends data out

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use KIE API Veo 3 Fast for image-to-video.

    line 18
  2. Distinctive:

    Keep motion subtle: particles, light pulses, gentle camera push-in, atmospheric drift

    line 34
  3. Distinctive:

    Avoid drastic scene changes (it must look like the same hero image, animated)

    line 35
  4. Very specific:

    readyState >= 2: check prevents errors before video data loads.

    line 143
  5. Distinctive:

    Gradient overlays: ensure text readability. Customize colors to match the page background for seamless blending at the bottom edge.

    line 146
  6. Very specific:

    Consider reducing runwayVh on mobile (150-200vh) to avoid excessive scrolling

    line 161

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Scroll Video Hero

Turn any static hero image into a scroll-controlled cinematic video background. The hero stays pinned while the user scrolls; the video scrubs forward with scroll progress, then releases into normal page flow.

Pipeline

  1. Generate video from hero image via KIE API (Veo 3 image-to-video)
  2. Compress with ffmpeg (target <3MB)
  3. Embed as sticky scroll-controlled background in Next.js

Step 1: Generate Video

Use KIE API Veo 3 Fast for image-to-video. See references/kie-video-api.md for full endpoint details.

curl -s -X POST "https://api.kie.ai/api/v1/veo/generate" \
  -H "Authorization: Bearer $KIE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "<describe subtle motion: particles, light shifts, gentle camera push>",
    "model": "veo3_fast",
    "aspect_ratio": "9:16",
    "generationType": "FIRST_AND_LAST_FRAMES_2_VIDEO",
    "image": "<publicly-accessible-image-url>"
  }'

Prompt guidelines

  • Keep motion subtle: particles, light pulses, gentle camera push-in, atmospheric drift
  • Avoid drastic scene changes (it must look like the same hero image, animated)
  • Include "slow motion feel" and "seamless loop friendly" for smoother scrubbing
  • Match the brand's visual language in the prompt

Aspect ratio selection

  • 9:16 (portrait): Best for full-viewport sticky heroes on desktop. Fills tall viewports.
  • 16:9 (landscape): Use only if the hero section is short/cinematic-bar style.
  • 1:1: Good compromise for mixed desktop/mobile.

Polling for completion

curl -s "https://api.kie.ai/api/v1/veo/record-info?taskId=$TASK_ID" \
  -H "Authorization: Bearer $KIE_API_KEY"
  • successFlag: 0 = still generating (poll every 30s, typically 2-5 min)
  • successFlag: 1 = done, URL in response.resultUrls[0]
  • successFlag: 2 or 3 = failed, retry

Step 2: Compress Video

Strip audio, compress for web, enable fast-start streaming:

ffmpeg -i input.mp4 -vcodec libx264 -crf 28 -preset fast -an -movflags +faststart output.mp4

Target: <3MB for hero backgrounds. Adjust -crf (lower = better quality, bigger file).

Step 3: React Component

Dependencies

  • framer-motion (useScroll, useTransform, useMotionValueEvent)
  • next/image (fallback poster)

Pattern: Sticky Scroll-Scrubbed Video

'use client';

import { useRef } from 'react';
import { useScroll, useMotionValueEvent } from 'framer-motion';
import Image from 'next/image';

interface ScrollVideoHeroProps {
  videoSrc: string;        // path to compressed mp4
  posterSrc: string;       // fallback image (same as source image)
  posterAlt: string;
  runwayVh?: number;       // scroll runway height in vh (default 250)
  children: React.ReactNode; // hero text content
}

export function ScrollVideoHero({
  videoSrc,
  posterSrc,
  posterAlt,
  runwayVh = 250,
  children,
}: ScrollVideoHeroProps) {
  const wrapperRef = useRef<HTMLDivElement>(null);
  const videoRef = useRef<HTMLVideoElement>(null);

  const { scrollYProgress } = useScroll({
    target: wrapperRef,
    offset: ['start start', 'end end'],
  });

  useMotionValueEvent(scrollYProgress, 'change', (v) => {
    const video = videoRef.current;
    if (video && video.duration && video.readyState >= 2) {
      video.currentTime = v * video.duration;
    }
  });

  return (
    <div ref={wrapperRef} className="relative" style={{ height: `${runwayVh}vh` }}>
      <div className="sticky top-0 h-screen w-full overflow-hidden">
        {/* Fallback image (base layer) */}
        <Image src={posterSrc} alt={posterAlt} fill className="object-cover" priority />

        {/* Video (on top of image) */}
        <video
          ref={videoRef}
          src={videoSrc}
          muted
          playsInline
          preload="auto"
          className="absolute inset-0 w-full h-full object-cover z-[1]"
        />

        {/* Overlay gradients (on top of video) */}
        <div className="absolute inset-0 z-[2] bg-gradient-to-r from-black/80 via-black/50 to-transparent" />
        <div className="absolute inset-0 z-[2] bg-gradient-to-t from-white via-transparent to-transparent" />

        {/* Content (highest layer) */}
        <div className="absolute inset-0 z-[3] flex items-center">
          {children}
        </div>
      </div>
    </div>
  );
}

Key architecture decisions

  • Outer div height controls scroll runway. 250vh = ~2.5 screens of scrolling before release. Adjust based on video duration (longer video = more runway).
  • sticky top-0 h-screen pins the visual hero to the viewport.
  • Z-index layers: Image (base) → Video (z-1) → Gradients (z-2) → Text (z-3).
  • readyState >= 2 check prevents errors before video data loads.
  • preload="auto" ensures the video buffers ahead of scroll.
  • Image as poster: The <Image> shows immediately while the video loads. Once the video has data, it paints over the image. No flash of empty content.
  • Gradient overlays ensure text readability. Customize colors to match the page background for seamless blending at the bottom edge.

Customization

ParameterDefaultNotes
runwayVh250Higher = more scroll time for video. Match to video duration.
Gradient from-colorblack/80Match your dark overlay needs
Gradient to-colorwhiteMatch the background color of the next section
Video CRF28Lower = better quality, bigger file

Mobile considerations

  • playsInline is required for iOS (prevents fullscreen hijack)
  • muted is required for autoplay policies
  • 9:16 aspect fills mobile viewports naturally
  • Consider reducing runwayVh on mobile (150-200vh) to avoid excessive scrolling

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.