import React from "react"; import { AbsoluteFill, Img, OffthreadVideo, interpolate, spring, staticFile, useCurrentFrame, useVideoConfig, } from "remotion"; import { fontFamily } from "../fonts"; import { TikTokCaptions } from "../components/TikTokCaptions"; import { ProgressDots } from "../components/ProgressDots"; interface HeadlineSceneProps { title: string; bullets: string[]; category: string; categoryColor: string; bgFile: string; clipFile?: string; image?: string; captionsFile?: string; audioStartFrame?: number; index: number; totalStories: number; durationInFrames: number; } export const HeadlineScene: React.FC = ({ title, bullets, category, categoryColor, bgFile, clipFile, image, captionsFile, audioStartFrame, index, totalStories, durationInFrames, }) => { const frame = useCurrentFrame(); const { fps } = useVideoConfig(); // Category pill const categorySpring = spring({ frame, fps, config: { damping: 35, mass: 0.6, stiffness: 100 }, durationInFrames: 30, }); // Story number const numberSpring = spring({ frame: frame - 5, fps, config: { damping: 22, mass: 0.6, stiffness: 100 }, durationInFrames: 30, }); // Headline const headlineSpring = spring({ frame: frame - 12, fps, config: { damping: 20, mass: 0.7, stiffness: 90 }, durationInFrames: 40, }); // Accent line under headline const lineSpring = spring({ frame: frame - 25, fps, config: { damping: 25, mass: 0.5, stiffness: 80 }, durationInFrames: 40, }); // Bullet animations (staggered) const bulletSprings = bullets.map((_, i) => spring({ frame: frame - 35 - i * 10, fps, config: { damping: 20, mass: 0.6, stiffness: 90 }, durationInFrames: 35, }) ); // Image fade in + fast pan movement const imageOpacity = interpolate(frame, [0, 20], [0, 1], { extrapolateRight: "clamp", }); const imageScale = interpolate(frame, [0, durationInFrames], [1.12, 1.04], { extrapolateRight: "clamp", }); const imagePanX = interpolate( frame, [0, durationInFrames * 0.4, durationInFrames], [-140, 60, 10], { extrapolateRight: "clamp", } ); const imagePanY = interpolate( frame, [0, durationInFrames * 0.5, durationInFrames], [-30, 20, -10], { extrapolateRight: "clamp", } ); const imageRotate = interpolate(frame, [0, durationInFrames], [-1.2, 0.6], { extrapolateRight: "clamp", }); const headlineOpacity = headlineSpring; const lineWidth = interpolate(lineSpring, [0, 1], [0, 300]); const typedHeadlineLength = Math.min( title.length, Math.max(0, Math.floor((frame - 10) * 1.8)) ); const headlineRevealPercent = title.length === 0 ? 100 : (typedHeadlineLength / title.length) * 100; const showCursor = typedHeadlineLength < title.length && frame % 12 < 6; const storyProgress = durationInFrames <= 0 ? 0 : frame / durationInFrames; return ( {/* ===== TOP HALF: Story clip or image ===== */}
{clipFile ? ( ) : image ? ( ) : null} {/* Gradient fade at bottom of top half */}
{/* ===== BOTTOM HALF: Background video + text ===== */}
{/* Background video */} {/* Dark overlay */}
{/* Gradient fade at top blending from top half */}
{/* Text content */}
{/* Bullets (only when no captions) */} {!captionsFile && bullets.map((bullet, i) => { const bSpring = bulletSprings[i]; const bY = interpolate(bSpring, [0, 1], [20, 0]); return (
{bullet}
); })}
{/* TikTok-style captions */} {captionsFile && ( )} {/* Top headline block */}
{/* Category pill */}
#{category}
{/* Headline */}
{/* Reserve final layout immediately to avoid headline reflow */}
{title}
{title}
{showCursor ? (
) : null}
{/* Accent line */}
{/* Story number — top left */}
{String(index + 1).padStart(2, "0")}
{/* Story progress dots */}
); };