Skip to content

Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.

Say only what the card says, let the page finish, and free the captions (#233)

Nika Siradze0b8c0d9972e2
diff --git a/remotion/src/CaptionedClip.tsx b/remotion/src/CaptionedClip.tsx
index edbde42..cba700e 100644
--- a/remotion/src/CaptionedClip.tsx
+++ b/remotion/src/CaptionedClip.tsx
@@ -18,7 +18,7 @@ import type { Brand } from "./components/Cards";
import { MOTION, motionAt } from "./motion";
import type { Motion } from "./motion";
import {
- brandCaptions, captionZone, LOGO_CAPTION_GAP, LOGO_HEIGHT, LOGO_INSET, safeFor,
+ brandCaptions, captionZone, STYLES, LOGO_CAPTION_GAP, LOGO_HEIGHT, LOGO_INSET, safeFor,
} from "./types";
import type { Word, CaptionStyle, CaptionPosition, LogoPosition } from "./types";
import { resolveTheme } from "./style/theme";
@@ -78,6 +78,14 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({
theme: themeInput,
}) => {
const theme = resolveTheme(withDefaultTextures(themeInput ?? null));
+ const preset = theme ? STYLES[theme.captions] : undefined;
+ const voice: CaptionStyle = preset && preset.name !== style.name
+ ? {
+ ...preset,
+ fontFamily: style.fontFamily,
+ fontSize: preset.fontSize * (style.fontSize / (STYLES[style.name]?.fontSize ?? style.fontSize)),
+ }
+ : style;
const { fps, height, width } = useVideoConfig();
const SAFE = safeFor(width, height);
const frame = useCurrentFrame();
@@ -123,11 +131,11 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({
const placementMargin = captionPosition === "upper" ? 1120
: captionPosition === "center" ? 820
: captionPosition === "lower" ? SAFE.bottom
- : width < height ? style.marginBottom : SAFE.bottom;
+ : width < height ? voice.marginBottom : SAFE.bottom;
const captionStyle: CaptionStyle = {
- ...brandCaptions(style, brand),
+ ...brandCaptions(voice, brand),
marginBottom: Math.max(placementMargin, SAFE.bottom),
- fontSize: style.fontSize * captionSize * captionShrink,
+ fontSize: voice.fontSize * captionSize * captionShrink,
};
/*
@@ -168,7 +176,7 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({
);
const captionMotion: Motion = {
- ...(MOTION[style.name] ?? MOTION.subtle), ...(motion?.captions ?? {}),
+ ...(MOTION[voice.name] ?? MOTION.subtle), ...(motion?.captions ?? {}),
};
const cardMotion: Motion = { ...MOTION.nameCard, ...(motion?.nameCard ?? {}) };
const CaptionComponent = {
@@ -177,7 +185,7 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({
subtle: SubtleCaptions,
branded: BrandedCaptions,
outline: SubtleCaptions,
- }[style.name];
+ }[voice.name];
return (
<AbsoluteFill style={{ backgroundColor: "transparent" }}>
@@ -198,9 +206,9 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({
/>
)}
<Watermark src={logoSrc} height={height} position={logoPosition} scale={logoScale} />
- {theme ? (
+ {theme && theme.captions === "pack" ? (
<StyledCaptions theme={theme} words={words} style={captionStyle} />
- ) : style.name === "branded" ? (
+ ) : voice.name === "branded" ? (
<BrandedCaptions words={words} style={captionStyle} faceY={faceY}
captionPosition={captionPosition} hasLogo={Boolean(logoSrc)}
logoPosition={logoPosition} singleLine={singleLine} />
diff --git a/remotion/src/style/pages.test.ts b/remotion/src/style/pages.test.ts
index dbab0f1..c06dc8a 100644
--- a/remotion/src/style/pages.test.ts
+++ b/remotion/src/style/pages.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
-import { paced } from "./pages";
+import { buildFrames, paced, tempo } from "./pages";
import { entranceFrames } from "./reveal";
import { PACKS } from "./theme";
import type { Card } from "../cards";
@@ -19,3 +19,20 @@ describe("paced", () => {
expect(paced(PACKS.collage, quote, 600)).toBe(PACKS.collage);
});
});
+
+describe("tempo", () => {
+ const stat: Card = { kind: "stat", start: 3.5, end: 4.8, eyebrow: "Stanford research", value: "1 year", caption: "matched by Claude in three weeks" };
+
+ it("speeds the whole build up when the card is short", () => {
+ expect(tempo(PACKS.collage, stat, 39)).toBeGreaterThan(1);
+ });
+
+ it("leaves a long card at its own pace", () => {
+ expect(tempo(PACKS.collage, stat, 600)).toBe(1);
+ });
+
+ it("fits the sped-up build inside the first half of the card", () => {
+ const length = 60;
+ expect(buildFrames(PACKS.collage, stat) / tempo(PACKS.collage, stat, length)).toBeLessThanOrEqual(length * 0.55 + 0.001);
+ });
+});
diff --git a/remotion/src/style/pages.tsx b/remotion/src/style/pages.tsx
index 8bb9c1d..7f304e7 100644
--- a/remotion/src/style/pages.tsx
+++ b/remotion/src/style/pages.tsx
@@ -19,6 +19,7 @@ type PageProps<K extends Card["kind"]> = {
f: number;
fps: number;
inset: number;
+ k: number;
};
const planner = (theme: Theme, start = 2) => {
@@ -32,6 +33,7 @@ const planner = (theme: Theme, start = 2) => {
};
const CONTENT_TOP = 190;
+const EXIT_FRAMES = 8;
const CONTENT_BOTTOM = 1250;
const Page: React.FC<{
@@ -42,14 +44,15 @@ const Page: React.FC<{
shots: Shot[];
punch: Shot | null;
inset: number;
+ k: number;
children: React.ReactNode;
-}> = ({ theme, s, f, length, shots, punch, inset, children }) => {
+}> = ({ theme, s, f, length, shots, punch, inset, k, children }) => {
const { width, height } = useVideoConfig();
const shift = Math.max(0, inset - CONTENT_TOP + 20);
const squeeze = (CONTENT_BOTTOM - CONTENT_TOP - shift) / (CONTENT_BOTTOM - CONTENT_TOP);
const lens = (shot: Shot) => ({ ...shot, x: shot.x * s, y: shot.y * s });
const fade = theme.motion.exit === "fade"
- ? interpolate(f, [length - 6, length], [1, 0], { extrapolateLeft: "clamp", extrapolateRight: "clamp" })
+ ? interpolate(f, [length - EXIT_FRAMES * k, length], [1, 0], { extrapolateLeft: "clamp", extrapolateRight: "clamp" })
: 1;
return (
<AbsoluteFill style={{ overflow: "hidden", opacity: fade, backgroundColor: theme.color.ground }}>
@@ -123,16 +126,16 @@ const Strip: React.FC<{ theme: Theme; seed: number; s: number; color?: string; s
</Paper>
);
-const StatPage: React.FC<PageProps<"stat"> & { length: number }> = ({ card, theme, s, f, fps, length, inset }) => {
- const title = card.eyebrow ?? "By the numbers";
+const StatPage: React.FC<PageProps<"stat"> & { length: number }> = ({ card, theme, s, f, fps, length, inset, k }) => {
+ const title = card.eyebrow;
const next = planner(theme);
- const titleAt = next("title", title);
+ const titleAt = title ? next("title", title) : 0;
const stripAt = next("strip");
const sheetAt = next("media");
const figureAt = next("figure", card.value) + 4;
const circleAt = figureAt + 8;
return (
- <Page theme={theme} s={s} f={f} length={length} inset={inset}
+ <Page theme={theme} s={s} f={f} length={length} inset={inset} k={k}
punch={{ at: figureAt, zoom: 1.12, x: 540, y: 820 }}
shots={[
{ at: 0, zoom: 1.35, x: 360, y: 300 }, { at: stripAt, zoom: 1.35, x: 360, y: 300 },
@@ -147,13 +150,15 @@ const StatPage: React.FC<PageProps<"stat"> & { length: number }> = ({ card, them
</Reveal>
)}
<div style={{ position: "absolute", left: 50 * s, top: 190 * s, width: 980 * s, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 14 * s }}>
- <Reveal theme={theme} role="title" f={f} at={titleAt} fps={fps} style={{ position: "relative", ...tilt(theme, -1) }}>
- <Paper theme={theme} seed={12} color={theme.color.strip} scale={s}>
- <div style={{ ...fontOf(theme.type.display, titleSize(title, 124) * s), color: theme.color.ink, padding: `${22 * s}px ${48 * s}px ${34 * s}px` }}>
- <RevealText theme={theme} role="title" f={f} at={titleAt} text={title} s={s} />
- </div>
- </Paper>
- </Reveal>
+ {title && (
+ <Reveal theme={theme} role="title" f={f} at={titleAt} fps={fps} style={{ position: "relative", ...tilt(theme, -1) }}>
+ <Paper theme={theme} seed={12} color={theme.color.strip} scale={s}>
+ <div style={{ ...fontOf(theme.type.display, titleSize(title, 124) * s), color: theme.color.ink, padding: `${22 * s}px ${48 * s}px ${34 * s}px` }}>
+ <RevealText theme={theme} role="title" f={f} at={titleAt} text={title} s={s} />
+ </div>
+ </Paper>
+ </Reveal>
+ )}
{card.caption && (
<Reveal theme={theme} role="strip" f={f} at={stripAt} fps={fps} style={{ position: "relative", marginLeft: 60 * s, ...tilt(theme, 0.6) }}>
<Strip theme={theme} seed={13} s={s}>{card.caption}</Strip>
@@ -173,7 +178,7 @@ const StatPage: React.FC<PageProps<"stat"> & { length: number }> = ({ card, them
);
};
-const HeadlinePage: React.FC<PageProps<"headline"> & { length: number }> = ({ card, theme, s, f, fps, length, inset }) => {
+const HeadlinePage: React.FC<PageProps<"headline"> & { length: number }> = ({ card, theme, s, f, fps, length, inset, k }) => {
const next = planner(theme);
const eyebrowAt = next("label");
const leadAt = next("title", card.lead);
@@ -181,7 +186,7 @@ const HeadlinePage: React.FC<PageProps<"headline"> & { length: number }> = ({ ca
const subAt = next("strip") + 6;
const mark = Array.isArray(card.emphasis) ? card.emphasis[0] : card.emphasis;
return (
- <Page theme={theme} s={s} f={f} length={length} inset={inset}
+ <Page theme={theme} s={s} f={f} length={length} inset={inset} k={k}
punch={{ at: markAt, zoom: 1.1, x: 540, y: 640 }}
shots={[
{ at: 0, zoom: 1.18, x: 540, y: 560 }, { at: markAt, zoom: 1.18, x: 540, y: 560 }, { at: markAt + 16, zoom: 1, x: 540, y: 960 },
@@ -190,9 +195,11 @@ const HeadlinePage: React.FC<PageProps<"headline"> & { length: number }> = ({ ca
<Paper theme={theme} seed={21} color={theme.color.sheet} scale={s} strength={0.4}
style={{ position: "absolute", left: 160 * s, top: 760 * s, width: 1000 * s, height: 1300 * s, ...tilt(theme, 2) }} />
)}
- <Reveal theme={theme} role="label" f={f} at={eyebrowAt} fps={fps} style={{ left: 80 * s, top: 250 * s, ...tilt(theme, -2) }}>
- <Label theme={theme} seed={22} scale={s} size={50 * s}>{card.eyebrow ?? "The shift"}</Label>
- </Reveal>
+ {card.eyebrow && (
+ <Reveal theme={theme} role="label" f={f} at={eyebrowAt} fps={fps} style={{ left: 80 * s, top: 250 * s, ...tilt(theme, -2) }}>
+ <Label theme={theme} seed={22} scale={s} size={50 * s}>{card.eyebrow}</Label>
+ </Reveal>
+ )}
<Reveal theme={theme} role="title" f={f} at={leadAt} fps={fps} style={{ left: 40 * s, top: 340 * s, width: 990 * s, ...tilt(theme, -0.8) }}>
<Paper theme={theme} seed={23} color={theme.color.sheet} scale={s}>
<div style={{ ...fontOf(theme.type.display, 128 * s), color: theme.color.ink, padding: `${50 * s}px ${60 * s}px ${64 * s}px` }}>
@@ -209,14 +216,14 @@ const HeadlinePage: React.FC<PageProps<"headline"> & { length: number }> = ({ ca
);
};
-const EntityPage: React.FC<PageProps<"entity"> & { length: number }> = ({ card, theme, s, f, fps, length, inset }) => {
+const EntityPage: React.FC<PageProps<"entity"> & { length: number }> = ({ card, theme, s, f, fps, length, inset, k }) => {
const next = planner(theme, 0);
const mediaAt = next("media");
const nameAt = next("figure", card.name) + 10;
const noteAt = next("strip") + 10;
const src = card.src && (theme.media === "halftone" ? theme.textures.halftone?.[card.src] ?? card.src : card.src);
return (
- <Page theme={theme} s={s} f={f} length={length} inset={inset}
+ <Page theme={theme} s={s} f={f} length={length} inset={inset} k={k}
punch={{ at: nameAt, zoom: 1.1, x: 300, y: 1090 }}
shots={[{ at: 0, zoom: 1.4, x: 560, y: 420 }, { at: 12, zoom: 1.4, x: 560, y: 420 }, { at: 34, zoom: 1, x: 540, y: 960 }]}>
{src && <Reveal theme={theme} role="media" f={f} at={mediaAt} fps={fps} style={{ left: 120 * s, top: 170 * s, width: 840 * s, ...tilt(theme, 1.3) }}>
@@ -242,31 +249,34 @@ const EntityPage: React.FC<PageProps<"entity"> & { length: number }> = ({ card,
);
};
-const BulletsPage: React.FC<PageProps<"bullets"> & { length: number }> = ({ card, theme, s, f, fps, length, inset }) => {
- const title = card.eyebrow ?? "In short";
+const BulletsPage: React.FC<PageProps<"bullets"> & { length: number }> = ({ card, theme, s, f, fps, length, inset, k }) => {
+ const title = card.eyebrow;
const next = planner(theme);
- const titleAt = next("title", title);
+ const titleAt = title ? next("title", title) : 0;
const items = card.items.slice(0, 3).map(() => next("item"));
+ const lift = title ? 0 : 220;
const stocks = [theme.color.sheet, theme.color.stripAlt, theme.color.strip];
const lefts = [50, 110, 70];
return (
- <Page theme={theme} s={s} f={f} length={length} inset={inset}
+ <Page theme={theme} s={s} f={f} length={length} inset={inset} k={k}
punch={{ at: items[0] ?? 0, zoom: 1.08, x: 480, y: 600 }}
shots={[{ at: 0, zoom: 1.3, x: 380, y: 290 }, { at: items[0] ?? 0, zoom: 1.3, x: 380, y: 290 }, { at: (items[0] ?? 0) + 12, zoom: 1, x: 540, y: 960 }]}>
{theme.surface === "paper" && (
<Paper theme={theme} seed={40} color={theme.color.stripAlt} scale={s} texture="kraft"
style={{ position: "absolute", left: 300 * s, top: 420 * s, width: 900 * s, height: 1600 * s, ...tilt(theme, 3) }} />
)}
- <Reveal theme={theme} role="title" f={f} at={titleAt} fps={fps} style={{ left: 50 * s, top: 200 * s, ...tilt(theme, -1) }}>
- <Paper theme={theme} seed={41} color={theme.color.strip} scale={s}>
- <div style={{ ...fontOf(theme.type.display, titleSize(title, 120) * s), color: theme.color.ink, padding: `${22 * s}px ${48 * s}px ${34 * s}px` }}>
- <RevealText theme={theme} role="title" f={f} at={titleAt} text={title} s={s} />
- </div>
- </Paper>
- </Reveal>
+ {title && (
+ <Reveal theme={theme} role="title" f={f} at={titleAt} fps={fps} style={{ left: 50 * s, top: 200 * s, ...tilt(theme, -1) }}>
+ <Paper theme={theme} seed={41} color={theme.color.strip} scale={s}>
+ <div style={{ ...fontOf(theme.type.display, titleSize(title, 120) * s), color: theme.color.ink, padding: `${22 * s}px ${48 * s}px ${34 * s}px` }}>
+ <RevealText theme={theme} role="title" f={f} at={titleAt} text={title} s={s} />
+ </div>
+ </Paper>
+ </Reveal>
+ )}
{card.items.slice(0, 3).map((item, i) => (
<Reveal key={item} theme={theme} role="item" f={f} at={items[i]} fps={fps}
- style={{ left: lefts[i] * s, top: (500 + i * 220) * s, width: 900 * s, ...tilt(theme, i % 2 ? 0.9 : -0.8) }}>
+ style={{ left: lefts[i] * s, top: (500 - lift + i * 220) * s, width: 900 * s, ...tilt(theme, i % 2 ? 0.9 : -0.8) }}>
<Paper theme={theme} seed={42 + i} color={stocks[i]} scale={s} texture={i === 1 ? "kraft" : "paper"}>
<div style={{ ...fontOf(theme.type.display, 84 * s), color: theme.color.ink, padding: `${36 * s}px ${50 * s}px ${44 * s}px ${170 * s}px` }}>
<RevealText theme={theme} role="item" f={f} at={items[i]} text={item} s={s} />
@@ -281,12 +291,12 @@ const BulletsPage: React.FC<PageProps<"bullets"> & { length: number }> = ({ card
);
};
-const QuotePage: React.FC<PageProps<"quote"> & { length: number }> = ({ card, theme, s, f, fps, length, inset }) => {
+const QuotePage: React.FC<PageProps<"quote"> & { length: number }> = ({ card, theme, s, f, fps, length, inset, k }) => {
const next = planner(theme);
const textAt = next("title", card.text);
const byAt = next("label") + 4;
return (
- <Page theme={theme} s={s} f={f} length={length} inset={inset}
+ <Page theme={theme} s={s} f={f} length={length} inset={inset} k={k}
punch={{ at: byAt, zoom: 1.06, x: 540, y: 700 }}
shots={[{ at: 0, zoom: 1.15, x: 520, y: 620 }, { at: byAt - 4, zoom: 1.15, x: 520, y: 620 }, { at: byAt + 10, zoom: 1, x: 540, y: 960 }]}>
{theme.surface === "paper" && (
@@ -325,17 +335,17 @@ const Title: React.FC<{ theme: Theme; s: number; f: number; fps: number; at: num
</Reveal>
);
-const CompareRows: React.FC<PageProps<"compare"> & { length: number }> = ({ card, theme, s, f, fps, length, inset }) => {
- const title = card.eyebrow ?? "Side by side";
+const CompareRows: React.FC<PageProps<"compare"> & { length: number }> = ({ card, theme, s, f, fps, length, inset, k }) => {
+ const title = card.eyebrow;
const next = planner(theme);
- const titleAt = next("title", title);
+ const titleAt = title ? next("title", title) : 0;
const rows = card.rows.slice(0, 5);
const ats = rows.map(() => next("item"));
const top = Math.max(...rows.map((r) => r.value), 1);
return (
- <Page theme={theme} s={s} f={f} length={length} inset={inset} punch={{ at: ats[0] ?? 0, zoom: 1.06, x: 540, y: 700 }}
+ <Page theme={theme} s={s} f={f} length={length} inset={inset} k={k} punch={{ at: ats[0] ?? 0, zoom: 1.06, x: 540, y: 700 }}
shots={[{ at: 0, zoom: 1.3, x: 380, y: 290 }, { at: ats[0] ?? 0, zoom: 1.3, x: 380, y: 290 }, { at: (ats[0] ?? 0) + 12, zoom: 1, x: 540, y: 960 }]}>
- <Title theme={theme} s={s} f={f} fps={fps} at={titleAt} text={title} seed={81} />
+ {title && <Title theme={theme} s={s} f={f} fps={fps} at={titleAt} text={title} seed={81} />}
{rows.map((row, i) => (
<Reveal key={`${row.label}-${i}`} theme={theme} role="item" f={f} at={ats[i]} fps={fps}
style={{ left: 70 * s, top: (480 + i * 170) * s, width: 940 * s }}>
@@ -356,10 +366,10 @@ const CompareRows: React.FC<PageProps<"compare"> & { length: number }> = ({ card
);
};
-const ChangePage: React.FC<PageProps<"change"> & { length: number }> = ({ card, theme, s, f, fps, length, inset }) => {
- const title = card.eyebrow ?? card.label ?? "What moved";
+const ChangePage: React.FC<PageProps<"change"> & { length: number }> = ({ card, theme, s, f, fps, length, inset, k }) => {
+ const title = card.eyebrow ?? card.label;
const next = planner(theme);
- const titleAt = next("title", title);
+ const titleAt = title ? next("title", title) : 0;
const fromAt = next("item");
const arrowAt = fromAt + 6;
const toAt = next("figure", card.to.value) + 8;
@@ -374,9 +384,9 @@ const ChangePage: React.FC<PageProps<"change"> & { length: number }> = ({ card,
</Reveal>
);
return (
- <Page theme={theme} s={s} f={f} length={length} inset={inset} punch={{ at: toAt, zoom: 1.1, x: 540, y: 1000 }}
+ <Page theme={theme} s={s} f={f} length={length} inset={inset} k={k} punch={{ at: toAt, zoom: 1.1, x: 540, y: 1000 }}
shots={[{ at: 0, zoom: 1.25, x: 540, y: 560 }, { at: arrowAt, zoom: 1.25, x: 540, y: 560 }, { at: toAt + 8, zoom: 1, x: 540, y: 960 }]}>
- <Title theme={theme} s={s} f={f} fps={fps} at={titleAt} text={title} seed={91} />
+ {title && <Title theme={theme} s={s} f={f} fps={fps} at={titleAt} text={title} seed={91} />}
{end(card.from.value, card.from.note, fromAt, "item", 440, 92, false)}
{p > 0 && (
<svg style={{ position: "absolute", left: 470 * s, top: 690 * s, width: 140 * s, height: 190 * s, overflow: "visible" }}>
@@ -390,19 +400,19 @@ const ChangePage: React.FC<PageProps<"change"> & { length: number }> = ({ card,
);
};
-const SharePage: React.FC<PageProps<"share"> & { length: number }> = ({ card, theme, s, f, fps, length, inset }) => {
+const SharePage: React.FC<PageProps<"share"> & { length: number }> = ({ card, theme, s, f, fps, length, inset, k }) => {
const share = Math.max(0, Math.min(1, card.value));
const display = card.display ?? `${Math.round(share * 100)}%`;
- const title = card.eyebrow ?? "How much";
+ const title = card.eyebrow;
const next = planner(theme);
- const titleAt = next("title", title);
+ const titleAt = title ? next("title", title) : 0;
const figureAt = next("figure", display) + 4;
const barAt = next("item");
const fill = progress(theme.motion, f, barAt, Math.max(12, theme.motion.frames * 2));
return (
- <Page theme={theme} s={s} f={f} length={length} inset={inset} punch={{ at: figureAt, zoom: 1.1, x: 540, y: 700 }}
+ <Page theme={theme} s={s} f={f} length={length} inset={inset} k={k} punch={{ at: figureAt, zoom: 1.1, x: 540, y: 700 }}
shots={[{ at: 0, zoom: 1.3, x: 380, y: 290 }, { at: figureAt, zoom: 1.3, x: 380, y: 290 }, { at: figureAt + 12, zoom: 1, x: 540, y: 960 }]}>
- <Title theme={theme} s={s} f={f} fps={fps} at={titleAt} text={title} seed={101} />
+ {title && <Title theme={theme} s={s} f={f} fps={fps} at={titleAt} text={title} seed={101} />}
<Reveal theme={theme} role="figure" f={f} at={figureAt} fps={fps}
style={{ left: 0, right: 0, top: 520 * s, display: "flex", justifyContent: "center", ...tilt(theme, 1.4) }}>
<Label theme={theme} seed={102} scale={s} size={260 * s} ink={theme.color.figure} pad={0.16}>
@@ -422,7 +432,7 @@ const SharePage: React.FC<PageProps<"share"> & { length: number }> = ({ card, th
);
};
-const MediaPage: React.FC<PageProps<"image" | "video"> & { length: number }> = ({ card, theme, s, f, fps, length, inset }) => {
+const MediaPage: React.FC<PageProps<"image" | "video"> & { length: number }> = ({ card, theme, s, f, fps, length, inset, k }) => {
const src = card.src.startsWith("http") || card.src.startsWith("/") ? card.src : staticFile(card.src);
const shown = card.kind === "image" && theme.media === "halftone" ? theme.textures.halftone?.[card.src] ?? src : src;
const Frame = getRemotionEnvironment().isRendering ? OffthreadVideo : Video;
@@ -435,7 +445,7 @@ const MediaPage: React.FC<PageProps<"image" | "video"> & { length: number }> = (
? <Frame src={src} muted startFrom={Math.max(0, Math.round((card.startAt ?? 0) * fps))} style={fit} />
: <Img src={shown} style={fit} />;
return (
- <Page theme={theme} s={s} f={f} length={length} inset={inset} punch={null}
+ <Page theme={theme} s={s} f={f} length={length} inset={inset} k={k} punch={null}
shots={[{ at: 0, zoom: 1.12, x: 540, y: 800 }, { at: 30, zoom: 1, x: 540, y: 960 }]}>
<Reveal theme={theme} role="media" f={f} at={mediaAt} fps={fps}
style={bleed ? { inset: 0 } : { left: 70 * s, top: 170 * s, width: 940 * s, height: 1180 * s, ...tilt(theme, 1.1) }}>
@@ -455,13 +465,13 @@ const MediaPage: React.FC<PageProps<"image" | "video"> & { length: number }> = (
);
};
-const ScenePage: React.FC<PageProps<"scene"> & { length: number }> = ({ card, theme, s, f, fps, length, inset }) => {
+const ScenePage: React.FC<PageProps<"scene"> & { length: number }> = ({ card, theme, s, f, fps, length, inset, k }) => {
const next = planner(theme, 0);
const sheetAt = next("media");
const bodyAt = next("item");
const surface = theme.surface === "none" ? theme.color.ground : theme.color.sheet;
return (
- <Page theme={theme} s={s} f={f} length={length} inset={inset} punch={null}
+ <Page theme={theme} s={s} f={f} length={length} inset={inset} k={k} punch={null}
shots={[{ at: 0, zoom: 1.12, x: 540, y: 700 }, { at: bodyAt + 14, zoom: 1, x: 540, y: 960 }]}>
<Reveal theme={theme} role="media" f={f} at={sheetAt} fps={fps}
style={{ left: 40 * s, top: 190 * s, width: 1000 * s, height: 1060 * s, ...tilt(theme, -0.8) }}>
@@ -477,7 +487,8 @@ const ScenePage: React.FC<PageProps<"scene"> & { length: number }> = ({ card, th
);
};
-const cardTexts = (card: Card): string[] => Object.values(card).flatMap((value) => {
+const cardTexts = (card: Card): string[] => Object.entries(card).flatMap(([key, value]) => {
+ if (key === "kind") return [];
if (typeof value === "string") return [value];
if (Array.isArray(value)) return value.filter((item): item is string => typeof item === "string");
return [];
@@ -497,12 +508,23 @@ export const paced = (theme: Theme, card: Card, length: number): Theme => {
return { ...theme, motion: { ...theme.motion, charsPerPose: Math.ceil((longest * hold) / budget) } };
};
+export const buildFrames = (theme: Theme, card: Card) => {
+ const texts = cardTexts(card);
+ const typed = texts.reduce((sum, text) => sum + roleFrames(theme, "title", text), 0);
+ return typed + texts.length * (Math.max(2, theme.motion.stagger) + theme.motion.frames) + 24;
+};
+
+export const tempo = (theme: Theme, card: Card, length: number) =>
+ Math.max(1, buildFrames(theme, card) / Math.max(1, length * 0.55));
+
export const TakeoverPage: React.FC<{
card: Card; theme: Theme; s: number; start: number; length: number; inset: number;
}> = ({ card, theme, s, start, length, inset }) => {
- const f = useCurrentFrame() - start;
+ const fitted = paced(theme, card, length);
+ const k = tempo(fitted, card, length);
+ const f = Math.floor((useCurrentFrame() - start) * k);
const { fps } = useVideoConfig();
- const props = { theme: paced(theme, card, length), s, f, fps, length, inset };
+ const props = { theme: fitted, s, f, fps, length: length * k, inset, k };
if (card.kind === "stat") return <StatPage card={card} {...props} />;
if (card.kind === "headline") return <HeadlinePage card={card} {...props} />;
if (card.kind === "entity") return <EntityPage card={card} {...props} />;
diff --git a/remotion/src/style/theme.test.ts b/remotion/src/style/theme.test.ts
index 7df975f..9e18046 100644
--- a/remotion/src/style/theme.test.ts
+++ b/remotion/src/style/theme.test.ts
@@ -39,3 +39,17 @@ describe("resolveTheme", () => {
expect(text).not.toMatch(/gradient/i);
});
});
+
+describe("caption choice", () => {
+ it("keeps the pack's caption skin by default", () => {
+ expect(resolveTheme({ pack: "collage" })?.captions).toBe("pack");
+ });
+
+ it("takes any caption preset on its own", () => {
+ expect(resolveTheme({ pack: "collage", motion: "kinetic", overrides: { captions: "hormozi" } })?.captions).toBe("hormozi");
+ });
+
+ it("closes every motion preset with a fade rather than a cut", () => {
+ for (const motion of Object.values(MOTIONS)) expect(motion.exit).toBe("fade");
+ });
+});
diff --git a/remotion/src/style/theme.ts b/remotion/src/style/theme.ts
index bfc8dc6..5f850ee 100644
--- a/remotion/src/style/theme.ts
+++ b/remotion/src/style/theme.ts
@@ -11,6 +11,9 @@ export type TextUnit = "char" | "word";
export type Ease = "out" | "in-out" | "linear";
export type CameraMove = "none" | "track" | "push" | "punch";
export type Exit = "cut" | "fade";
+export type CaptionChoice = "pack" | "template" | "hormozi" | "karaoke" | "subtle" | "branded" | "outline";
+
+export const CAPTION_CHOICES: CaptionChoice[] = ["pack", "template", "hormozi", "karaoke", "subtle", "branded", "outline"];
export const ROLES: Role[] = ["title", "figure", "item", "media", "label", "strip", "caption", "name"];
export const ENTRANCES: Entrance[] = [
@@ -61,6 +64,7 @@ export interface Theme {
type: { display: Face; label: Face; mono: Face; caption: number };
edge: { kind: EdgeKind; wave: number; fiber: number; rim: number };
surface: "paper" | "none";
+ captions: CaptionChoice;
mark: "fill" | "color";
shadow: number;
texture: { strength: number; ground: number };
@@ -85,7 +89,7 @@ export const MOTIONS = {
"stop-motion": {
roles: every("pop", { title: "type", item: "wipe", media: "wipe-up", strip: "wipe", name: "wipe" }),
frames: 8, stagger: 8, holdEvery: 2, charsPerPose: 1, ease: "out", overshoot: 0, bounces: 0,
- from: "left", textUnit: "char", camera: "track", exit: "cut",
+ from: "left", textUnit: "char", camera: "track", exit: "fade",
},
smooth: {
roles: every("rise", { media: "fade" }),
@@ -95,7 +99,7 @@ export const MOTIONS = {
kinetic: {
roles: every("spring", { label: "pop", strip: "wipe", name: "wipe" }),
frames: 7, stagger: 4, holdEvery: 1, charsPerPose: 3, ease: "out", overshoot: 0.35, bounces: 1,
- from: "right", textUnit: "word", camera: "punch", exit: "cut",
+ from: "right", textUnit: "word", camera: "punch", exit: "fade",
},
calm: {
roles: every("fade"),
@@ -105,7 +109,7 @@ export const MOTIONS = {
digital: {
roles: every("scramble", { media: "pop", label: "pop", strip: "wipe", name: "pop" }),
frames: 10, stagger: 6, holdEvery: 2, charsPerPose: 2, ease: "linear", overshoot: 0, bounces: 0,
- from: "left", textUnit: "char", camera: "none", exit: "cut",
+ from: "left", textUnit: "char", camera: "none", exit: "fade",
},
} satisfies Record<string, Motion>;
@@ -154,6 +158,7 @@ const collage: Theme = {
},
edge: { kind: "torn", wave: 5, fiber: 1.6, rim: 9 },
surface: "paper",
+ captions: "pack",
mark: "fill",
shadow: 0.07,
texture: { strength: 0.55, ground: 0.95 },