Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.
Python ai-toolsauto-captionscaptionscliffmpegmcpmcp-serveropusclip-alternativepodcast-clipspodcastsshortform-videovertical-videowhisper
Give each pack a signature motion (#258)
Nika Siradzecea62f4d1f72
diff --git a/remotion/src/style/pages.tsx b/remotion/src/style/pages.tsxindex 39406e4..86de58d 100644--- a/remotion/src/style/pages.tsx+++ b/remotion/src/style/pages.tsx@@ -7,7 +7,7 @@ import type { Card } from "../cards";import { fontOf } from "./theme";import type { Role, Theme } from "./theme";import { Label, Paper, Tape } from "./materials";-import { camera, progress, Reveal, RevealText, roleFrames } from "./reveal";+import { camera, progress, Reveal, RevealText, roleFrames, TEXT_ENTRANCES } from "./reveal";import type { Shot } from "./reveal";import { Scene } from "../components/Scene";import { hasMedia, SCENE_WIDTH, sceneHeight } from "../scene";@@ -26,7 +26,7 @@ const planner = (theme: Theme, start = 2) => {let cursor = start;return (role: Role, text?: string) => {const at = cursor;- const spoken = theme.motion.roles[role] === "type" || theme.motion.roles[role] === "scramble";+ const spoken = TEXT_ENTRANCES.has(theme.motion.roles[role]);cursor = at + (spoken ? roleFrames(theme, role, text) : 0) + Math.max(2, theme.motion.stagger);return at;};diff --git a/remotion/src/style/reveal.test.ts b/remotion/src/style/reveal.test.tsindex 4f1d9e8..3eb76df 100644--- a/remotion/src/style/reveal.test.ts+++ b/remotion/src/style/reveal.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from "vitest";-import { entranceFrames, settle } from "./reveal";+import { countedTo, entranceFrames, settle } from "./reveal";import { MOTIONS } from "./theme";describe("settle", () => {@@ -48,3 +48,36 @@ describe("entranceFrames", () => {expect(entranceFrames(motion, "mask-circle")).toBe(motion.frames);});});+++describe("counting a figure up", () => {+ it("keeps the words around the number", () => {+ expect(countedTo("−95%", 1)).toBe("−95%");+ expect(countedTo("−95%", 0.5)).toBe("−48%");+ expect(countedTo("$1.2 trillion", 0.5)).toBe("$0.6 trillion");+ });++ it("keeps thousands separators the speaker's figure had", () => {+ expect(countedTo("10,000x", 0.25)).toBe("2,500x");+ expect(countedTo("10000x", 0.25)).toBe("2500x");+ });++ it("leaves a figure with no number alone", () => {+ expect(countedTo("half", 0.3)).toBe("half");+ });++ it("starts at zero and lands exactly on the figure", () => {+ expect(countedTo("3 weeks", 0)).toBe("0 weeks");+ expect(countedTo("3 weeks", 1)).toBe("3 weeks");+ });+});++describe("counting a figure that is not one number", () => {+ it("leaves a comma that is punctuation alone", () => {+ expect(countedTo("3, 2, 1", 0.5)).toBe("2, 2, 1");+ });++ it("shows the exact figure once the count lands", () => {+ expect(countedTo("9,007,199,254,740,993", 1)).toBe("9,007,199,254,740,993");+ });+});diff --git a/remotion/src/style/reveal.tsx b/remotion/src/style/reveal.tsxindex 38869ac..9db71f3 100644--- a/remotion/src/style/reveal.tsx+++ b/remotion/src/style/reveal.tsx@@ -17,7 +17,7 @@ export const wipe = (p: number, from: "left" | "bottom" = "left") => {return from === "bottom" ? `inset(${hidden} 0 0 0)` : `inset(-20% ${hidden} -20% -5%)`;};-const TEXT_ENTRANCES = new Set<Entrance>(["type", "scramble"]);+export const TEXT_ENTRANCES = new Set<Entrance>(["type", "typed", "scramble", "count"]);export const settle = (t: number, bounces: number) => {const k = Math.min(1, Math.max(0, t));@@ -32,6 +32,7 @@ const unitCount = (text: string, unit: Motion["textUnit"]) =>export const entranceFrames = (motion: Motion, entrance: Entrance, text?: string) => {if (entrance === "pop") return 1;+ if (entrance === "count") return Math.round(motion.frames * 1.8);if (TEXT_ENTRANCES.has(entrance) && text) {const perPose = motion.textUnit === "word" ? 1 : motion.charsPerPose;return Math.ceil(unitCount(text, motion.textUnit) / perPose) * Math.max(1, motion.holdEvery);@@ -65,6 +66,21 @@ const scrambled = (char: string, n: number) => {return pool ? pool[n % pool.length] : char;};+const NUMBER = /^(.*?)([-−]?)(\d{1,3}(?:,\d{3})+|\d+)(?:\.(\d+))?(.*)$/s;++export const countedTo = (text: string, p: number) => {+ if (p >= 1) return text;+ const found = NUMBER.exec(text);+ if (!found) return text;+ const [, before, sign, whole, decimals = "", after] = found;+ const target = Number(`${whole.replace(/,/g, "")}.${decimals || "0"}`);+ const now = target * Math.min(1, Math.max(0, p));+ const fixed = now.toFixed(decimals.length);+ const [int, frac] = fixed.split(".");+ const grouped = whole.includes(",") ? int.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : int;+ return `${before}${sign}${grouped}${frac ? `.${frac}` : ""}${after}`;+};+export const Reveal: React.FC<{theme: Theme;role: Role;@@ -97,6 +113,37 @@ export const Reveal: React.FC<{);}+ if (entrance === "slam") {+ const k = spring({+ frame: held(motion, f) - at, fps,+ config: { stiffness: 220, damping: 14, mass: 0.6 },+ durationInFrames: motion.frames * 2,+ });+ const opacity = interpolate(held(motion, f) - at, [0, 1], [0, 1], { extrapolateRight: "clamp" });+ return (+ <div style={{ ...base, opacity, transform: `${base.transform ?? ""} scale(${1.35 - 0.35 * k})` }}>{children}</div>+ );+ }++ if (entrance === "drop") {+ const p = progress(motion, f, at);+ const turn = (at % 2 ? 4 : -4) * (1 - p);+ return (+ <div style={{ ...base, opacity: Math.min(1, p * 3), transform: `${base.transform ?? ""} rotate(${turn}deg) scale(${1 + 0.08 * (1 - p)})` }}>+ {children}+ </div>+ );+ }++ if (entrance === "register") {+ const p = progress(motion, f, at);+ const dx = 4 + 10 * (1 - p);+ const dy = -(3 + 6 * (1 - p));+ return (+ <div style={{ ...base, opacity: p, filter: `drop-shadow(${dx}px ${dy}px 0 ${theme.color.accent})` }}>{children}</div>+ );+ }+const t = interpolate(held(motion, f), [at, at + Math.max(1, motion.frames)], [0, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp",});@@ -144,6 +191,10 @@ export const RevealText: React.FC<{}> = ({ theme, role, f, at, text, mark, markAt, s }) => {const { motion } = theme;const entrance = motion.roles[role];+ if (entrance === "count") {+ const p = progress(motion, f, at, entranceFrames(motion, "count"));+ return <span style={{ fontVariantNumeric: "tabular-nums" }}>{countedTo(text, p)}</span>;+ }const typing = TEXT_ENTRANCES.has(entrance);const pieces = units(text, motion.textUnit);const perPose = motion.textUnit === "word" ? 1 : motion.charsPerPose;@@ -157,7 +208,11 @@ export const RevealText: React.FC<{let seen = 0;let cursor = 0;- const spans: { text: string; from: number; visible: boolean; fresh: boolean; cover?: string }[] = pieces.map((piece) => {+ const finished = at + entranceFrames(motion, entrance, text);+ const since = held(motion, f) - finished;+ const caretOn = entrance === "typed"+ && (count < total || (since < 30 && Math.floor(since / 15) % 2 === 0));+ const spans: { text: string; from: number; visible: boolean; fresh: boolean; cover?: string; caret?: boolean }[] = pieces.map((piece) => {const word = piece.trim().length > 0;const index = word ? seen++ : seen - 1;const from = cursor;@@ -167,7 +222,11 @@ export const RevealText: React.FC<{const cover = entrance === "scramble" && !settled && word? Array.from(piece).map((char, i) => scrambled(char, (from + i) * 7 + seed * 13)).join(""): undefined;- return { text: piece, from, visible: shown, cover, fresh: entrance === "type" && word && index === count - 1 && count < total };+ return {+ text: piece, from, visible: shown, cover,+ fresh: entrance === "type" && word && index === count - 1 && count < total,+ caret: caretOn && word && index === count - 1,+ };});const render = (lo: number, hi: number) => spans@@ -185,10 +244,18 @@ export const RevealText: React.FC<{))}</span>) : (- <span key={span.from} style={{- opacity: span.visible ? 1 : 0,- filter: span.fresh ? `blur(${3 * s}px)` : undefined,- }}>{span.text}</span>+ <React.Fragment key={span.from}>+ <span style={{+ opacity: span.visible ? 1 : 0,+ filter: span.fresh ? `blur(${3 * s}px)` : undefined,+ }}>{span.text}</span>+ {span.caret && (+ <span style={{+ display: "inline-block", width: "0.55em", height: "0.92em", marginLeft: "0.06em",+ verticalAlign: "-0.12em", backgroundColor: "currentColor",+ }} />+ )}+ </React.Fragment>)));diff --git a/remotion/src/style/theme.test.ts b/remotion/src/style/theme.test.tsindex 90590d5..508980d 100644--- a/remotion/src/style/theme.test.ts+++ b/remotion/src/style/theme.test.ts@@ -9,7 +9,7 @@ describe("resolveTheme", () => {it("starts from the pack and its own motion", () => {const theme = resolveTheme({ pack: "editorial" });expect(theme?.color.accent).toBe(PACKS.editorial.color.accent);- expect(theme?.motion).toEqual(MOTIONS.smooth);+ expect(theme?.motion).toEqual(MOTIONS.highlighter);});it("swaps the motion without touching the look", () => {diff --git a/remotion/src/style/theme.ts b/remotion/src/style/theme.tsindex cea134f..5f9d49d 100644--- a/remotion/src/style/theme.ts+++ b/remotion/src/style/theme.ts@@ -5,7 +5,8 @@ export type Layout = "takeover";export type Role = "title" | "figure" | "item" | "media" | "label" | "strip" | "caption" | "name";export type Entrance =| "type" | "scramble" | "wipe" | "wipe-up" | "pop" | "rise" | "fade" | "spring"- | "slide" | "scale" | "blur" | "mask-circle" | "mask-diagonal" | "mask-split";+ | "slide" | "scale" | "blur" | "mask-circle" | "mask-diagonal" | "mask-split"+ | "count" | "slam" | "drop" | "register" | "typed";export type Side = "left" | "right" | "top" | "bottom";export type TextUnit = "char" | "word";export type Ease = "out" | "in-out" | "linear";@@ -19,6 +20,7 @@ export const ROLES: Role[] = ["title", "figure", "item", "media", "label", "striexport const ENTRANCES: Entrance[] = ["type", "scramble", "wipe", "wipe-up", "pop", "rise", "fade", "spring","slide", "scale", "blur", "mask-circle", "mask-diagonal", "mask-split",+ "count", "slam", "drop", "register", "typed",];export const SIDES: Side[] = ["left", "right", "top", "bottom"];@@ -156,6 +158,41 @@ export const MOTIONS = {frames: 9, stagger: 5, holdEvery: 1, charsPerPose: 3, ease: "out", overshoot: 0, bounces: 0,from: "left", textUnit: "word", camera: "track", exit: "fade",},+ settle: {+ roles: every("rise", { figure: "count", media: "fade" }),+ frames: 14, stagger: 4, holdEvery: 1, charsPerPose: 2, ease: "out", overshoot: 0, bounces: 0,+ from: "bottom", textUnit: "word", camera: "none", exit: "fade",+ },+ pinned: {+ roles: every("drop", { figure: "count", caption: "pop" }),+ frames: 6, stagger: 5, holdEvery: 2, charsPerPose: 2, ease: "out", overshoot: 0, bounces: 0,+ from: "left", textUnit: "word", camera: "push", exit: "fade",+ },+ highlighter: {+ roles: every("rise", { title: "wipe", label: "wipe", strip: "wipe", figure: "count", media: "mask-diagonal" }),+ frames: 12, stagger: 6, holdEvery: 1, charsPerPose: 2, ease: "in-out", overshoot: 0, bounces: 0,+ from: "left", textUnit: "word", camera: "push", exit: "fade",+ },+ grid: {+ roles: every("slide", { figure: "wipe-up", media: "mask-split" }),+ frames: 10, stagger: 3, holdEvery: 1, charsPerPose: 2, ease: "in-out", overshoot: 0, bounces: 0,+ from: "left", textUnit: "word", camera: "none", exit: "fade",+ },+ slam: {+ roles: every("slam", { figure: "count", label: "pop", strip: "pop" }),+ frames: 9, stagger: 6, holdEvery: 1, charsPerPose: 3, ease: "out", overshoot: 0.4, bounces: 0,+ from: "bottom", textUnit: "word", camera: "punch", exit: "fade",+ },+ typed: {+ roles: every("typed", { figure: "scramble", media: "wipe-up" }),+ frames: 8, stagger: 2, holdEvery: 2, charsPerPose: 1, ease: "linear", overshoot: 0, bounces: 0,+ from: "left", textUnit: "char", camera: "none", exit: "fade",+ },+ misprint: {+ roles: every("register"),+ frames: 12, stagger: 5, holdEvery: 2, charsPerPose: 2, ease: "out", overshoot: 0, bounces: 0,+ from: "bottom", textUnit: "word", camera: "none", exit: "fade",+ },} satisfies Record<string, Motion>;export type MotionId = keyof typeof MOTIONS;@@ -210,7 +247,7 @@ const collage: Theme = {tape: true,media: "halftone",tilt: 1.6,- motion: MOTIONS["stop-motion"],+ motion: MOTIONS.pinned,layout: TAKEOVER,textures: {},};@@ -242,7 +279,7 @@ const editorial: Theme = {texture: { strength: 0.25, ground: 0.4 },tape: false,tilt: 0,- motion: MOTIONS.smooth,+ motion: MOTIONS.highlighter,};const clean: Theme = {@@ -275,7 +312,7 @@ const clean: Theme = {tape: false,media: "photo",tilt: 0,- motion: MOTIONS.smooth,+ motion: MOTIONS.settle,};const swiss: Theme = {@@ -300,7 +337,7 @@ const swiss: Theme = {mono: face("DM Sans", 400, { lineHeight: 1.5 }),caption: 60,},- motion: MOTIONS.slide,+ motion: MOTIONS.grid,};const poster: Theme = {@@ -325,7 +362,7 @@ const poster: Theme = {mono: face("Barlow Condensed", 600, { lineHeight: 1.3 }),caption: 68,},- motion: MOTIONS.zoom,+ motion: MOTIONS.slam,};const terminal: Theme = {@@ -350,7 +387,7 @@ const terminal: Theme = {mono: face("Courier Prime", 400, { lineHeight: 1.45 }),caption: 56,},- motion: MOTIONS.digital,+ motion: MOTIONS.typed,};const riso: Theme = {@@ -380,7 +417,7 @@ const riso: Theme = {texture: { strength: 0.45, ground: 0.7 },tape: false,tilt: 0.8,- motion: MOTIONS.snappy,+ motion: MOTIONS.misprint,};export const PACKS = { clean, collage, editorial, swiss, poster, terminal, riso } satisfies Record<string, Theme>;