Skip to content

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

Keep a clip's own words out of the part of the frame the app has spent (#223)

Nika Siradze7978b9edd8ef
diff --git a/backend/cli.py b/backend/cli.py
index 98fec7c..54c62f5 100644
--- a/backend/cli.py
+++ b/backend/cli.py
@@ -3923,7 +3923,7 @@ def print_help():
print(f" {green}-n{reset}, {green}--top{reset} {gray}<N>{reset} Export top N clips {dim}(default: 5){reset}")
print(f" {green}-o{reset}, {green}--output{reset} {gray}<dir>{reset} Output directory {dim}(default: ./clips){reset}")
print(f" {green}-p{reset}, {green}--preset{reset} {gray}<name>{reset} Load a saved preset")
- print(f" {green}--caption-style{reset} {gray}<style>{reset} branded | hormozi | karaoke | subtle")
+ print(f" {green}--caption-style{reset} {gray}<style>{reset} branded | hormozi | karaoke | outline | subtle")
print(f" {green}--crop{reset} {gray}<strategy>{reset} speaker | speaker-hardcut | face | center")
print(f" {green}--fast{reset} Draft mode: tiny Whisper, heuristic clips, low quality")
print(f" {green}--logo{reset} {gray}<asset|path>{reset} Overlay logo image")
@@ -4470,7 +4470,7 @@ def main():
help="Where the thumbnail goes in the video itself. "
"off keeps the pictures and leaves the video alone (default: start)")
proc.add_argument("--template", help="Cut in a saved look (podcli Pro). Name or id.")
- proc.add_argument("--caption-style", choices=["branded", "hormozi", "karaoke", "subtle"])
+ proc.add_argument("--caption-style", choices=["branded", "hormozi", "karaoke", "subtle", "outline"])
proc.add_argument("--caption-position", choices=["auto", "upper", "center", "lower"],
help="Caption placement (default: follows the chosen style)")
proc.add_argument("--caption-scale", type=float, choices=[0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5],
@@ -4563,7 +4563,7 @@ def main():
studio.add_argument("--language", help="Transcription language (e.g. es). Auto-detect if omitted.")
studio.add_argument("--engine", choices=["whisper-py", "whispercpp", "assemblyai"], help="Transcription engine")
studio.add_argument("--assemblyai-api-key", help="AssemblyAI API key for --engine assemblyai. Prefer ASSEMBLYAI_API_KEY; command-line secrets can appear in process listings.")
- studio.add_argument("--caption-style", choices=["hormozi", "karaoke", "subtle", "branded"], default="hormozi")
+ studio.add_argument("--caption-style", choices=["hormozi", "karaoke", "subtle", "branded", "outline"], default="hormozi")
studio.add_argument("--caption-position", choices=["auto", "upper", "center", "lower"], default="auto")
studio.add_argument("--caption-scale", type=float, default=1.0)
studio.add_argument("--crop", choices=["center", "face", "speaker", "speaker-hardcut", "manual"], default="face")
@@ -4633,7 +4633,7 @@ def main():
pre_save.add_argument("--video", help="Default video path")
pre_save.add_argument("--transcript", help="Default transcript path")
pre_save.add_argument("--output", help="Default output directory")
- pre_save.add_argument("--caption-style", choices=["branded", "hormozi", "karaoke", "subtle"])
+ pre_save.add_argument("--caption-style", choices=["branded", "hormozi", "karaoke", "subtle", "outline"])
pre_save.add_argument("--crop", choices=["center", "face", "speaker", "speaker-hardcut"])
pre_save.add_argument("--logo", help="Logo (asset name or path)")
pre_save.add_argument("--outro", help="Outro (asset name or path)")
@@ -4787,7 +4787,7 @@ def main():
clips_edit.add_argument("clip_id", help="Clip id (full or 8-char prefix)")
clips_edit.add_argument("--title", help="New title")
clips_edit.add_argument(
- "--caption-style", choices=["branded", "hormozi", "karaoke", "subtle"], help="New caption style"
+ "--caption-style", choices=["branded", "hormozi", "karaoke", "subtle", "outline"], help="New caption style"
)
clips_edit.add_argument("--thumbnail-config", help="Per-clip thumbnail config as a JSON string")
clips_reopen = clips_sub.add_parser(
@@ -5761,7 +5761,7 @@ def _interactive_presets():
# Caption style
caption_style = questionary.select(
"Caption style:",
- choices=["branded", "hormozi", "karaoke", "subtle"],
+ choices=["branded", "hormozi", "karaoke", "subtle", "outline"],
default=config.get("caption_style", "branded"),
style=qstyle,
).ask()
diff --git a/backend/clip_studio.py b/backend/clip_studio.py
index a6fe152..e0cad6d 100644
--- a/backend/clip_studio.py
+++ b/backend/clip_studio.py
@@ -338,7 +338,7 @@ def main():
ap.add_argument("--language", default=None, help="Transcription language (e.g. es). Auto-detect if omitted.")
ap.add_argument("--engine", choices=["whisper-py", "whispercpp", "assemblyai"], default=None, help="Transcription engine")
ap.add_argument("--transcript", default=None, help="Word timings JSON for this video (list of {word,start,end} or {words:[...]}); skips transcription")
- ap.add_argument("--caption-style", default="hormozi", choices=["hormozi", "karaoke", "subtle", "branded"])
+ ap.add_argument("--caption-style", default="hormozi", choices=["hormozi", "karaoke", "subtle", "branded", "outline"])
ap.add_argument("--caption-position", default="auto", choices=["auto", "upper", "center", "lower"])
ap.add_argument("--caption-scale", type=float, default=1.0)
ap.add_argument("--crop", default="face", choices=["center", "face", "speaker", "speaker-hardcut"])
diff --git a/backend/config/caption_styles.py b/backend/config/caption_styles.py
index edf4276..0b71bd5 100644
--- a/backend/config/caption_styles.py
+++ b/backend/config/caption_styles.py
@@ -109,6 +109,23 @@ STYLES = {
"uppercase": False,
"gradient_overlay": False,
},
+ "outline": {
+ "description": "A whole line at a time in white with a heavy black outline, no box. Stays readable without covering the shot.",
+ "font_name": DETECTED_FONT,
+ "font_size": 78,
+ "primary_color": "&H00FFFFFF", # White
+ "active_color": None, # The line is the unit, no sweep
+ "outline_color": "&H00000000", # Black
+ "back_color": "&H00000000", # Transparent: the outline does the work
+ "bold": True,
+ "outline_width": 6, # Heavy enough to carry over any footage
+ "shadow_depth": 0, # An outline and a shadow together read as mud
+ "alignment": 2,
+ "margin_v": 460, # Clears the app's own title and handle
+ "words_per_chunk": 7,
+ "uppercase": False,
+ "gradient_overlay": False,
+ },
"branded": {
"description": "Large bold text, 5-7 words wrapping across 2 lines, dark rounded pill on active word. Clean, no gradient.",
"font_name": DETECTED_FONT,
diff --git a/backend/services/caption_renderer.py b/backend/services/caption_renderer.py
index 06291c5..8f44d3a 100644
--- a/backend/services/caption_renderer.py
+++ b/backend/services/caption_renderer.py
@@ -118,7 +118,7 @@ def render_captions(
style = dict(get_style(caption_style))
scale = max(60, min(160, int(caption_font_scale))) / 100
style["font_size"] = round(style["font_size"] * scale)
- position_margins = {"upper": 760, "center": 480, "lower": 220}
+ position_margins = {"upper": 1120, "center": 820, "lower": 460}
if caption_position in position_margins:
style["margin_v"] = position_margins[caption_position]
@@ -126,7 +126,7 @@ def render_captions(
content = _render_hormozi(words, style, time_offset)
elif caption_style == "karaoke":
content = _render_karaoke(words, style, time_offset)
- elif caption_style == "subtle":
+ elif caption_style in ("subtle", "outline"):
content = _render_subtle(words, style, time_offset)
elif caption_style == "branded":
content = _render_branded(words, style, time_offset)
diff --git a/cli/VERSION b/cli/VERSION
index 93ebf46..168a15e 100644
--- a/cli/VERSION
+++ b/cli/VERSION
@@ -1 +1 @@
-2.7.33
+2.7.34
diff --git a/package-lock.json b/package-lock.json
index 492084c..5bc3efe 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "podcli",
- "version": "2.7.33",
+ "version": "2.7.34",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "podcli",
- "version": "2.7.33",
+ "version": "2.7.34",
"license": "AGPL-3.0-only",
"dependencies": {
"@fontsource/dm-sans": "^5.3.0",
diff --git a/package.json b/package.json
index 1623694..c97e223 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "podcli",
- "version": "2.7.33",
+ "version": "2.7.34",
"private": true,
"description": "AI-powered podcast clip generator for TikTok/YouTube Shorts. Transcribe, find viral moments, export vertical clips with burned captions.",
"type": "module",
diff --git a/remotion/src/CaptionedClip.tsx b/remotion/src/CaptionedClip.tsx
index b49f4ed..b171647 100644
--- a/remotion/src/CaptionedClip.tsx
+++ b/remotion/src/CaptionedClip.tsx
@@ -11,12 +11,15 @@ import { TopicChip } from "./components/TopicChip";
import type { TopicChipProps } from "./components/TopicChip";
import { ProgressBar } from "./components/ProgressBar";
import type { ProgressBarProps } from "./components/ProgressBar";
-import { Cards, CARD_CAPTION_MARGIN } from "./components/Cards";
+import { Cards } from "./components/Cards";
import { cardAt } from "./cards";
import type { Card } from "./cards";
import type { Brand } from "./components/Cards";
-import { MOTION } from "./motion";
+import { MOTION, motionAt } from "./motion";
import type { Motion } from "./motion";
+import {
+ brandCaptions, captionZone, LOGO_CAPTION_GAP, LOGO_HEIGHT, LOGO_INSET, safeFor,
+} from "./types";
import type { Word, CaptionStyle, CaptionPosition, LogoPosition } from "./types";
export interface CaptionedClipProps {
@@ -68,37 +71,95 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({
brand,
motion,
}) => {
- const { fps, height } = useVideoConfig();
+ const { fps, height, width } = useVideoConfig();
+ const SAFE = safeFor(width, height);
const frame = useCurrentFrame();
- /*
- * Captions drop toward the bottom edge while a card holds the frame.
- *
- * Their usual margin keeps them clear of a speaker's chin and hands. There
- * is no chin down there when a card is up, so the margin is only empty
- * surface, and it was the single biggest thing pushing the speaker's band
- * short enough to cut a face in half.
- */
const nameCardSeconds = nameCard?.title ? (nameCard.seconds ?? 3) : 0;
const pastNameCard = frame / fps >= nameCardSeconds;
- const cardUp = pastNameCard && Boolean(cards?.length) && Boolean(cardAt(cards ?? [], frame / fps));
const cardPlanned = Boolean(cards?.length);
- const captionShrink = cardUp ? 0.6 : cardPlanned ? 0.75 : 1;
- const baseCaptionStyle: CaptionStyle = cardUp
- ? { ...style, marginBottom: Math.min(style.marginBottom, CARD_CAPTION_MARGIN) }
- : style;
- // Keep a simple four-stop placement model. It is easier to reason about
- // than pixels, and stays proportional across every output shape.
- const placementMargin = captionPosition === "upper" ? 760
- : captionPosition === "center" ? 480
- : captionPosition === "lower" ? 220
- : baseCaptionStyle.marginBottom;
+ const upNow = pastNameCard ? cardAt(cards ?? [], frame / fps) : null;
+ /*
+ * How far in the card is, rather than whether it is.
+ *
+ * The card cross-fades over six frames and the captions used to answer on
+ * the frame it started: shrinking and jumping while the thing they were
+ * getting out of the way of was still arriving. Reading the card's own fade
+ * means the two move together, so a card coming up looks like one move
+ * instead of a card fading under captions that already snapped.
+ */
+ const cardIn = upNow
+ ? motionAt({
+ frame, fps, start: upNow.start, end: upNow.end,
+ motion: upNow.motion ?? MOTION.card,
+ }).opacity
+ : 0;
+ const restingShrink = cardPlanned ? 0.75 : 1;
+ const captionShrink = restingShrink + (0.6 - restingShrink) * cardIn;
+ /*
+ * Captions used to drop toward the bottom edge while a card held the frame,
+ * on the reasoning that there is no chin down there to clear. There is no
+ * chin, but there is a YouTube title, a handle and a link chip, and the
+ * margin that bought the speaker a taller band was spending the one part of
+ * the frame the viewer never sees. They hold above the chrome now, and the
+ * band the speaker lost is taken off its own floor instead.
+ */
+ /*
+ * A four-stop placement model, easier to reason about than pixels.
+ *
+ * The three named stops are fractions of the frame and travel between
+ * shapes on their own. Auto does not. A style's own margin was authored
+ * against a 1920-tall phone, and the same number on a 1080-tall landscape
+ * frame is half the picture. Off a phone, auto means as low as the
+ * furniture allows.
+ */
+ const placementMargin = captionPosition === "upper" ? 1120
+ : captionPosition === "center" ? 820
+ : captionPosition === "lower" ? SAFE.bottom
+ : width < height ? style.marginBottom : SAFE.bottom;
const captionStyle: CaptionStyle = {
- ...baseCaptionStyle,
- marginBottom: placementMargin,
- fontSize: baseCaptionStyle.fontSize * captionSize * captionShrink,
+ ...brandCaptions(style, brand),
+ marginBottom: Math.max(placementMargin, SAFE.bottom),
+ fontSize: style.fontSize * captionSize * captionShrink,
};
+ /*
+ * What the card lays itself out against.
+ *
+ * Not the caption that is halfway through shrinking. The reserved band is a
+ * function of the caption's size, so handing the card the interpolating one
+ * made its whole body creep and resize through the six frames of its own
+ * fade. It reserves for the settled size instead: the card holds still and
+ * only the captions move.
+ */
+ const settledStyle: CaptionStyle = {
+ ...captionStyle,
+ fontSize: style.fontSize * captionSize * 0.6,
+ };
+
+ /*
+ * Who owns the top corners, so nothing else writes into them.
+ *
+ * The logo and the chip both default to the same corner at the same inset,
+ * which drew one straight through the other on any clip carrying both. The
+ * chip drops below the logo when they collide, and a card given the whole
+ * frame is told how much of the top is already spoken for.
+ */
+ const logoTop = Boolean(logoSrc) && logoPosition.startsWith("top-");
+ const chipTop = Boolean(topic?.label)
+ && (topic?.position ?? "top-left").startsWith("top-");
+ const chipClashes = logoTop
+ && chipTop
+ && (topic?.position ?? "top-left").slice(4) === logoPosition.slice(4);
+ const chipInset = LOGO_INSET
+ + (chipClashes ? LOGO_HEIGHT * logoScale + LOGO_CAPTION_GAP : 0);
+ const CHIP_HEIGHT = 48;
+ const topTaken = Math.max(
+ SAFE.top,
+ logoTop ? LOGO_INSET + LOGO_HEIGHT * logoScale + LOGO_CAPTION_GAP : 0,
+ chipTop ? chipInset + CHIP_HEIGHT + LOGO_CAPTION_GAP : 0,
+ );
+
const captionMotion: Motion = {
...(MOTION[style.name] ?? MOTION.subtle), ...(motion?.captions ?? {}),
};
@@ -108,6 +169,7 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({
karaoke: KaraokeCaptions,
subtle: SubtleCaptions,
branded: BrandedCaptions,
+ outline: SubtleCaptions,
}[style.name];
return (
@@ -118,7 +180,8 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({
cards={cards}
videoSrc={videoSrc}
startFrom={startFrom}
- style={captionStyle}
+ style={settledStyle}
+ topInset={topTaken}
faceY={faceY}
faceH={faceH}
brand={brand}
@@ -133,8 +196,14 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({
<CaptionComponent words={words} style={captionStyle} motion={captionMotion}
singleLine={singleLine} />
)}
- {nameCard?.title && <NameCard {...nameCard} motion={cardMotion} />}
- {topic?.label && <TopicChip {...topic} />}
+ {nameCard?.title && (
+ <NameCard
+ {...nameCard}
+ bottom={nameCard.bottom ?? captionZone(captionStyle) + 24}
+ motion={cardMotion}
+ />
+ )}
+ {topic?.label && <TopicChip {...topic} inset={chipInset} />}
{progress && <ProgressBar {...progress} />}
</AbsoluteFill>
);
diff --git a/remotion/src/cards.ts b/remotion/src/cards.ts
index 8595541..1ca087a 100644
--- a/remotion/src/cards.ts
+++ b/remotion/src/cards.ts
@@ -20,6 +20,17 @@ interface CardBase {
* could read at half the height.
*/
speaker?: null;
+ /**
+ * Whether the card is a surface laid over the shot or ink written on it.
+ *
+ * "panel" is the default and the safe one: an opaque band, legible over any
+ * footage because none of it shows through. "over" keeps the whole shot and
+ * writes into it, which is what an interview channel does when the frame
+ * has room to spare. It costs the guarantee: a card written over a bright
+ * kitchen needs the scrim to do work a panel did for free, so it is a
+ * choice somebody makes about a shot rather than a default.
+ */
+ place?: "panel" | "over";
}
/**
@@ -42,8 +53,13 @@ export type Card =
kind: "headline";
eyebrow?: string;
lead: string;
- /** The payload word, set apart from the lead. */
- emphasis?: string;
+ /**
+ * The payload words, set apart from the lead.
+ *
+ * Coloured where they stand when they are in the lead, appended when
+ * they are not. See the text block for why both.
+ */
+ emphasis?: string | string[];
sub?: string;
})
| (CardBase & { kind: "bullets"; eyebrow?: string; items: string[] })
@@ -110,6 +126,16 @@ export type Card =
* and is for a photograph, where the edges carry nothing.
*/
fit?: "fit" | "fill";
+ /**
+ * Whether the file takes the whole frame rather than a band of it.
+ *
+ * Only ever honoured once the card has given up the speaker, because a
+ * cutaway that leaves the person on screen is a smaller picture with
+ * extra steps. A band too short to read falls back to this on its own:
+ * a letterbox slit of a photograph says nothing while still costing the
+ * frame it sits in.
+ */
+ bleed?: boolean;
caption?: string;
})
/**
@@ -139,6 +165,8 @@ export type Card =
fit?: "fit" | "fill";
/** Where in the file to start, in seconds. */
startAt?: number;
+ /** The whole frame rather than the band. See the image card. */
+ bleed?: boolean;
caption?: string;
});
diff --git a/remotion/src/components/BrandedCaptions.tsx b/remotion/src/components/BrandedCaptions.tsx
index 966d61b..5ecb836 100644
--- a/remotion/src/components/BrandedCaptions.tsx
+++ b/remotion/src/components/BrandedCaptions.tsx
@@ -38,7 +38,8 @@ const WordWithPill: React.FC<{
frame: number;
fps: number;
emphasisColor?: string;
-}> = ({ word, isActive, frame, fps, emphasisColor }) => {
+ background?: string;
+}> = ({ word, isActive, frame, fps, emphasisColor, background }) => {
const { height } = useVideoConfig();
const s = captionScale(height);
const wordEntryFrame = Math.round(word.start * fps);
@@ -61,7 +62,7 @@ const WordWithPill: React.FC<{
left: -16 * s,
right: -16 * s,
bottom: -4 * s,
- backgroundColor: "rgba(0, 0, 0, 0.85)",
+ backgroundColor: background ?? "rgba(0, 0, 0, 0.85)",
borderRadius: 18 * s,
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.5)",
opacity: pillOpacity,
@@ -120,6 +121,7 @@ const CaptionLine: React.FC<{
frame={frame}
fps={fps}
emphasisColor={style.emphasisColor}
+ background={style.background}
/>
</React.Fragment>
);
diff --git a/remotion/src/components/Cards.tsx b/remotion/src/components/Cards.tsx
index 4486f17..7282649 100644
--- a/remotion/src/components/Cards.tsx
+++ b/remotion/src/components/Cards.tsx
@@ -3,7 +3,7 @@ import {
getRemotionEnvironment, Img, OffthreadVideo, Video, staticFile,
useCurrentFrame, useVideoConfig,
} from "remotion";
-import { captionScale, FONT } from "../types";
+import { captionScale, captionZone, FONT, safeFor } from "../types";
import type { CaptionStyle } from "../types";
import { MOTION, motionAt } from "../motion";
import { cardAt } from "../cards";
@@ -11,7 +11,7 @@ import type { Card } from "../cards";
import { context, DEFAULT_BRAND, muted, track } from "./brand";
import type { Brand } from "./brand";
import { fitScene, Scene } from "./Scene";
-import { MIN_FIT } from "../scene";
+import { emphasisRuns, MIN_FIT, sceneHeight } from "../scene";
import type { Block } from "../scene";
/**
@@ -52,11 +52,12 @@ const TYPE = { label: 34, body: 46, item: 58, quote: 68, lead: 84, figure: 168 }
/**
* How much of the frame a video card's footage takes.
*
- * The arithmetic it has to fit: a 1920 canvas, roughly 470 reserved for the
- * captions, 76 of gap, and the speaker's own floor of 820 above it. What is
- * left is this. Asking for the literal half of the frame would push the band
- * under that floor, and the card would answer by dropping the speaker
- * altogether — the opposite of what a split screen is for.
+ * The arithmetic it has to fit: a 1920 canvas, roughly 750 reserved for the
+ * captions and for the app's own furniture under them, 76 of gap, and the
+ * speaker's floor of 680 above it. What is left is this. Asking for the
+ * literal half of the frame would push the band under that floor, and the
+ * card would answer by dropping the speaker altogether, which is the opposite
+ * of what a split screen is for.
*
* It shrinks before the speaker does, because a caption style with tall words
* has to take its room from somewhere and a face cut in half is worse than
@@ -117,8 +118,21 @@ const mediaBand = (
* two-line quote and a bare figure want different amounts, and pinning both
* ends meant a tall card overflowed upward across the speaker's chin. This
* floor stops a very long card from squeezing the face out altogether.
+ *
+ * It was 820 while the captions were free to drop to the bottom edge. They
+ * are not: the bottom 520 belongs to the app the clip plays in. The band the
+ * captions gave back has to come off this floor, because the alternative is a
+ * card written into the part of the frame a viewer never sees.
*/
-const SPEAKER_MIN = 820;
+const SPEAKER_MIN = 680;
+
+/**
+ * How far the footage takes to become the card.
+ *
+ * Long enough to read as a ramp rather than a band, short enough that the
+ * shoulder it eats is a shoulder and not a face.
+ */
+const SEAM = 160;
/**
* How much room a head needs, given how big the face is.
@@ -135,36 +149,6 @@ const SPEAKER_MIN = 820;
*/
const HEAD_TO_FACE = 2.5;
-/**
- * Where captions sit while a card is up.
- *
- * Their usual margin exists to clear a speaker's chin and hands, and there is
- * no chin down there behind a card. Dropping them toward the bottom edge is
- * what buys the speaker a band tall enough to hold a whole head.
- */
-export const CARD_CAPTION_MARGIN = 180;
-
-/**
- * The room the captions need, measured rather than assumed.
- *
- * A fixed number worked until a two-line Georgian caption grew taller than it
- * and the card's last line rendered behind the pill. The caption's own style
- * knows where it sits and how big it is, so the reserved band is read off that:
- * its margin, two lines of it, and a gap.
- */
-const captionZone = (style: CaptionStyle) =>
- style.marginBottom + style.fontSize * CAPTION_LINES * 1.2 + GAP.group;
-
-/**
- * How many lines of caption a card gets out of the way of.
- *
- * Two was the common case and wrong at the worst one: a chunk that wrapped to
- * three lines covered the card's last row, which is the row a comparison keeps
- * its second bar in. Reserving for the tallest caption costs a card some
- * height on every clip and costs it nothing on the clip where it matters.
- */
-const CAPTION_LINES = 3;
-
/*
* The panel runs to the bottom edge, and that is not negotiable.
*
@@ -232,6 +216,68 @@ const Endpoint: React.FC<{
</div>
);
+/**
+ * A file given the whole frame, the way a cutaway is.
+ *
+ * Cover rather than contain, because a cutaway that letterboxes itself is a
+ * picture of a picture. A screenshot says otherwise by asking to be fitted,
+ * and gets the surface behind it rather than bars of nothing.
+ *
+ * Any caption it carries goes to the top. The bottom of the frame is spoken
+ * for twice over down there, by the clip's own captions and by the app's
+ * furniture under them, and a source line is not worth fighting either for.
+ */
+const BleedMedia: React.FC<{
+ card: Extract<Card, { kind: "image" | "video" }>;
+ scale: number;
+ brand: Brand;
+ fps: number;
+ topInset: number;
+}> = ({ card, scale: s, brand, fps, topInset }) => {
+ const { height, width } = useVideoConfig();
+ const SAFE = safeFor(width, height);
+ const src = card.src.startsWith("http") ? card.src : staticFile(card.src);
+ const fit = card.fit === "fit" ? "contain" : "cover";
+ const box: React.CSSProperties = {
+ position: "absolute", inset: 0, width: "100%", height: "100%",
+ objectFit: fit, backgroundColor: card.fit === "fit" ? brand.surface : "#000",
+ };
+ const Frame = getRemotionEnvironment().isRendering ? OffthreadVideo : Video;
+
+ return (
+ <>
+ {card.kind === "video" ? (
+ <Frame
+ src={src}
+ startFrom={Math.max(0, Math.round((card.startAt ?? 0) * fps))}
+ muted
+ style={box}
+ />
+ ) : (
+ <Img src={src} style={box} />
+ )}
+ {card.caption && (
+ <div
+ style={{
+ position: "absolute", top: 0, left: 0, right: 0,
+ padding: `${topInset * s}px ${SAFE.right * s}px ${GAP.section * s}px `
+ + `${SAFE.left * s}px`,
+ background:
+ `linear-gradient(to bottom, rgba(0,0,0,0.65), transparent)`,
+ fontFamily: FONT,
+ fontSize: TYPE.label * s,
+ fontWeight: 500,
+ lineHeight: 1.3,
+ color: "#FFFFFF",
+ }}
+ >
+ {card.caption}
+ </div>
+ )}
+ </>
+ );
+};
+
const CardBody: React.FC<{
card: Card;
scale: number;
@@ -244,12 +290,25 @@ const CardBody: React.FC<{
* drawn over the captions rather than a card that came out short.
*/
room?: number;
+ /**
+ * Whether a file takes the whole frame rather than a band of it.
+ *
+ * Set when the card has already given up the speaker. A photograph nobody
+ * kept a face for was still being drawn at a quarter of the height, which
+ * left it floating in an empty slab: the layout of a split screen with
+ * nothing in the other half. Given the frame, it is a cutaway, which is what
+ * dropping the speaker was for.
+ */
+ bleed?: boolean;
+ /** How much of the top the logo and the chip have already taken. */
+ topInset?: number;
}> = ({
- card, scale: s, brand, room,
+ card, scale: s, brand, room, bleed = false, topInset,
}) => {
// Read before any of the branches below, so a card kind that never uses it
// does not change the order the hooks run in.
- const { fps } = useVideoConfig();
+ const { fps, height, width } = useVideoConfig();
+ const SAFE = safeFor(width, height);
const accent = card.accent ?? brand.accent;
const INK = brand.ink;
const MUTED = muted(brand.ink);
@@ -318,12 +377,11 @@ const CardBody: React.FC<{
color: INK,
}}
>
- {card.lead}
- {card.emphasis && (
- // The payload word carries the card's one accent. Italic as well
- // would be two ways of saying the same thing.
- <span style={{ color: accent }}> {card.emphasis}</span>
- )}
+ {/* The payload words carry the card's one accent. Italic as well
+ would be two ways of saying the same thing. */}
+ {emphasisRuns(card.lead, card.emphasis).map((run, i) => (
+ <span key={i} style={run.mark ? { color: accent } : undefined}>{run.text}</span>
+ ))}
</div>
{card.sub && (
<div
@@ -531,18 +589,42 @@ const CardBody: React.FC<{
);
}
+ if (bleed && (card.kind === "image" || card.kind === "video")) {
+ return (
+ <BleedMedia
+ card={card} scale={s} brand={brand} fps={fps}
+ topInset={topInset ?? SAFE.top}
+ />
+ );
+ }
+
if (card.kind === "image") {
return (
<>
<Img
src={card.src.startsWith("http") ? card.src : staticFile(card.src)}
style={{
- width: "100%",
+ /*
+ * Shown whole, the element is sized by the picture rather than the
+ * other way round.
+ *
+ * A full-width box with objectFit contain letterboxes inside
+ * itself, and the hairline below then traces the box: a tall
+ * screenshot came out as a thin picture adrift in a wide empty
+ * rectangle. Bounded instead of sized, the element is the picture,
+ * so the line lands on its edge.
+ */
+ ...(card.fit === "fill"
+ ? { width: "100%", objectFit: "cover" as const }
+ : {
+ maxWidth: "100%",
+ alignSelf: "center" as const,
+ objectFit: "contain" as const,
+ }),
// Capped by the room actually left rather than by a number alone:
// captions placed high reserve their band from the same frame, and
// a picture pinned to a fixed height drew over them.
maxHeight: mediaBand("image", room ?? IMAGE_BAND * s, s, Boolean(card.caption)),
- objectFit: card.fit === "fill" ? "cover" : "contain",
borderRadius: 16 * s,
// A screenshot's own edge is often near the surface tone behind it.
// Pure white at a tenth, never a tone borrowed from the palette.
@@ -598,7 +680,7 @@ const CardBody: React.FC<{
color: MUTED,
// Its own inset: the footage above it runs to both edges, and a
// caption that did the same would sit against the frame.
- padding: `0 ${96 * s}px`,
+ padding: `0 ${SAFE.right * s}px 0 ${SAFE.left * s}px`,
marginTop: GAP.tight * s,
}}
>
@@ -686,6 +768,58 @@ const KNOWN_KINDS = new Set([
"image", "video", "scene",
]);
+/**
+ * A preset written out as the blocks it is made of, for measuring only.
+ *
+ * The presets used to be trusted to fit, on the grounds that somebody sized
+ * them. Somebody sized the layout; nobody sized the words, and five bullets or
+ * a quote that runs to nine lines drew straight through the captions and out
+ * the bottom of the frame. A scene has been measured since the day it existed,
+ * so rather than write a second estimator the preset says which blocks it is
+ * and borrows that one.
+ *
+ * Nothing here draws. The kinds that already answer a height of their own,
+ * which is the two that show a file and the scene itself, return null and keep
+ * the arithmetic they have.
+ */
+const presetBlocks = (card: Card): Block[] | null => {
+ const eyebrow: Block[] = "eyebrow" in card && card.eyebrow
+ ? [{ type: "text", text: card.eyebrow, size: "xs" }]
+ : [];
+ switch (card.kind) {
+ case "stat":
+ return [
+ ...eyebrow,
+ { type: "text", text: card.value, size: "xxl" },
+ ...(card.caption ? [{ type: "text", text: card.caption, size: "sm" } as Block] : []),
+ ];
+ case "headline":
+ return [
+ ...eyebrow,
+ { type: "text", text: card.lead, emphasis: card.emphasis, size: "xl" },
+ ...(card.sub ? [{ type: "text", text: card.sub, size: "sm" } as Block] : []),
+ ];
+ case "bullets":
+ return [...eyebrow, { type: "list", items: card.items, size: "md" }];
+ case "compare":
+ return [...eyebrow, { type: "bars", rows: card.rows.slice(0, 3) }];
+ case "change":
+ return [...eyebrow, { type: "steps", points: [card.from, card.to] }];
+ case "share":
+ return [
+ ...eyebrow,
+ { type: "meter", value: card.value, display: card.display },
+ ...(card.caption ? [{ type: "text", text: card.caption, size: "sm" } as Block] : []),
+ ];
+ case "entity":
+ return [...eyebrow, { type: "chip", name: card.name, note: card.note, src: card.src }];
+ case "quote":
+ return [{ type: "quote", text: card.text, attribution: card.attribution, size: "lg" }];
+ default:
+ return null;
+ }
+};
+
/** A block that would put something on screen, rather than an empty group. */
const drawsSomething = (block: Block): boolean =>
(block.type === "group"
@@ -700,10 +834,15 @@ export const Cards: React.FC<{
faceY?: number | null;
faceH?: number | null;
brand?: Brand | null;
-}> = ({ cards, videoSrc, startFrom = 0, style, faceY, faceH, brand }) => {
+ /** How much of the top the logo and the chip have already taken. */
+ topInset?: number;
+}> = ({
+ cards, videoSrc, startFrom = 0, style, faceY, faceH, brand, topInset,
+}) => {
const colours = { ...DEFAULT_BRAND, ...(brand ?? {}) };
const frame = useCurrentFrame();
- const { fps, height } = useVideoConfig();
+ const { fps, height, width } = useVideoConfig();
+ const SAFE = safeFor(width, height);
const s = captionScale(height);
/*
@@ -767,52 +906,183 @@ export const Cards: React.FC<{
// at all, and the fit arithmetic runs before anything has narrowed to one.
const hasCaption = "caption" in card && Boolean(card.caption);
/*
- * A scene keeps the speaker while it can still be read beside one.
+ * A card keeps the speaker while it can still be read beside one.
+ *
+ * Measured for every kind rather than for the scene alone. A card that would
+ * have to be squashed to the floor of the fit takes the whole frame instead
+ * of sharing it at a size nobody reads at arm's length, and that call is the
+ * same call whether the arrangement was named by somebody or arrived as
+ * blocks.
+ */
+ const shape = presetBlocks(card);
+ /*
+ * The measure a preset is actually set to, rather than the scene's.
+ *
+ * A preset fills the padded container, so on a wider frame it wraps later
+ * than SCENE_WIDTH says. Measured at 680 on a landscape clip it came out
+ * far taller than it draws, which shrank the type and could drop the
+ * speaker for a card that had room all along. In portrait the two are the
+ * same number, so nothing moves there.
+ */
+ const contentWidth = width / s - SAFE.left - SAFE.right;
+ const wanted = shape ? sceneHeight(shape, "stack", "tight", contentWidth) : 0;
+ const fitFor = (available: number) =>
+ wanted > 0 ? Math.max(MIN_FIT, Math.min(1, available / s / wanted)) : 1;
+ /** How far this card would have to shrink to sit in a room of this height. */
+ const fitsIn = (available: number) =>
+ (card.kind === "scene"
+ ? fitScene(card.blocks, {
+ layout: card.layout, gap: card.gap, room: available / s,
+ }).fit
+ : fitFor(available));
+ const bodyShares = fitsIn(bodyRoom(room - speakerTakes)) > MIN_FIT;
+ /*
+ * How far down a card written into the shot has to start.
+ *
+ * Nothing else stops it landing on the face. A banded card has a speaker
+ * band above it and a full-frame one has no face to miss; this one is drawn
+ * over the person and would happily print a sentence across their mouth.
+ * The measured eye line plus a chin's worth below it is the floor. Generous
+ * here costs the card the frame: between a high face and a tall caption
+ * style there is little clear frame to begin with, and the fallback fires
+ * on cards that would have fitted.
+ */
+ const HEAD_BELOW_EYES = 0.13;
+ const faceFloor = ((faceY ?? 0.4) + HEAD_BELOW_EYES) * height;
+ const overRoom = Math.min(
+ bodyRoom(room),
+ Math.max(0, height - faceFloor - (captionZone(style) + GAP.section) * s),
+ );
+ /*
+ * Written into the shot rather than laid over it, when the shot has the room.
*
- * The presets know their own height because somebody sized them. An
- * arrangement nobody has seen before is measured instead, and one that would
- * have to be squashed to the floor of the fit takes the whole frame rather
- * than sharing it at a size nobody reads at arm's length.
+ * The speaker is never drawn for one of these: the composition is an overlay
+ * composited onto the clip, so leaving the panel transparent is what shows
+ * the person. Drawing the band as well would put the same face on screen
+ * twice, once cropped and once not.
+ *
+ * It falls back to the panel rather than squeezing. Between a close-up's
+ * chin and a tall caption there can be sixty pixels of clear frame, and a
+ * card drawn at the floor of the fit in sixty pixels is not a quieter
+ * treatment, it is an unreadable one. A panel always has room because it
+ * makes its own.
*/
- const sceneShares = card.kind !== "scene"
- || fitScene(card.blocks, {
- layout: card.layout,
- gap: card.gap,
- room: bodyRoom(room - speakerTakes) / s,
- }).fit > MIN_FIT;
- const withSpeaker = card.speaker !== null
+ const over = card.place === "over" && fitsIn(overRoom) > MIN_FIT;
+ const withSpeaker = !over
+ && card.speaker !== null
&& Boolean(videoSrc)
&& room >= headNeeds
- && sceneShares
+ && bodyShares
&& (!SHOWS_A_FILE.has(card.kind)
|| mediaBand(card.kind, bodyRoom(room - speakerTakes), s, hasCaption)
>= MEDIA_MIN * s);
+ /*
+ * How far the type has to come down to sit inside the band.
+ *
+ * The type shrinks and the width is kept, which is the same move a scene
+ * makes: a card drawn narrower as well as smaller reads as a card that
+ * failed to lay out, where one drawn smaller at the same measure reads as a
+ * card with a lot to say. The estimate it comes from over-states height on
+ * purpose, so the result is a card with a little room to spare rather than
+ * one resting on the caption.
+ */
+ const bodyAvailable = over
+ ? overRoom
+ : bodyRoom(withSpeaker ? room - speakerTakes : room);
+ const bodyFit = fitFor(bodyAvailable);
+ /*
+ * A file takes the whole frame when it was asked to, or when a band would
+ * be too short to be worth one.
+ *
+ * Asked, because a cutaway is an edit rather than a consequence: a card
+ * that keeps its picture in a band on a surface is a legitimate thing to
+ * want, and inferring the cutaway from a dropped speaker took that choice
+ * away. The fallback stays, because the alternative to a band nobody can
+ * read is not a smaller band.
+ *
+ * Never with a speaker still up. A cutaway that leaves the person on screen
+ * is a smaller picture with extra steps.
+ */
+ const bandWouldBe = SHOWS_A_FILE.has(card.kind)
+ ? mediaBand(card.kind, bodyRoom(withSpeaker ? room - speakerTakes : room), s, hasCaption)
+ : 0;
+ const bleeds = SHOWS_A_FILE.has(card.kind)
+ && !withSpeaker
+ && (("bleed" in card && card.bleed === true) || bandWouldBe < MEDIA_MIN * s);
return (
<div
style={{
position: "absolute",
inset: 0,
- backgroundColor: card.background ?? colours.surface,
+ backgroundColor: over ? "transparent" : (card.background ?? colours.surface),
opacity,
display: "flex",
flexDirection: "column",
// The captions are not part of this stack; they are drawn over it.
// Reserving their band as padding is what keeps a card's last line
// from ending up behind the pill.
- paddingBottom: captionZone(style) * s,
+ paddingBottom: bleeds ? 0 : captionZone(style) * s,
}}
>
+ {over && (
+ /*
+ * What a panel was doing for free.
+ *
+ * A card written into the shot has to be readable over whatever the
+ * shot happens to be, and a kitchen window behind a guest is white.
+ * A wash rather than a slab: heavy enough at the bottom that ink and
+ * captions hold, gone by the time it reaches the face, so the thing
+ * the overlay was for is still the shot.
+ */
+ <div
+ style={{
+ position: "absolute", left: 0, right: 0, bottom: 0, height: "62%",
+ background: `linear-gradient(to bottom, transparent, `
+ + `color-mix(in oklab, ${colours.surface} 78%, transparent))`,
+ }}
+ />
+ )}
{withSpeaker && videoSrc && (
- <div style={{ flex: 1, minHeight: SPEAKER_MIN * s, overflow: "hidden" }}>
+ <div
+ style={{
+ flex: 1, minHeight: SPEAKER_MIN * s, overflow: "hidden",
+ position: "relative",
+ }}
+ >
<SpeakerBand src={videoSrc} startFrom={startFrom} faceY={faceY} />
+ {/*
+ * Where the footage stops being footage.
+ *
+ * Without this the two halves meet on a hard line, which on a dark
+ * show hides in the dark bottom of the shot and on a light one cuts
+ * a shoulder in half with a white slab. Neither is a decision
+ * anybody made. A short ramp into the surface reads as the card
+ * being laid over the shot on every brand and every room.
+ */}
+ <div
+ style={{
+ position: "absolute", left: 0, right: 0, bottom: 0,
+ height: SEAM * s,
+ background:
+ `linear-gradient(to bottom, transparent, ${colours.surface})`,
+ }}
+ />
</div>
)}
<div
style={{
- // Footage runs to both edges. An inset would draw it as a picture
- // pasted on a card, where the point is a second half of the frame.
- padding: `${GAP.section * s}px ${(card.kind === "video" ? 0 : 96) * s}px 0`,
+ /*
+ * Wider on the right than on the left, because the app draws its
+ * like, comment and share rail up that side and a bar measured
+ * under it is a bar nobody reads. Footage still runs to both edges:
+ * an inset would draw it as a picture pasted on a card, where the
+ * point is a second half of the frame, and footage losing its outer
+ * ninth to a rail costs nothing a number would not.
+ */
+ padding: bleeds || card.kind === "video"
+ ? `${bleeds ? 0 : GAP.section * s}px 0 0`
+ : `${GAP.section * s}px ${SAFE.right * s}px 0 ${SAFE.left * s}px`,
display: "flex",
flexDirection: "column",
/*
@@ -823,16 +1093,28 @@ export const Cards: React.FC<{
* reads as a card that failed to load. With a speaker the content
* belongs low, because the thing above it is a person and the gap
* between them is what makes the pair read as one shot.
+ *
+ * A file taking the whole frame does neither: it is the frame, so it
+ * stretches rather than sitting anywhere in it.
*/
- marginTop: "auto",
- marginBottom: withSpeaker ? undefined : "auto",
+ ...(bleeds
+ ? { position: "absolute", inset: 0 }
+ : {
+ marginTop: "auto",
+ // Written into the shot, a card belongs low for the same reason a
+ // banded one does: the person is above it. Centred, it reads as a
+ // slide someone forgot to take down.
+ marginBottom: withSpeaker || over ? undefined : "auto",
+ }),
}}
>
<CardBody
card={card}
- scale={s}
+ scale={s * bodyFit}
brand={colours}
- room={bodyRoom(withSpeaker ? room - speakerTakes : room)}
+ room={bodyAvailable}
+ bleed={bleeds}
+ topInset={topInset}
/>
</div>
</div>
diff --git a/remotion/src/components/HormoziCaptions.tsx b/remotion/src/components/HormoziCaptions.tsx
index 89214ab..b52df0c 100644
--- a/remotion/src/components/HormoziCaptions.tsx
+++ b/remotion/src/components/HormoziCaptions.tsx
@@ -55,7 +55,7 @@ export const HormoziCaptions: React.FC<Props> = ({
>
<div
style={{
- backgroundColor: "rgba(0, 0, 0, 0.8)",
+ backgroundColor: style.background ?? "rgba(0, 0, 0, 0.8)",
borderRadius: 16 * s,
padding: `${14 * s}px ${32 * s}px`,
maxWidth: `calc(100% - ${120 * s}px)`,
diff --git a/remotion/src/components/NameCard.tsx b/remotion/src/components/NameCard.tsx
index 798d55b..c0b6704 100644
--- a/remotion/src/components/NameCard.tsx
+++ b/remotion/src/components/NameCard.tsx
@@ -13,6 +13,8 @@ export interface NameCardProps {
background?: string;
color?: string;
accent?: string;
+ /** How far off the bottom it sits, in unscaled units. */
+ bottom?: number;
motion?: Motion;
}
@@ -33,6 +35,7 @@ export const NameCard: React.FC<NameCardProps> = ({
background = "rgba(0,0,0,0.85)",
color = "#FFFFFF",
accent = "#2ED9C3",
+ bottom = 620,
motion,
}) => {
const frame = useCurrentFrame();
@@ -53,7 +56,7 @@ export const NameCard: React.FC<NameCardProps> = ({
style={{
position: "absolute",
left: 0,
- bottom: 620 * s,
+ bottom: bottom * s,
maxWidth: "78%",
padding: `${18 * s}px ${28 * s}px ${16 * s}px`,
background,
diff --git a/remotion/src/components/Scene.tsx b/remotion/src/components/Scene.tsx
index b279cc3..23e5231 100644
--- a/remotion/src/components/Scene.tsx
+++ b/remotion/src/components/Scene.tsx
@@ -6,7 +6,8 @@ import { FONT } from "../types";
import { context, muted, track } from "./brand";
import type { Brand } from "./brand";
import {
- GAP_SIZE, MEDIA_HEIGHT, MIN_FIT, SCENE_WIDTH, TYPE_SIZE, sceneHeight, sizeOf,
+ emphasisRuns, GAP_SIZE, MEDIA_HEIGHT, MIN_FIT, SCENE_WIDTH, TYPE_SIZE, sceneHeight,
+ sizeOf,
} from "../scene";
import type { Align, Block, Gap, Layout, Size, Tone } from "../scene";
@@ -95,8 +96,9 @@ const Piece: React.FC<{ block: Block; paint: Paint }> = ({ block, paint }) => {
textAlign: block.align ?? "start",
}}
>
- {block.text}
- {block.emphasis && <span style={{ color: accent }}> {block.emphasis}</span>}
+ {emphasisRuns(block.text, block.emphasis).map((run, i) => (
+ <span key={i} style={run.mark ? { color: accent } : undefined}>{run.text}</span>
+ ))}
</div>
);
}
diff --git a/remotion/src/components/SubtleCaptions.tsx b/remotion/src/components/SubtleCaptions.tsx
index 3997ea9..12e6f60 100644
--- a/remotion/src/components/SubtleCaptions.tsx
+++ b/remotion/src/components/SubtleCaptions.tsx
@@ -29,12 +29,24 @@ const Line: React.FC<{
style={{
fontFamily: style.fontFamily,
fontSize: style.fontSize * scale,
- fontWeight: 400,
+ fontWeight: style.stroke ? 600 : 400,
color: style.color,
- textShadow:
- "0 1px 3px rgba(0,0,0,0.95), 0 0 20px rgba(0,0,0,0.6), 0 0 50px rgba(0,0,0,0.3)",
+ /*
+ * One legibility trick or the other, never both. A stroked letter over
+ * three stacked shadows reads as mud at the size this style is set at.
+ */
+ ...(style.stroke
+ ? {
+ WebkitTextStrokeWidth: `${style.fontSize * scale * 0.13}px`,
+ WebkitTextStrokeColor: style.stroke,
+ paintOrder: "stroke fill",
+ }
+ : {
+ textShadow:
+ "0 1px 3px rgba(0,0,0,0.95), 0 0 20px rgba(0,0,0,0.6), 0 0 50px rgba(0,0,0,0.3)",
+ }),
textAlign: "center",
- lineHeight: 1.35,
+ lineHeight: style.stroke ? 1.1 : 1.35,
whiteSpace: nowrap ? "nowrap" : undefined,
}}
>
diff --git a/remotion/src/components/TopicChip.tsx b/remotion/src/components/TopicChip.tsx
index 4446005..2606a00 100644
--- a/remotion/src/components/TopicChip.tsx
+++ b/remotion/src/components/TopicChip.tsx
@@ -11,6 +11,14 @@ export interface TopicChipProps {
color?: string;
/** Drawn behind the label. Transparent by default, which is the reference look. */
background?: string;
+ /**
+ * How far off its edge it sits, in unscaled units.
+ *
+ * Passed in rather than fixed, because the logo claims the same corner at
+ * the same inset by default and the two drew through each other. Whoever
+ * knows about both decides; the chip only draws where it is told.
+ */
+ inset?: number;
}
/**
@@ -29,6 +37,7 @@ export const TopicChip: React.FC<TopicChipProps> = ({
position = "top-left",
color = "#FFFFFF",
background = "transparent",
+ inset = LOGO_INSET,
}) => {
const { height } = useVideoConfig();
const s = captionScale(height);
@@ -42,8 +51,8 @@ export const TopicChip: React.FC<TopicChipProps> = ({
style={{
position: "absolute",
...(position.startsWith("top-")
- ? { top: LOGO_INSET * s }
- : { bottom: LOGO_INSET * s }),
+ ? { top: inset * s }
+ : { bottom: inset * s }),
...(position.endsWith("-left")
? { left: LOGO_EDGE * s }
: position.endsWith("-right")
diff --git a/remotion/src/motion.ts b/remotion/src/motion.ts
index e82392d..531733c 100644
--- a/remotion/src/motion.ts
+++ b/remotion/src/motion.ts
@@ -35,6 +35,8 @@ export const MOTION: Record<string, Motion> = {
karaoke: { enter: "none", exit: "none", duration: 0, feel: "linear" },
/** The pill on the active word is the motion; the block holds still. */
branded: { enter: "none", exit: "none", duration: 0, feel: "linear" },
+ /** A line meant to be read as a line. It cuts, the way a subtitle does. */
+ outline: { enter: "none", exit: "none", duration: 0, feel: "linear" },
/**
* Names arrive, hold, and get out of the way.
*
diff --git a/remotion/src/scene.ts b/remotion/src/scene.ts
index c82f458..4afaa11 100644
--- a/remotion/src/scene.ts
+++ b/remotion/src/scene.ts
@@ -1,3 +1,4 @@
+import { SAFE } from "./types";
export type Tone = "ink" | "accent" | "muted" | "context";
export type Size = "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
@@ -28,8 +29,15 @@ export type Block =
| (Common & {
type: "text";
text: string;
- /** Set apart in the card's accent, appended to the text. */
- emphasis?: string;
+ /**
+ * The words set apart in the card's accent.
+ *
+ * A phrase found inside the text is coloured where it stands, so a
+ * sentence can land on two of them without being rewritten. One that is
+ * not in the text is appended instead, which is what this field used to
+ * mean and what an older plan still sends.
+ */
+ emphasis?: string | string[];
size?: Size;
caps?: boolean;
})
@@ -67,7 +75,7 @@ export const GAP_SIZE: Record<Gap, number> = { tight: 14, group: 36, section: 76
export const MEDIA_HEIGHT = { min: 260, max: 540 };
-export const SCENE_WIDTH = 888;
+export const SCENE_WIDTH = 1080 - SAFE.left - SAFE.right;
export const MAX_BLOCKS = 14;
@@ -77,6 +85,67 @@ const DEFAULT_SIZE: Partial<Record<BlockType, Size>> = {
text: "sm", quote: "lg", list: "md",
};
+/** A stretch of a line, and whether it is the part being pointed at. */
+export type Run = { text: string; mark: boolean };
+
+/**
+ * A line split into what is set in ink and what is set in the accent.
+ *
+ * Written once because two things ask and they must not disagree: the
+ * renderer, to colour it, and the estimator, to say how tall it is. A phrase
+ * coloured in place costs no extra characters; one appended costs its own
+ * length, and a card measured under one rule and drawn under the other ends
+ * up behind the captions.
+ *
+ * Matching is case-insensitive and first-occurrence. Two phrases that overlap
+ * do not nest: the first one wins and the second is dropped rather than
+ * printed again at the end.
+ */
+export function emphasisRuns(text: string, emphasis?: string | string[]): Run[] {
+ const phrases = (Array.isArray(emphasis) ? emphasis : emphasis ? [emphasis] : [])
+ .map((phrase) => phrase.trim())
+ .filter(Boolean);
+ if (!phrases.length) return [{ text, mark: false }];
+
+ const runs: Run[] = [{ text, mark: false }];
+ const appended: string[] = [];
+
+ for (const phrase of phrases) {
+ let placed = false;
+ for (let i = 0; i < runs.length && !placed; i++) {
+ const run = runs[i]!;
+ if (run.mark) continue;
+ const at = run.text.toLowerCase().indexOf(phrase.toLowerCase());
+ if (at < 0) continue;
+ const before = run.text.slice(0, at);
+ const after = run.text.slice(at + phrase.length);
+ const parts: Run[] = [];
+ if (before) parts.push({ text: before, mark: false });
+ parts.push({ text: run.text.slice(at, at + phrase.length), mark: true });
+ if (after) parts.push({ text: after, mark: false });
+ runs.splice(i, 1, ...parts);
+ placed = true;
+ }
+ /*
+ * Appended only when the line does not contain it at all. A phrase that is
+ * in the line but already sits inside another mark has been said: adding
+ * it to the end as well would print it twice.
+ */
+ if (!placed && !text.toLowerCase().includes(phrase.toLowerCase())) {
+ appended.push(phrase);
+ }
+ }
+
+ for (const phrase of appended) {
+ runs.push({ text: " ", mark: false }, { text: phrase, mark: true });
+ }
+ return runs;
+}
+
+/** What the line comes to once emphasis has been placed or appended. */
+export const emphasised = (text: string, emphasis?: string | string[]): string =>
+ emphasisRuns(text, emphasis).map((run) => run.text).join("");
+
export const sizeOf = (block: Block): Size =>
("size" in block && block.size ? block.size : DEFAULT_SIZE[block.type] ?? "sm");
@@ -124,7 +193,7 @@ export function blockHeight(block: Block, width: number): number {
switch (block.type) {
case "text": {
const size = TYPE_SIZE[sizeOf(block)];
- const text = block.emphasis ? `${block.text} ${block.emphasis}` : block.text;
+ const text = emphasised(block.text, block.emphasis);
return lines(text, size, width, block.caps ? CAPS_ADVANCE : ADVANCE) * size * LINE;
}
case "quote": {
diff --git a/remotion/src/types.ts b/remotion/src/types.ts
index 4ca70b1..f66f5f6 100644
--- a/remotion/src/types.ts
+++ b/remotion/src/types.ts
@@ -16,7 +16,7 @@ export interface Word {
}
export interface CaptionStyle {
- name: "hormozi" | "karaoke" | "subtle" | "branded";
+ name: "hormozi" | "karaoke" | "subtle" | "branded" | "outline";
fontSize: number;
fontFamily: string;
color: string;
@@ -29,6 +29,24 @@ export interface CaptionStyle {
uppercase: boolean;
wordsPerChunk: number;
marginBottom: number;
+ /**
+ * What a pill behind the words is filled with.
+ *
+ * Black until a show says otherwise, because a caption is read over footage
+ * and black is the one fill that works over all of it. A show that has told
+ * us what its text sits on gets that instead, so the pill over a card is the
+ * card rather than a hole cut in it.
+ */
+ background?: string;
+ /**
+ * What the words are outlined in, when they are outlined rather than boxed.
+ *
+ * A pill guarantees legibility by covering the shot. An outline guarantees
+ * it by making every letter carry its own contrast, which leaves the frame
+ * whole. Drawn behind the fill, so a heavy stroke thickens the letter rather
+ * than eating it.
+ */
+ stroke?: string;
}
export type CaptionPosition = "auto" | "upper" | "center" | "lower";
@@ -53,6 +71,63 @@ export const LOGO_WIDTH = 255;
export const LOGO_HEIGHT = 126;
export const LOGO_CAPTION_GAP = 24;
+/**
+ * The part of the frame the app it plays in has already spent.
+ *
+ * A vertical clip is never watched on its own. YouTube draws a title, a handle
+ * and a link chip across the bottom of it, an action rail up the right, and a
+ * progress bar under both. TikTok and Reels draw the same furniture in the
+ * same two places. None of it is ours and all of it is opaque, so anything we
+ * put there is not a card that came out badly, it is a card nobody ever saw.
+ *
+ * Measured off a Shorts screenshot rather than guessed. On a 9:19.5 phone a
+ * viewer's chrome starts 1498 down a 1920 frame and the rail runs from x 817
+ * to the edge. The bottom leaves 38 clear of that line, which is as low as
+ * the words go before the app starts eating them.
+ */
+export const SAFE = {
+ top: 200,
+ bottom: 460,
+ left: 120,
+ right: 280,
+} as const;
+
+/**
+ * The same reservation for a frame nobody scrolls past.
+ *
+ * A landscape clip plays in a player, not in a feed. There is no handle, no
+ * title and no action rail drawn over it; there is a scrubber that appears on
+ * hover and the edges of a screen it might be letterboxed on. Reserving the
+ * phone's 460 here would spend a quarter of the frame guarding against
+ * furniture that is not there.
+ */
+export const SAFE_WIDE = {
+ top: 90,
+ bottom: 150,
+ left: 120,
+ right: 120,
+} as const;
+
+/**
+ * Which reservation this frame is owed, read off its own shape.
+ *
+ * Portrait is the feed and gets the full chrome. Anything square or wider is
+ * a player and gets the margin a broadcast would use. The composition knows
+ * its size, so nothing has to be told which platform it is for.
+ */
+export const safeFor = (width: number, height: number) =>
+ (width < height ? SAFE : SAFE_WIDE);
+
+/**
+ * How much of the width a phone throws away.
+ *
+ * A 9:16 file on a 9:19.5 screen is filled to the height and cropped at the
+ * sides, so the outer ninth of the frame is off-screen before any chrome is
+ * drawn. `SAFE.left` and `SAFE.right` already cover it; this is the number
+ * they were derived from, kept so the derivation is checkable.
+ */
+export const DEVICE_SIDE_CROP = 96;
+
export interface CaptionProps {
words: Word[];
style: CaptionStyle;
@@ -83,6 +158,25 @@ export const fontStack = (family?: string | null): string =>
export const REFERENCE_HEIGHT = 1920;
export const captionScale = (height: number): number => height / REFERENCE_HEIGHT;
+/**
+ * How many lines of caption everything else gets out of the way of.
+ *
+ * Reserving for the tallest caption costs a card some height on every clip
+ * and costs it nothing on the clip where it matters.
+ */
+export const CAPTION_LINES = 3;
+
+/**
+ * The band the captions own, in reference units.
+ *
+ * Read off the style rather than fixed, because a style's size and margin are
+ * the only things that decide it. Lives here because four things need to
+ * clear it: the card, the name card, the logo and the chip, and a number
+ * copied into four files is a number that drifts in three of them.
+ */
+export const captionZone = (style: CaptionStyle) =>
+ style.marginBottom + style.fontSize * CAPTION_LINES * 1.2 + 36;
+
export const STYLES: Record<string, CaptionStyle> = {
hormozi: {
name: "hormozi",
@@ -128,4 +222,56 @@ export const STYLES: Record<string, CaptionStyle> = {
wordsPerChunk: 3,
marginBottom: 420,
},
+ /**
+ * A whole sentence at a time, outlined, over an uncovered frame.
+ *
+ * The one every serious interview channel converges on, because it is the
+ * only caption that stays readable without taking anything from the shot.
+ * More words per chunk than the rest: the point is a line somebody reads,
+ * not a word that lands.
+ */
+ outline: {
+ name: "outline",
+ fontSize: 96,
+ fontFamily: FONT,
+ color: "#FFFFFF",
+ activeColor: "#FFFFFF",
+ emphasisColor: "#3B9CFF",
+ stroke: "#000000",
+ uppercase: false,
+ wordsPerChunk: 7,
+ marginBottom: 460,
+ },
+};
+
+/**
+ * The caption styles, in the show's own colours.
+ *
+ * A style ships with a palette because it has to look like something before
+ * anybody has picked anything. Left at that, every clip carried two accents:
+ * the show's on the card and the style's in the captions, a yellow sweep under
+ * a green figure, and a colour that means two things means neither.
+ *
+ * Each style keeps its character and loses its palette. Hormozi is the loud
+ * one, so the word being spoken takes the accent; the quieter three set the
+ * spoken word in ink and spend the accent only on a word worth reading with
+ * the sound off. The pill becomes the show's surface, which is what makes a
+ * caption over a card read as part of it.
+ */
+export const brandCaptions = (
+ style: CaptionStyle,
+ brand?: { accent: string; ink: string; surface: string } | null,
+): CaptionStyle => {
+ if (!brand) return style;
+ return {
+ ...style,
+ color: style.name === "karaoke"
+ ? `color-mix(in oklab, ${brand.ink} 40%, transparent)`
+ : brand.ink,
+ activeColor: style.name === "hormozi" ? brand.accent : brand.ink,
+ emphasisColor: brand.accent,
+ background: `color-mix(in oklab, ${brand.surface} 85%, transparent)`,
+ // Opaque, unlike the pill: a stroke at 85% is a grey halo, not an edge.
+ ...(style.stroke ? { stroke: brand.surface } : {}),
+ };
};