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
The logo goes on every clip, the outro plays whole, and a guest has a name (#148)
Nika Siradze9607f204648f
diff --git a/backend/cli.py b/backend/cli.pyindex 057cfc8..dc6a9eb 100644--- a/backend/cli.py+++ b/backend/cli.py@@ -576,6 +576,15 @@ def cmd_process(args):config["format"] = args.formatif getattr(args, "profile", None):config["profile"] = args.profile+ if getattr(args, "name_card", None):+ config["name_card"] = {+ "title": args.name_card,+ "subtitle": getattr(args, "name_card_sub", None),+ "seconds": getattr(args, "name_card_seconds", None),+ "accent": getattr(args, "name_card_accent", None),+ }+ if getattr(args, "bookend_fade", None) is not None:+ config["bookend_fade"] = args.bookend_fadeif getattr(args, "thumbnails", None) is not None:config["generate_thumbnails"] = args.thumbnailsif args.top:@@ -1056,6 +1065,8 @@ def cmd_process(args):logo_path=config.get("logo_path") or None,outro_path=config.get("outro_path") or None,intro_path=config.get("intro_path") or None,+ name_card=config.get("name_card"),+ bookend_fade=config.get("bookend_fade", 0.0),keep_segments=clip.get("segments"),face_map=face_map,allow_ass_fallback=config.get("allow_ass_fallback", False),@@ -1274,6 +1285,8 @@ def cmd_process(args):face_map=face_map,allow_ass_fallback=config.get("allow_ass_fallback", False),use_ass_captions=config.get("use_ass_captions", False),+ name_card=config.get("name_card"),+ bookend_fade=config.get("bookend_fade", 0.0),)results[-1] = resultprint(f" ✓ Re-rendered: {result['file_size_mb']}MB")@@ -3990,6 +4003,16 @@ def main():proc.add_argument("--profile", choices=["podcast", "party", "action"], help="Detection profile: podcast (transcript-first, default), party/action (laughter/energy highlights)")proc.add_argument("--logo", help="Logo image (asset name or path)")proc.add_argument("--outro", help="Outro video (asset name or path)")+ proc.add_argument("--name-card", dest="name_card",+ help="Lower third naming the speaker, shown for the first seconds")+ proc.add_argument("--name-card-sub", dest="name_card_sub",+ help="Second line of the lower third")+ proc.add_argument("--name-card-seconds", dest="name_card_seconds", type=float,+ help="How long the lower third holds (default 3)")+ proc.add_argument("--name-card-accent", dest="name_card_accent",+ help="Underline colour on the lower third")+ proc.add_argument("--bookend-fade", dest="bookend_fade", type=float, default=None,+ help="Seconds of crossfade into an intro or outro (default 0, a cut)")proc.add_argument("--no-outro", action="store_true", help="Do not append an outro (default for highlight profiles)")proc.add_argument("--intro", help="Intro video (asset name or path)")proc.add_argument("--time-adjust", type=float, help="Timestamp offset in seconds")diff --git a/backend/config/caption_styles.py b/backend/config/caption_styles.pyindex e0ae80b..edf4276 100644--- a/backend/config/caption_styles.py+++ b/backend/config/caption_styles.py@@ -74,7 +74,6 @@ STYLES = {"words_per_chunk": 3, # Show 3 words at a time"uppercase": True,"gradient_overlay": False,- "logo_support": False,},"karaoke": {"description": "Full sentence visible, words highlight progressively",@@ -92,7 +91,6 @@ STYLES = {"words_per_chunk": 5,"uppercase": False,"gradient_overlay": False,- "logo_support": False,},"subtle": {"description": "Clean white text at bottom with shadow, professional look",@@ -110,7 +108,6 @@ STYLES = {"words_per_chunk": 5,"uppercase": False,"gradient_overlay": False,- "logo_support": False,},"branded": {"description": "Large bold text, 5-7 words wrapping across 2 lines, dark rounded pill on active word. Clean, no gradient.",@@ -134,7 +131,6 @@ STYLES = {"uppercase": False, # Mixed case, natural capitalization"gradient_overlay": False, # No gradient — clean direct-on-video"gradient_opacity": 0.0,- "logo_support": True, # Logo top-left"logo_margin_x": 40, # Logo X offset from left"logo_margin_y": 60, # Logo Y offset from top"logo_height": 100, # Logo height in pxdiff --git a/backend/services/clip_generator.py b/backend/services/clip_generator.pyindex b9118be..d40933c 100644--- a/backend/services/clip_generator.py+++ b/backend/services/clip_generator.py@@ -465,6 +465,7 @@ def _render_with_remotion(output_path: str,time_offset: float = 0.0,logo_path: Optional[str] = None,+ name_card: Optional[dict] = None,keep_caption_overlay: bool = False,caption_position: str = "auto",caption_font_scale: int = 100,@@ -596,6 +597,14 @@ def _render_with_remotion(]if logo_path and os.path.exists(logo_path):cmd.extend(["--logo", os.path.abspath(logo_path)])+ if name_card and name_card.get("title"):+ cmd.extend(["--name-card", str(name_card["title"])])+ if name_card.get("subtitle"):+ cmd.extend(["--name-card-sub", str(name_card["subtitle"])])+ if name_card.get("seconds"):+ cmd.extend(["--name-card-seconds", str(name_card["seconds"])])+ if name_card.get("accent"):+ cmd.extend(["--name-card-accent", str(name_card["accent"])])if keep_caption_overlay:cmd.append("--keep-overlay")@@ -661,6 +670,8 @@ def generate_clip(logo_path: Optional[str] = None,outro_path: Optional[str] = None,intro_path: Optional[str] = None,+ name_card: Optional[dict] = None,+ bookend_fade: float = 0.0,clean_fillers: bool = True,keep_segments: list[dict] = None,trim_opening: Optional[bool] = None,@@ -886,6 +897,21 @@ def generate_clip(else:fit_to_frame(segment_path, cropped_path, target_dims=spec.dims)+ # Only Remotion draws the name card, and it is reached only when there+ # are words to caption. Refusing beats returning a clip that quietly+ # lacks the overlay that was asked for.+ if name_card and name_card.get("title"):+ if use_ass_captions or allow_ass_fallback:+ raise ValueError(+ "A name card can only be drawn by the Remotion renderer. "+ "Drop --name-card, or drop --fast and --allow-ass-fallback."+ )+ if not transcript_words:+ raise ValueError(+ "A name card needs the caption renderer, which only runs when "+ "there is a transcript. Drop --name-card for an uncaptioned render."+ )+# Step 3: Render captions (Remotion-first; ASS fallback optional)if transcript_words:if progress_callback:@@ -918,7 +944,8 @@ def generate_clip(caption_style=caption_style,output_path=captioned_path,time_offset=caption_time_offset,- logo_path=logo_path if (style_config.get("logo_support", False) and logo_path) else None,+ logo_path=logo_path or None,+ name_card=name_card,keep_caption_overlay=keep_caption_overlay,caption_position=caption_position,caption_font_scale=caption_font_scale,@@ -945,7 +972,7 @@ def generate_clip(use_gradient = style_config.get("gradient_overlay", False)gradient_opacity = style_config.get("gradient_opacity", 0.6)- use_logo = style_config.get("logo_support", False) and logo_path+ use_logo = bool(logo_path)burn_captions(input_path=cropped_path,@@ -985,7 +1012,8 @@ def generate_clip(intro_scaled = os.path.join(work_dir, "intro_scaled.mp4")scale_to_frame(intro_path, intro_scaled, cw, ch)with_intro_path = os.path.join(work_dir, "with_intro.mp4")- concat_outro(intro_scaled, final_video_path, with_intro_path)+ concat_outro(intro_scaled, final_video_path, with_intro_path,+ crossfade_duration=bookend_fade)final_video_path = with_intro_pathif outro_path and os.path.exists(outro_path):@@ -993,7 +1021,8 @@ def generate_clip(progress_callback(85, f"Adding outro ({total_steps}/{total_steps})")with_outro_path = os.path.join(work_dir, "with_outro.mp4")- concat_outro(final_video_path, outro_path, with_outro_path)+ concat_outro(final_video_path, outro_path, with_outro_path,+ crossfade_duration=bookend_fade)final_video_path = with_outro_path# Step 6: Move to outputdiff --git a/remotion/render.mjs b/remotion/render.mjsindex 2ac57e9..d4efbb8 100644--- a/remotion/render.mjs+++ b/remotion/render.mjs@@ -150,12 +150,24 @@ async function main() {const durationSec = videoDuration || (lastWord ? lastWord.end + 0.5 : 30);const durationInFrames = Math.ceil(durationSec * fps);+ // Who is speaking, for the lower third. Sent whole so the composition takes+ // one prop rather than six loose ones.+ const nameCard = opts["name-card"]+ ? {+ title: opts["name-card"],+ subtitle: opts["name-card-sub"] || undefined,+ seconds: opts["name-card-seconds"] ? parseFloat(opts["name-card-seconds"]) : undefined,+ accent: opts["name-card-accent"] || undefined,+ }+ : null;+const inputProps = {videoSrc,words,styleName,logoSrc,faceY,+ nameCard,durationInFrames,fps,captionPosition: opts["caption-position"] || "auto",diff --git a/remotion/src/CaptionedClip.tsx b/remotion/src/CaptionedClip.tsxindex d29e9e1..c19111e 100644--- a/remotion/src/CaptionedClip.tsx+++ b/remotion/src/CaptionedClip.tsx@@ -1,9 +1,12 @@import React from "react";-import { AbsoluteFill } from "remotion";+import { AbsoluteFill, useVideoConfig } from "remotion";import { HormoziCaptions } from "./components/HormoziCaptions";import { KaraokeCaptions } from "./components/KaraokeCaptions";import { SubtleCaptions } from "./components/SubtleCaptions";import { BrandedCaptions } from "./components/BrandedCaptions";+import { NameCard } from "./components/NameCard";+import type { NameCardProps } from "./components/NameCard";+import { Watermark } from "./components/Watermark";import type { Word, CaptionStyle, CaptionPosition, LogoPosition } from "./types";export interface CaptionedClipProps {@@ -12,6 +15,8 @@ export interface CaptionedClipProps {style: CaptionStyle;logoSrc?: string;faceY?: number | null;+ /** Who is speaking, shown for the first few seconds. */+ nameCard?: NameCardProps | null;captionPosition?: CaptionPosition;logoPosition?: LogoPosition;singleLine?: boolean;@@ -22,10 +27,12 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({style,logoSrc,faceY,+ nameCard,captionPosition = "auto",logoPosition = "top-left",singleLine = false,}) => {+ const { height } = useVideoConfig();const CaptionComponent = {hormozi: HormoziCaptions,karaoke: KaraokeCaptions,@@ -35,12 +42,14 @@ export const CaptionedClip: React.FC<CaptionedClipProps> = ({return (<AbsoluteFill style={{ backgroundColor: "transparent" }}>+ <Watermark src={logoSrc} height={height} position={logoPosition} />{style.name === "branded" ? (<BrandedCaptions words={words} style={style} logoSrc={logoSrc} faceY={faceY}captionPosition={captionPosition} logoPosition={logoPosition} singleLine={singleLine} />) : (<CaptionComponent words={words} style={style} singleLine={singleLine} />)}+ {nameCard?.title && <NameCard {...nameCard} />}</AbsoluteFill>);};diff --git a/remotion/src/Root.tsx b/remotion/src/Root.tsxindex ca1545e..34d5e85 100644--- a/remotion/src/Root.tsx+++ b/remotion/src/Root.tsx@@ -46,6 +46,14 @@ const inputProps = getInputProps() as {bookendPlatforms?: string[];bookendBg?: string;bookendAccent?: string;+ nameCard?: {+ title: string;+ subtitle?: string;+ seconds?: number;+ background?: string;+ color?: string;+ accent?: string;+ } | null;};export const RemotionRoot: React.FC = () => {@@ -80,6 +88,7 @@ export const RemotionRoot: React.FC = () => {style,logoSrc: inputProps.logoSrc,faceY: inputProps.faceY ?? null,+ nameCard: inputProps.nameCard ?? null,captionPosition,logoPosition: inputProps.logoPosition || "top-left",singleLine: inputProps.singleLine === true,diff --git a/remotion/src/components/BrandedCaptions.tsx b/remotion/src/components/BrandedCaptions.tsxindex b69162c..ef412e5 100644--- a/remotion/src/components/BrandedCaptions.tsx+++ b/remotion/src/components/BrandedCaptions.tsx@@ -3,16 +3,17 @@ import {useCurrentFrame,useVideoConfig,spring,- Img,- staticFile,} from "remotion";import type { Word, CaptionStyle, CaptionPosition, LogoPosition } from "../types";import { captionScale } from "../types";import { buildChunks, activeChunkAt, splitCaptionLines } from "../chunks";+import { LOGO_CAPTION_GAP, LOGO_HEIGHT, LOGO_INSET } from "./Watermark";interface Props {words: Word[];style: CaptionStyle;+ // The logo is drawn by Watermark now, but the caption margin still has to+ // know it is there.logoSrc?: string;faceY?: number | null; // normalized 0-1 (0=top, 1=bottom)captionPosition?: CaptionPosition;@@ -22,12 +23,6 @@ interface Props {const MAX_CHARS_PER_CHUNK = 18;-// Unscaled logo box, shared by the logo style and the caption-margin guard so-// the two cannot drift apart.-const LOGO_INSET = 180;-const LOGO_HEIGHT = 126;-const LOGO_CAPTION_GAP = 24;-/*** Active pill rendered as an absolutely positioned background behind the word.* The word itself is always rendered as plain inline text so layout doesn't shift.@@ -161,24 +156,6 @@ export const BrandedCaptions: React.FC<Props> = ({return (<>- {logoSrc && (- <Img- src={logoSrc.startsWith("http") ? logoSrc : staticFile(logoSrc)}- style={{- position: "absolute",- ...(logoPosition.startsWith("top-") ? { top: LOGO_INSET * s } : { bottom: LOGO_INSET * s }),- ...(logoPosition.endsWith("-left")- ? { left: 108 * s }- : logoPosition.endsWith("-right")- ? { right: 108 * s }- : { left: "50%", transform: "translateX(-50%)" }),- width: 255 * s,- height: LOGO_HEIGHT * s,- objectFit: "contain",- }}- />- )}-{activeChunk && (() => {const [line1, line2] = splitCaptionLines(activeChunk.words, 2, singleLine);diff --git a/remotion/src/components/NameCard.tsx b/remotion/src/components/NameCard.tsxnew file mode 100644index 0000000..5038280--- /dev/null+++ b/remotion/src/components/NameCard.tsx@@ -0,0 +1,94 @@+import React from "react";+import { useCurrentFrame, useVideoConfig } from "remotion";+import { captionScale } from "../types";+import { fadeInOut } from "../motion";++export interface NameCardProps {+ /** Who is speaking, and what they are. One line each. */+ title: string;+ subtitle?: string;+ /** How long it stays, from the top of the clip. */+ seconds?: number;+ background?: string;+ color?: string;+ accent?: string;+}++/**+ * The lower third that says who this is.+ *+ * A clip lifted out of an hour of conversation opens on a stranger. Every+ * show solves it the same way and podcli had no answer at all, so the name+ * card was drawn somewhere else and burned in by hand.+ *+ * Anchored to the bottom rather than centred, sized off the composition the+ * way captions are, and gone by the time anyone would tire of it.+ */+export const NameCard: React.FC<NameCardProps> = ({+ title,+ subtitle,+ seconds = 3,+ background = "rgba(0,0,0,0.85)",+ color = "#FFFFFF",+ accent = "#2ED9C3",+}) => {+ const frame = useCurrentFrame();+ const { fps, height } = useVideoConfig();+ const s = captionScale(height);++ if (!title) return null;+ if (frame >= seconds * fps) return null;++ // fadeInOut returns the rising half only when the ramps do not fit inside+ // `seconds`, so opacity alone never brings the card back down.+ const ramp = Math.min(8, Math.floor((seconds * fps) / 2));+ const opacity = fadeInOut({+ frame, fps, start: 0, end: seconds, inFrames: ramp, outFrames: Math.min(10, ramp),+ });+ if (opacity <= 0) return null;++ return (+ <div+ style={{+ position: "absolute",+ left: 0,+ bottom: 620 * s,+ maxWidth: "78%",+ padding: `${18 * s}px ${28 * s}px ${16 * s}px`,+ background,+ borderBottom: `${10 * s}px solid ${accent}`,+ opacity,+ // Rises the last few pixels as it arrives, which reads as arriving+ // rather than appearing.+ transform: `translateY(${(1 - opacity) * 12 * s}px)`,+ }}+ >+ <div+ style={{+ fontFamily: "'DM Sans', sans-serif",+ fontSize: 44 * s,+ fontWeight: 700,+ lineHeight: 1.2,+ color,+ }}+ >+ {title}+ </div>+ {subtitle && (+ <div+ style={{+ fontFamily: "'DM Sans', sans-serif",+ fontSize: 38 * s,+ fontWeight: 400,+ lineHeight: 1.25,+ marginTop: 4 * s,+ color,+ opacity: 0.85,+ }}+ >+ {subtitle}+ </div>+ )}+ </div>+ );+};diff --git a/remotion/src/components/SubtleCaptions.tsx b/remotion/src/components/SubtleCaptions.tsxindex e7cc1fa..1bd878e 100644--- a/remotion/src/components/SubtleCaptions.tsx+++ b/remotion/src/components/SubtleCaptions.tsx@@ -3,6 +3,7 @@ import { useCurrentFrame, useVideoConfig, interpolate } from "remotion";import type { Word, CaptionStyle } from "../types";import { captionScale } from "../types";import { buildChunks, activeChunkAt, splitCaptionLines } from "../chunks";+import { fadeInOut } from "../motion";interface Props {words: Word[];@@ -26,12 +27,9 @@ export const SubtleCaptions: React.FC<Props> = ({ words, style, singleLine = falif (!activeChunk) return null;const entryFrame = Math.round(activeChunk.start * fps);- const opacity = interpolate(- frame - entryFrame,- [0, 5],- [0, 1],- { extrapolateRight: "clamp" }- );+ const opacity = fadeInOut({+ frame, fps, start: activeChunk.start, end: activeChunk.end, inFrames: 5, outFrames: 5,+ });// Slight upward slide on entryconst translateY = interpolate(diff --git a/remotion/src/components/Watermark.tsx b/remotion/src/components/Watermark.tsxnew file mode 100644index 0000000..53af0ea--- /dev/null+++ b/remotion/src/components/Watermark.tsx@@ -0,0 +1,46 @@+import React from "react";+import { Img, staticFile } from "remotion";+import type { LogoPosition } from "../types";+import { captionScale } from "../types";++// Unscaled logo box, shared with BrandedCaptions' caption-margin guard so the+// mark and the gap left for it cannot drift apart.+export const LOGO_INSET = 180;+export const LOGO_HEIGHT = 126;+export const LOGO_CAPTION_GAP = 24;++/**+ * The show's logo, on every clip.+ *+ * It used to live inside the branded caption component, which meant `--logo`+ * did nothing at all on the other three styles: the flag was accepted, the+ * file was resolved, and the renderer dropped it. Same position and size as+ * before, one level up, so a branded render is unchanged and the rest finally+ * carry the mark they were told to.+ */+export const Watermark: React.FC<{+ src?: string;+ height: number;+ position?: LogoPosition;+}> = ({ src, height, position = "top-left" }) => {+ if (!src) return null;+ const s = captionScale(height);++ return (+ <Img+ src={src.startsWith("http") ? src : staticFile(src)}+ style={{+ position: "absolute",+ ...(position.startsWith("top-") ? { top: LOGO_INSET * s } : { bottom: LOGO_INSET * s }),+ ...(position.endsWith("-left")+ ? { left: 108 * s }+ : position.endsWith("-right")+ ? { right: 108 * s }+ : { left: "50%", transform: "translateX(-50%)" }),+ width: 255 * s,+ height: LOGO_HEIGHT * s,+ objectFit: "contain",+ }}+ />+ );+};diff --git a/remotion/src/motion.ts b/remotion/src/motion.tsnew file mode 100644index 0000000..8ea4c15--- /dev/null+++ b/remotion/src/motion.ts@@ -0,0 +1,42 @@+import { interpolate } from "remotion";++/**+ * Fade a thing in when it arrives and out before it leaves.+ *+ * Captions faded in and then cut, which reads as a flicker at every chunk+ * boundary: the outgoing line vanishes on the same frame the incoming one+ * starts at zero. Ramping the tail down inside the chunk's own window turns+ * that into a crossfade without moving a single caption timing.+ *+ * The out ramp is skipped on a chunk too short to hold full opacity, since a+ * line that fades in and straight back out never reads at all.+ */+export function fadeInOut({+ frame, fps, start, end, inFrames = 5, outFrames = 5,+}: {+ frame: number;+ fps: number;+ /** Seconds, on the composition's clock. */+ start: number;+ end: number;+ inFrames?: number;+ outFrames?: number;+}): number {+ const startFrame = Math.round(start * fps);+ const endFrame = Math.round(end * fps);++ const rising = interpolate(frame - startFrame, [0, inFrames], [0, 1], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });++ const held = endFrame - startFrame;+ if (!outFrames || held < inFrames + outFrames + 2) return rising;++ const falling = interpolate(frame, [endFrame - outFrames, endFrame], [1, 0], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ });++ return Math.min(rising, falling);+}diff --git a/tests/test_clip_generator.py b/tests/test_clip_generator.pyindex 2aca949..b6ef7ee 100644--- a/tests/test_clip_generator.py+++ b/tests/test_clip_generator.py@@ -41,6 +41,70 @@ class ClipGeneratorTests(unittest.TestCase):self.assertTrue(expected.endswith("_captions.mov"))self.assertIn("captioned", expected)+ def _render_args(self, **kwargs):+ """The argv one Remotion render was invoked with."""+ real_exists = os.path.exists+ ok = subprocess.CompletedProcess(args=["node"], returncode=0, stdout="", stderr="")++ with tempfile.TemporaryDirectory() as td:+ video_path = os.path.join(td, "video.mp4")+ output_path = os.path.join(td, "captioned.mp4")+ logo_path = os.path.join(td, "logo.png")+ for path in (video_path, logo_path):+ with open(path, "wb"):+ pass++ with mock.patch.object(cg.os.path, "exists", side_effect=self._fake_exists(real_exists)), \+ mock.patch.object(cg.shutil, "which", return_value="/usr/bin/node"), \+ mock.patch("subprocess.run", return_value=ok) as mock_run:+ cg._render_with_remotion(+ video_path=video_path,+ words=[{"word": "hello", "start": 0.0, "end": 0.5}],+ output_path=output_path,+ logo_path=logo_path,+ **kwargs,+ )++ for call in mock_run.call_args_list:+ argv = call.args[0] if call.args else call.kwargs.get("args", [])+ if any(str(part).endswith("render.mjs") for part in argv):+ return [str(part) for part in argv]+ return []++ def test_logo_reaches_the_renderer_whatever_the_caption_style(self):+ """A logo belongs to the show, not to one caption style.++ `--logo` was accepted, resolved and then dropped for every style except+ branded, so three of the four rendered no watermark at all.+ """+ for style in ("branded", "hormozi", "karaoke", "subtle"):+ argv = self._render_args(caption_style=style)+ self.assertIn("--logo", argv, f"{style} lost the logo")++ def test_no_caption_style_gates_the_logo(self):+ """The gate that dropped it lived in the style config, so guard that.++ Every style carried `logo_support`, and only branded said true. A logo+ is the show's; if a per-style opt-out comes back, three quarters of+ renders silently lose their watermark again.+ """+ from config.caption_styles import STYLES++ for name, config in STYLES.items():+ self.assertNotIn(+ "logo_support", config,+ f"{name} decides whether the show's logo is drawn",+ )++ def test_name_card_reaches_the_renderer(self):+ argv = self._render_args(+ caption_style="subtle",+ name_card={"title": "Jamie Gull", "subtitle": "Wave Function Ventures"},+ )+ self.assertIn("--name-card", argv)+ self.assertIn("Jamie Gull", argv)+ self.assertIn("--name-card-sub", argv)+def test_remotion_runtime_failure_does_not_disable_future_clips(self):real_exists = os.path.existsfail_result = subprocess.CompletedProcess(