Reel Wall
Curved video wall for Remotion. A ring of vertical clips turns past in the dark: it eases in from rest on twos, then keeps turning at an even speed.
Source
components/kuchi/reel-wall.tsx
1"use client";23import type { CSSProperties } from "react";4import {5 Easing,6 Freeze,7 getRemotionEnvironment,8 interpolate,9 OffthreadVideo,10 staticFile,11 useCurrentFrame,12 useVideoConfig,13} from "remotion";1415/**16 * A "reel wall": a curved wall of vertical clips turns past in the dark. It17 * eases in from rest, then keeps turning at an even speed for as long as the18 * composition runs.19 *20 * Replicated from a 24fps reference, fitted on its own frames. The wall is a21 * CSS 3D ring: every card is a plane `RING_R` in front of the ring's axis,22 * viewed through a `perspective` of `PERSPECTIVE` (median edge error 0.64px23 * against the recording). Lengths are reference pixels (`REF_W` wide) and scale24 * with the frame; the timeline is in 24fps frames.25 *26 * The wall moves "on twos": it holds every picture for two frames, like the27 * reference, which is part of its look. The opening fade runs on every frame.28 *29 * Like `announce-title` it paints a cinematic world rather than a surface — a30 * dark stage under clips — so it takes no `theme`/`mode`; its colours are props.31 */3233export interface ReelWallProps {34 /**35 * Clips for the wall, left to right; they repeat around the ring. Video URLs36 * play muted. Absolute URLs or paths under `public/`.37 */38 videos?: string[];39 /** The page behind the wall. */40 background?: string;41 /** A card before its clip has a frame to show. */42 cardColor?: string;43 speed?: number;44 className?: string;45}4647/** Creator-style clips, 12s each, compressed. Absolute, because a root-relative48 * default becomes `staticFile()` in a render and 404s in the project this file49 * was just copied into. Ceiling: a clip shorter than the composition stops on50 * its last frame — pass clips at least as long as the scene runs. */51const DEFAULT_VIDEOS = [1, 2, 3, 4, 5, 6].map(52 (n) => `https://kuchi-media.kalarislabs.com/components/clips/clip-${n}.mp4`,53);5455// ─── Geometry, in reference pixels ────────────────────────────────────────────56export const REF_W = 716;57const REF_H = 398;58/** The card, its ring and the lens. */59export const CARD = { w: 201.92, h: 349.09 } as const;60export const RING_R = 1837.36;61export const PERSPECTIVE = 446.54;62/** Angle between neighbouring cards, radians. */63export const PITCH = 0.1328;64/** Perspective origin, from the top-left of the frame. */65export const ORIGIN = { x: 356.76, y: 197.99 } as const;6667// ─── Timeline (24fps frames) ──────────────────────────────────────────────────68/** Where the fitted ease hands over to an even turn, in 12fps steps. */69const CRUISE_AT = 52;70/** The ease-in, radians over 12fps steps: a cubic-bezier fitted to 53 measured71 * steps (0.31px RMS). Valid up to `CRUISE_AT`; past it the bezier overshoots. */72const easeIn = (step: number) =>73 interpolate(step, [0, 67.8], [-0.0497, -0.2656], {74 extrapolateLeft: "clamp",75 extrapolateRight: "clamp",76 easing: Easing.bezier(0.344, 0.0049, 0.7833, 1.3384),77 });78/** Turn per step once cruising: the ease's own speed where it hands over. */79const CRUISE = easeIn(CRUISE_AT) - easeIn(CRUISE_AT - 1);8081/** The wall's turn at a 12fps step: the fitted ease-in, then an even turn. */82export const wallTurn = (step: number) =>83 step <= CRUISE_AT84 ? easeIn(step)85 : easeIn(CRUISE_AT) + (step - CRUISE_AT) * CRUISE;8687/** The opening fade-in: a black veil that clears in 9 frames. */88export const veil = (f: number) =>89 f >= 9 ? 0 : 0.142 * (1 - Math.max(f, 0) / 9) ** 3.7;9091/** Hold every picture for two frames: 0, 1, 1, 3, 3, 5, … */92const onTwos = (f: number) => (f < 1 ? 0 : Math.floor((f - 1) / 2) * 2 + 1);9394function resolveSrc(src: string): string {95 const isLocal = src.startsWith("/") && !src.startsWith("//");96 if (!isLocal || getRemotionEnvironment().isPlayer) return src;97 // A value that already came out of staticFile() carries the static base.98 const base = staticFile("_").slice(0, -2);99 if (base && src.startsWith(`${base}/`)) return src;100 try {101 return staticFile(src.replace(/^\/+/, ""));102 } catch {103 return src;104 }105}106107const cover: CSSProperties = {108 width: "100%",109 height: "100%",110 // Preflight's `img { max-width: 100% }` collapses a box sized by its parent.111 maxWidth: "none",112 objectFit: "cover",113 display: "block",114};115116export function ReelWall({117 videos = DEFAULT_VIDEOS,118 background = "#0e0e0e",119 cardColor = "#1a1a1a",120 speed = 1,121 className,122}: ReelWallProps) {123 const { width, height, fps } = useVideoConfig();124 const frame = useCurrentFrame() * ((speed * 24) / fps);125 const u = width / REF_W;126 // The reference frame is a hair wider than 16:9; centre it vertically.127 const dy = (height - REF_H * u) / 2;128129 const held = onTwos(Math.floor(frame));130 const theta = wallTurn((held + 1) / 2);131 // Only the cards within reach of the lens; the rest are behind the frame.132 const first = Math.floor((-theta - 0.6) / PITCH);133 const n = videos.length;134135 return (136 <div137 className={className}138 style={{139 position: "absolute",140 inset: 0,141 overflow: "hidden",142 backgroundColor: background,143 }}144 >145 <div146 style={{147 position: "absolute",148 left: 0,149 top: dy,150 width,151 height: REF_H * u,152 perspective: PERSPECTIVE * u,153 perspectiveOrigin: `${ORIGIN.x * u}px ${ORIGIN.y * u}px`,154 }}155 >156 {/* The page: lit from the middle, falling to black at the sides. */}157 <div158 style={{159 position: "absolute",160 inset: 0,161 background:162 "radial-gradient(ellipse 60% 75% at 50% 50%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.45) 70%, rgba(0,0,0,0.92) 100%)",163 }}164 />165 {Array.from({ length: 10 }, (_, i) => first + i).map((k) => {166 const src = n ? videos[((k % n) + n) % n] : undefined;167 return (168 <div169 key={k}170 style={{171 position: "absolute",172 left: (ORIGIN.x - CARD.w / 2) * u,173 top: (ORIGIN.y - CARD.h / 2) * u,174 width: CARD.w * u,175 height: CARD.h * u,176 overflow: "hidden",177 backgroundColor: cardColor,178 transform: `translateZ(${-RING_R * u}px) rotateY(${theta + k * PITCH}rad) translateZ(${RING_R * u}px)`,179 }}180 >181 {src && (182 // The clips hold on twos with the wall.183 <Freeze frame={held}>184 <OffthreadVideo src={resolveSrc(src)} muted style={cover} />185 </Freeze>186 )}187 </div>188 );189 })}190 </div>191192 {veil(frame) > 0 && (193 <div194 style={{195 position: "absolute",196 inset: 0,197 background: "#000",198 opacity: veil(frame),199 }}200 />201 )}202 </div>203 );204}









