Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

feat: lens zoom

kapishdima77fbd77c935a
diff --git a/components/docs/examples/lens-zoom-example.tsx b/components/docs/examples/lens-zoom-example.tsx
new file mode 100644
index 00000000..3a5f1263
--- /dev/null
+++ b/components/docs/examples/lens-zoom-example.tsx
@@ -0,0 +1,115 @@
+"use client";
+
+import { linearTiming, TransitionSeries } from "@remotion/transitions";
+import { AbsoluteFill, Easing, interpolate, useCurrentFrame } from "remotion";
+import {
+ LENS_ZOOM_DURATION_IN_FRAMES,
+ lensZoom,
+} from "@/registry/remocn/lens-zoom";
+
+const FONT_FAMILY =
+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif";
+
+function Scene({
+ label,
+ background,
+ squeezeAt,
+}: {
+ label: string;
+ background: string;
+ squeezeAt?: number;
+}) {
+ const frame = useCurrentFrame();
+ const scale =
+ squeezeAt === undefined
+ ? 1
+ : interpolate(frame, [squeezeAt, squeezeAt + 7], [1, 0.87], {
+ easing: Easing.bezier(0.32, 0, 0.24, 1),
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ });
+
+ return (
+ <AbsoluteFill
+ style={{
+ background,
+ alignItems: "center",
+ justifyContent: "center",
+ }}
+ >
+ <span
+ style={{
+ fontFamily: FONT_FAMILY,
+ fontSize: 96,
+ fontWeight: 600,
+ letterSpacing: "-0.03em",
+ color: "#f2f2f2",
+ transform: `scale(${scale})`,
+ }}
+ >
+ {label}
+ </span>
+ </AbsoluteFill>
+ );
+}
+
+interface LensZoomExampleProps {
+ lensSteps?: number;
+ blurSamples?: number;
+ shakeAmount?: number;
+ shakeTranslatePx?: number;
+}
+
+export function LensZoomExampleScene({
+ lensSteps,
+ blurSamples,
+ shakeAmount,
+ shakeTranslatePx,
+}: LensZoomExampleProps) {
+ return (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={70}>
+ <Scene label="Scene A" background="#141318" squeezeAt={35} />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({
+ durationInFrames: LENS_ZOOM_DURATION_IN_FRAMES,
+ })}
+ presentation={lensZoom({
+ lensSteps,
+ blurSamples,
+ shakeAmount,
+ shakeTranslatePx,
+ })}
+ />
+ <TransitionSeries.Sequence durationInFrames={70}>
+ <Scene label="Lens Zoom" background="#1a1922" />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+ );
+}
+
+export const lensZoomExampleCode = (
+ values: Record<string, unknown>,
+): string => {
+ const lensSteps = (values.lensSteps as number) ?? 9;
+ const blurSamples = (values.blurSamples as number) ?? 7;
+ const shakeAmount = (values.shakeAmount as number) ?? 50;
+ return `import { TransitionSeries, linearTiming } from "@remotion/transitions";
+import { lensZoom, LENS_ZOOM_DURATION_IN_FRAMES } from "@/components/remocn/lens-zoom";
+
+export const MyVideo = () => (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={70}>
+ <SceneA />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: LENS_ZOOM_DURATION_IN_FRAMES })}
+ presentation={lensZoom({ lensSteps: ${lensSteps}, blurSamples: ${blurSamples}, shakeAmount: ${shakeAmount} })}
+ />
+ <TransitionSeries.Sequence durationInFrames={70}>
+ <SceneB />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+);`;
+};
diff --git a/content/docs/transitions/lens-zoom.mdx b/content/docs/transitions/lens-zoom.mdx
new file mode 100644
index 00000000..15953ee4
--- /dev/null
+++ b/content/docs/transitions/lens-zoom.mdx
@@ -0,0 +1,208 @@
+---
+title: Lens Zoom
+description: A hard cut disguised as a lens punch-in — barrel distortion, zoom blur, chromatic split and camera shake around the splice
+component: lens-zoom
+vibe: premium
+length: 28
+useWhen:
+ - "A high-energy beat drop or reveal needs a cinematic camera move — the cut hides inside the peak of the distortion."
+ - "You want the full optics package (lens warp, fading zoom blur, RGB fringing, shake) in one drop-in presentation."
+ - "The two scenes are visually rich footage-like content that can sell a physical camera whip."
+avoidWhen:
+ - "You just need a clean depth punch-in without the optics — use `zoom-blur`, the cheap variant of this move."
+ - "You want static lens optics on a single scene rather than a transition — use `camera-lens`."
+ - "The scenes are heavy React subtrees — every frame paints `blurSamples × (lensSteps + 1)` copies of the scene (×3 with the chromatic split); keep scenes light or turn the counts down."
+ - "The pacing is calm or the brand is minimal — this is an aggressive, showy move."
+---
+
+<ComponentPreview name="lens-zoom" />
+
+## Installation
+
+<InstallBlock name="lens-zoom" />
+
+## Usage
+
+`lensZoom()` is a Remotion transition presentation. The transition is a hard
+cut, not a dissolve: the outgoing half owns progress 0–0.5 and the incoming
+half owns 0.5–1, so the splice lands exactly halfway through the transition.
+Use `LENS_ZOOM_DURATION_IN_FRAMES` (28) with `linearTiming` for the tutorial's
+pacing — two equal 14-frame ramps either side of the cut.
+
+```tsx
+import { TransitionSeries, linearTiming } from "@remotion/transitions";
+import {
+ lensZoom,
+ LENS_ZOOM_DURATION_IN_FRAMES,
+} from "@/components/remocn/lens-zoom";
+
+export const MyVideo = () => (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={70}>
+ <SceneA />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: LENS_ZOOM_DURATION_IN_FRAMES })}
+ presentation={lensZoom()}
+ />
+ <TransitionSeries.Sequence durationInFrames={70}>
+ <SceneB />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+);
+```
+
+Performance scales with `blurSamples × (lensSteps + 1)` painted copies of each
+scene per frame, tripled when the three channel scales differ. Setting
+`redScale`, `greenScale` and `blueScale` equal skips the chromatic split
+entirely — the single biggest thing to turn off while dialling the transition
+in.
+
+## Props
+
+`lensZoom(props)` accepts:
+
+<PropsTable
+ rows={[
+ {
+ name: "inScaleFrom / inScaleTo",
+ type: "number",
+ default: "100 / 150",
+ description: "Scale ramp of the outgoing half, in percent",
+ },
+ {
+ name: "inFovFrom / inFovTo",
+ type: "number",
+ default: "0 / 160",
+ description: "Lens distortion FOV ramp of the outgoing half, in degrees",
+ },
+ {
+ name: "inBlurFrom / inBlurTo",
+ type: "number",
+ default: "0 / 60",
+ description: "Zoom blur amount ramp of the outgoing half",
+ },
+ {
+ name: "inRotationFrom / inRotationTo",
+ type: "number",
+ default: "0 / -15",
+ description: "Rotation ramp of the outgoing half, in degrees",
+ },
+ {
+ name: "outScaleFrom / outScaleTo",
+ type: "number",
+ default: "135 / 100",
+ description: "Scale ramp of the incoming half — starts below the outgoing peak so the energy steps down at the cut",
+ },
+ {
+ name: "outFovFrom / outFovTo",
+ type: "number",
+ default: "135 / 0",
+ description: "Lens distortion FOV ramp of the incoming half",
+ },
+ {
+ name: "outBlurFrom / outBlurTo",
+ type: "number",
+ default: "45 / 0",
+ description: "Zoom blur amount ramp of the incoming half",
+ },
+ {
+ name: "outRotationFrom / outRotationTo",
+ type: "number",
+ default: "345 / 360",
+ description: "Rotation ramp of the incoming half — unwinds the outgoing twist",
+ },
+ {
+ name: "anticipateScale",
+ type: "number",
+ default: "100",
+ description: "Scale the outgoing scene squeezes down to before the punch — the wind-up before the jump. The lens, blur and rotation ramps hold until the squeeze ends. Disabled by default (scaling the full frame below 100 reveals the backdrop behind it) — prefer squeezing the subject inside the scene; set below `inScaleFrom` to enable the frame squeeze",
+ },
+ {
+ name: "anticipatePortion",
+ type: "number",
+ default: "0.35",
+ description: "Portion of the outgoing half spent on the squeeze. 0 disables it",
+ },
+ {
+ name: "lensSteps",
+ type: "number",
+ default: "9",
+ description: "Concentric rings approximating the barrel warp. Nearly free — the rings are disjoint",
+ },
+ {
+ name: "blurSamples",
+ type: "number",
+ default: "7",
+ description: "Scaled copies approximating the zoom blur. The expensive knob — higher is smoother",
+ },
+ {
+ name: "blurScaleGain",
+ type: "number",
+ default: "1",
+ description: "Scale span one unit of blur amount buys",
+ },
+ {
+ name: "blurFade",
+ type: "number",
+ default: "1.5",
+ description: "Higher keeps the sharp copy dominant over the smear",
+ },
+ {
+ name: "shakeAmount",
+ type: "number",
+ default: "50",
+ description: "Peak of the shake envelope around the cut. 0 disables the shake",
+ },
+ {
+ name: "shakeFrequency",
+ type: "number",
+ default: "1.4",
+ description: "Shake noise frequency",
+ },
+ {
+ name: "shakeCyclesPerUnit",
+ type: "number",
+ default: "8",
+ description: "Noise cycles per second one unit of frequency is worth",
+ },
+ {
+ name: "shakeTranslatePx",
+ type: "number",
+ default: "73",
+ description: "Peak shake translation in pixels",
+ },
+ {
+ name: "shakeRotateDeg",
+ type: "number",
+ default: "1.1",
+ description: "Peak shake rotation in degrees",
+ },
+ {
+ name: "redScale / greenScale / blueScale",
+ type: "number",
+ default: "1.01 / 1.0 / 0.99",
+ description: "Per-channel scales for the chromatic aberration. Set all three equal to skip the split",
+ },
+ {
+ name: "letterboxAspect",
+ type: "number",
+ default: "0",
+ description: "Cinematic bars aspect ratio (e.g. 2.39). 0 disables them",
+ },
+ {
+ name: "width / height",
+ type: "number",
+ default: "composition size",
+ description: "Stage size in pixels",
+ },
+ {
+ name: "distortionCenterX / distortionCenterY",
+ type: "number",
+ default: "stage center",
+ description: "Center of the lens distortion, blur and shake",
+ },
+ ]}
+/>
+
+Inspired by [After Effects: Lens Zoom Transition Tutorial](https://www.youtube.com/watch?v=ePz-YEPXl6Y) by Creative Dojo.
diff --git a/content/docs/transitions/meta.json b/content/docs/transitions/meta.json
index 4cda207e..70d5b10d 100644
--- a/content/docs/transitions/meta.json
+++ b/content/docs/transitions/meta.json
@@ -15,6 +15,7 @@
"push-through",
"focus-pull",
"zoom-blur",
+ "lens-zoom",
"page-turn",
"ascii-dissolve",
"caret-wipe",
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index 23355209..5cea5a01 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -1666,6 +1666,16 @@ const registry: Record<string, RegistryEntry> = {
(m) => m.zoomBlurConfig,
),
},
+ "lens-zoom": {
+ load: () =>
+ import("@/components/docs/examples/lens-zoom-example").then((m) => ({
+ default: m.LensZoomExampleScene,
+ })),
+ loadConfig: () =>
+ import("@/registry/remocn/lens-zoom/config").then(
+ (m) => m.lensZoomConfig,
+ ),
+ },
"glitch-cut": {
load: () =>
import("@/components/docs/examples/glitch-cut-example").then((m) => ({
diff --git a/registry/remocn/lens-zoom/config.ts b/registry/remocn/lens-zoom/config.ts
new file mode 100644
index 00000000..f7cb62bf
--- /dev/null
+++ b/registry/remocn/lens-zoom/config.ts
@@ -0,0 +1,47 @@
+import { lensZoomExampleCode } from "@/components/docs/examples/lens-zoom-example";
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const lensZoomConfig: ComponentConfig = {
+ componentName: "lensZoom",
+ importPath: "@/components/remocn/lens-zoom",
+ controls: {
+ lensSteps: {
+ type: "number",
+ default: 9,
+ min: 4,
+ max: 32,
+ step: 1,
+ label: "Lens steps",
+ },
+ blurSamples: {
+ type: "number",
+ default: 7,
+ min: 2,
+ max: 32,
+ step: 1,
+ label: "Blur samples",
+ },
+ shakeAmount: {
+ type: "number",
+ default: 50,
+ min: 0,
+ max: 300,
+ step: 5,
+ label: "Shake amount",
+ },
+ shakeTranslatePx: {
+ type: "number",
+ default: 73,
+ min: 0,
+ max: 80,
+ step: 1,
+ label: "Shake travel (px)",
+ },
+ },
+ durationInFrames: 112,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+ previewBackdrop: { type: "color", value: "#141318" },
+ snippet: lensZoomExampleCode,
+};
diff --git a/registry/remocn/lens-zoom/index.tsx b/registry/remocn/lens-zoom/index.tsx
new file mode 100644
index 00000000..3d1c2d90
--- /dev/null
+++ b/registry/remocn/lens-zoom/index.tsx
@@ -0,0 +1,524 @@
+"use client";
+
+import type {
+ TransitionPresentation,
+ TransitionPresentationComponentProps,
+} from "@remotion/transitions";
+import type { ReactNode } from "react";
+import { useId } from "react";
+import { Easing, interpolate, useCurrentFrame, useVideoConfig } from "remotion";
+
+export const LENS_ZOOM_DURATION_IN_FRAMES = 28;
+
+export const SHAKE_STOPS = [-9 / 11, -3 / 11, 4 / 11, 8 / 11] as const;
+
+export const LENS_ZOOM_EASE_IN = Easing.bezier(0.54, 0, 0.82, 0.8);
+export const LENS_ZOOM_EASE_OUT = Easing.bezier(0.18, 0.2, 0.46, 1);
+
+export type LensZoomProps = {
+ inScaleFrom?: number;
+ inScaleTo?: number;
+ inFovFrom?: number;
+ inFovTo?: number;
+ inBlurFrom?: number;
+ inBlurTo?: number;
+ inRotationFrom?: number;
+ inRotationTo?: number;
+ outScaleFrom?: number;
+ outScaleTo?: number;
+ outFovFrom?: number;
+ outFovTo?: number;
+ outBlurFrom?: number;
+ outBlurTo?: number;
+ outRotationFrom?: number;
+ outRotationTo?: number;
+ anticipateScale?: number;
+ anticipatePortion?: number;
+ lensSteps?: number;
+ blurSamples?: number;
+ blurScaleGain?: number;
+ blurFade?: number;
+ shakeAmount?: number;
+ shakeFrequency?: number;
+ shakeCyclesPerUnit?: number;
+ shakeTranslatePx?: number;
+ shakeRotateDeg?: number;
+ redScale?: number;
+ greenScale?: number;
+ blueScale?: number;
+ letterboxAspect?: number;
+ width?: number;
+ height?: number;
+ distortionCenterX?: number;
+ distortionCenterY?: number;
+};
+
+function hashed(seed: number, i: number): number {
+ let t = Math.imul(i ^ seed, 0x27d4eb2d);
+ t ^= t >>> 15;
+ t = Math.imul(t, 0x85ebca6b);
+ t ^= t >>> 13;
+ return ((t >>> 0) / 4294967296) * 2 - 1;
+}
+
+function valueNoise(seed: number, t: number): number {
+ const i = Math.floor(t);
+ const f = t - i;
+ const u = f * f * (3 - 2 * f);
+ return hashed(seed, i) * (1 - u) + hashed(seed, i + 1) * u;
+}
+
+function fovHalf(fov: number): number {
+ return (Math.min(fov, 178) / 2) * (Math.PI / 180);
+}
+
+function lensMagnification(r: number, fov: number): number {
+ if (fov < 0.01) return 1;
+ const theta = fovHalf(fov);
+ const peak = Math.tan(theta) / theta;
+ if (r <= 0) return peak;
+ const a = r * theta;
+ if (a >= Math.PI / 2 - 1e-3) return 1;
+ const rSource = Math.tan(a) / Math.tan(theta);
+ if (rSource <= 1e-6) return peak;
+ return Math.max(1, r / rSource);
+}
+
+function radiusForMagnification(target: number, fov: number): number {
+ let lo = 0;
+ let hi = 1;
+ for (let i = 0; i < 24; i++) {
+ const mid = (lo + hi) / 2;
+ if (lensMagnification(mid, fov) > target) lo = mid;
+ else hi = mid;
+ }
+ return (lo + hi) / 2;
+}
+
+function ringClip(
+ rInner: number,
+ rOuter: number | null,
+ w: number,
+ h: number,
+ cx: number,
+ cy: number,
+): string {
+ const circle = (r: number, clockwise: boolean) => {
+ const s = clockwise ? 1 : 0;
+ return `M ${cx + r} ${cy} A ${r} ${r} 0 1 ${s} ${cx - r} ${cy} A ${r} ${r} 0 1 ${s} ${cx + r} ${cy} Z`;
+ };
+ const outer =
+ rOuter === null
+ ? `M 0 0 L ${w} 0 L ${w} ${h} L 0 ${h} Z`
+ : circle(rOuter, true);
+ return rInner > 0 ? `${outer} ${circle(rInner, false)}` : outer;
+}
+
+type HalfProps = {
+ scene: ReactNode;
+ scale: number;
+ fov: number;
+ blur: number;
+ rotation: number;
+ centerX: number;
+ centerY: number;
+ width: number;
+ height: number;
+ lensSteps: number;
+ blurSamples: number;
+ blurScaleGain: number;
+ blurFade: number;
+};
+
+function TransitionHalf({
+ scene,
+ scale,
+ fov,
+ blur,
+ rotation,
+ centerX,
+ centerY,
+ width,
+ height,
+ lensSteps,
+ blurSamples,
+ blurScaleGain,
+ blurFade,
+}: HalfProps) {
+ const origin = `${centerX}px ${centerY}px`;
+ const base = scale / 100;
+
+ const peak = lensMagnification(0, fov);
+ const steps = peak <= 1.001 ? 0 : lensSteps;
+ const rings = Array.from({ length: steps }, (_, i) => {
+ const s = 1 + ((peak - 1) * (i + 0.5)) / steps;
+ return { s, r: radiusForMagnification(s, fov) };
+ });
+
+ const samples =
+ blur <= 0.05 ? 1 : Math.max(2, Math.round((blurSamples * blur) / 60));
+ const weights = Array.from({ length: samples }, (_, j) =>
+ Math.pow(1 - j / samples, blurFade),
+ );
+
+ const groups: {
+ key: number;
+ alpha: number;
+ copies: { key: string; clip: string; k: number }[];
+ }[] = [];
+ let running = 0;
+ for (let j = samples - 1; j >= 0; j--) {
+ running += weights[j];
+ const g =
+ samples === 1
+ ? 1
+ : 1 + (blur / 100) * blurScaleGain * (j / (samples - 1));
+ const halfWidth = (width / 2) * g;
+ const copies: { key: string; clip: string; k: number }[] = [];
+
+ copies.push({
+ key: "base",
+ clip: ringClip(
+ rings.length ? rings[0].r * halfWidth : 0,
+ null,
+ width,
+ height,
+ centerX,
+ centerY,
+ ),
+ k: g * base,
+ });
+
+ for (let i = 0; i < rings.length; i++) {
+ const inner = i + 1 < rings.length ? rings[i + 1].r * halfWidth : 0;
+ copies.push({
+ key: `${i}`,
+ clip: ringClip(
+ inner,
+ rings[i].r * halfWidth,
+ width,
+ height,
+ centerX,
+ centerY,
+ ),
+ k: g * rings[i].s * base,
+ });
+ }
+
+ groups.push({ key: j, alpha: weights[j] / running, copies });
+ }
+
+ return (
+ <div style={{ position: "absolute", inset: 0 }}>
+ {groups.map(({ key, alpha, copies }) => (
+ <div key={key} style={{ position: "absolute", inset: 0, opacity: alpha }}>
+ {copies.map(({ key: ck, clip, k }) => (
+ <div
+ key={ck}
+ style={{
+ position: "absolute",
+ inset: 0,
+ clipPath: `path("${clip}")`,
+ transform: `rotate(${rotation}deg) scale(${k})`,
+ transformOrigin: origin,
+ }}
+ >
+ {scene}
+ </div>
+ ))}
+ </div>
+ ))}
+ </div>
+ );
+}
+
+interface LensZoomStageProps extends HalfProps {
+ shakeEnvelope: number;
+ shakeFrequency: number;
+ shakeCyclesPerUnit: number;
+ shakeTranslatePx: number;
+ shakeRotateDeg: number;
+ redScale: number;
+ greenScale: number;
+ blueScale: number;
+ letterboxAspect: number;
+}
+
+function LensZoomStage({
+ shakeEnvelope,
+ shakeFrequency,
+ shakeCyclesPerUnit,
+ shakeTranslatePx,
+ shakeRotateDeg,
+ redScale,
+ greenScale,
+ blueScale,
+ letterboxAspect,
+ ...half
+}: LensZoomStageProps) {
+ const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+ const filterId = useId();
+ const { width, height, centerX, centerY } = half;
+
+ const core = <TransitionHalf {...half} />;
+
+ const split = redScale !== greenScale || blueScale !== greenScale;
+ const channels: { id: string; scale: number; matrix: string }[] = [
+ {
+ id: "r",
+ scale: redScale,
+ matrix: "1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0",
+ },
+ {
+ id: "g",
+ scale: greenScale,
+ matrix: "0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0",
+ },
+ {
+ id: "b",
+ scale: blueScale,
+ matrix: "0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0",
+ },
+ ];
+
+ const composited = split ? (
+ <div style={{ position: "absolute", inset: 0, backgroundColor: "#000000" }}>
+ {channels.map((c) => (
+ <div
+ key={c.id}
+ style={{
+ position: "absolute",
+ inset: 0,
+ mixBlendMode: "screen",
+ filter: `url(#${filterId}-${c.id})`,
+ transform: `scale(${c.scale})`,
+ transformOrigin: `${centerX}px ${centerY}px`,
+ }}
+ >
+ {core}
+ </div>
+ ))}
+ </div>
+ ) : (
+ core
+ );
+
+ const t = (frame / fps) * shakeFrequency * shakeCyclesPerUnit;
+ const octave = (seed: number) =>
+ valueNoise(seed, t) + 0.45 * valueNoise(seed + 977, t * 2.6);
+ const shakeX = octave(11) * shakeTranslatePx * shakeEnvelope;
+ const shakeY = octave(23) * shakeTranslatePx * shakeEnvelope;
+ const shakeR = octave(41) * shakeRotateDeg * shakeEnvelope;
+
+ const barHeight =
+ letterboxAspect > 0
+ ? Math.max(0, (height - width / letterboxAspect) / 2)
+ : 0;
+
+ return (
+ <div
+ style={{
+ position: "absolute",
+ inset: 0,
+ width,
+ height,
+ overflow: "hidden",
+ backgroundColor: "#000000",
+ }}
+ >
+ {split ? (
+ <svg width={0} height={0} style={{ position: "absolute" }} aria-hidden>
+ <defs>
+ {channels.map((c) => (
+ <filter
+ key={c.id}
+ id={`${filterId}-${c.id}`}
+ colorInterpolationFilters="sRGB"
+ >
+ <feColorMatrix type="matrix" values={c.matrix} />
+ </filter>
+ ))}
+ </defs>
+ </svg>
+ ) : null}
+
+ <div
+ style={{
+ position: "absolute",
+ inset: 0,
+ transform: `translate(${shakeX}px, ${shakeY}px) rotate(${shakeR}deg)`,
+ transformOrigin: `${centerX}px ${centerY}px`,
+ }}
+ >
+ {composited}
+ </div>
+
+ {barHeight > 0 ? (
+ <>
+ <div
+ style={{
+ position: "absolute",
+ left: 0,
+ right: 0,
+ top: 0,
+ height: barHeight,
+ backgroundColor: "#000000",
+ }}
+ />
+ <div
+ style={{
+ position: "absolute",
+ left: 0,
+ right: 0,
+ bottom: 0,
+ height: barHeight,
+ backgroundColor: "#000000",
+ }}
+ />
+ </>
+ ) : null}
+ </div>
+ );
+}
+
+const LensZoomPresentation: React.FC<
+ TransitionPresentationComponentProps<LensZoomProps>
+> = ({ children, presentationDirection, presentationProgress, passedProps }) => {
+ const config = useVideoConfig();
+ const {
+ inScaleFrom = 100,
+ inScaleTo = 150,
+ inFovFrom = 0,
+ inFovTo = 160,
+ inBlurFrom = 0,
+ inBlurTo = 60,
+ inRotationFrom = 0,
+ inRotationTo = -15,
+
+ outScaleFrom = 135,
+ outScaleTo = 100,
+ outFovFrom = 135,
+ outFovTo = 0,
+ outBlurFrom = 45,
+ outBlurTo = 0,
+ outRotationFrom = 345,
+ outRotationTo = 360,
+
+ anticipateScale = 100,
+ anticipatePortion = 0.35,
+
+ lensSteps = 9,
+ blurSamples = 7,
+ blurScaleGain = 1,
+ blurFade = 1.5,
+
+ shakeAmount = 50,
+ shakeFrequency = 1.4,
+ shakeCyclesPerUnit = 8,
+ shakeTranslatePx = 73,
+ shakeRotateDeg = 1.1,
+
+ redScale = 1.01,
+ greenScale = 1.0,
+ blueScale = 0.99,
+
+ letterboxAspect = 0,
+
+ width = config.width,
+ height = config.height,
+ distortionCenterX = width / 2,
+ distortionCenterY = height / 2,
+ } = passedProps;
+
+ const exiting = presentationDirection === "exiting";
+
+ if (exiting ? presentationProgress >= 0.5 : presentationProgress < 0.5)
+ return null;
+
+ const p = exiting
+ ? interpolate(presentationProgress, [0, 0.5], [0, 1], {
+ easing: LENS_ZOOM_EASE_IN,
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ })
+ : interpolate(presentationProgress, [0.5, 1], [0, 1], {
+ easing: LENS_ZOOM_EASE_OUT,
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ });
+
+ const anticipating =
+ exiting && anticipatePortion > 0 && anticipateScale < inScaleFrom;
+
+ const pFx =
+ anticipating && exiting
+ ? interpolate(p, [anticipatePortion, 1], [0, 1], {
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ })
+ : p;
+
+ const lerp = (from: number, to: number) => from + (to - from) * pFx;
+
+ const exitScale = anticipating
+ ? interpolate(
+ p,
+ [0, anticipatePortion, 1],
+ [inScaleFrom, anticipateScale, inScaleTo],
+ {
+ easing: Easing.inOut(Easing.ease),
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ },
+ )
+ : lerp(inScaleFrom, inScaleTo);
+
+ const shakeEnvelope =
+ interpolate(
+ presentationProgress,
+ SHAKE_STOPS.map((s) => 0.5 + s / 2),
+ [0, shakeAmount, shakeAmount, 0],
+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" },
+ ) / 100;
+
+ return (
+ <LensZoomStage
+ scene={children}
+ scale={exiting ? exitScale : lerp(outScaleFrom, outScaleTo)}
+ fov={exiting ? lerp(inFovFrom, inFovTo) : lerp(outFovFrom, outFovTo)}
+ blur={exiting ? lerp(inBlurFrom, inBlurTo) : lerp(outBlurFrom, outBlurTo)}
+ rotation={
+ exiting
+ ? lerp(inRotationFrom, inRotationTo)
+ : lerp(outRotationFrom, outRotationTo)
+ }
+ centerX={distortionCenterX}
+ centerY={distortionCenterY}
+ width={width}
+ height={height}
+ lensSteps={lensSteps}
+ blurSamples={blurSamples}
+ blurScaleGain={blurScaleGain}
+ blurFade={blurFade}
+ shakeEnvelope={shakeEnvelope}
+ shakeFrequency={shakeFrequency}
+ shakeCyclesPerUnit={shakeCyclesPerUnit}
+ shakeTranslatePx={shakeTranslatePx}
+ shakeRotateDeg={shakeRotateDeg}
+ redScale={redScale}
+ greenScale={greenScale}
+ blueScale={blueScale}
+ letterboxAspect={letterboxAspect}
+ />
+ );
+};
+
+export function lensZoom(
+ props: LensZoomProps = {},
+): TransitionPresentation<LensZoomProps> {
+ return {
+ component: LensZoomPresentation,
+ props,
+ };
+}
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index 80ad87fc..febb676d 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -129,6 +129,20 @@
}
]
},
+ {
+ "name": "lens-zoom",
+ "type": "registry:component",
+ "title": "Lens Zoom",
+ "description": "A hard cut disguised as a lens punch-in: barrel distortion, zoom blur, chromatic split and camera shake around the splice.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "files": [
+ {
+ "path": "lens-zoom/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/lens-zoom.tsx"
+ }
+ ]
+ },
{
"name": "line-by-line-slide",
"type": "registry:component",