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
fix: split-screen instant cut, undefined cluster_radius, tighter clip selection
Nika Siradze42499673d6bf
diff --git a/backend/cli.py b/backend/cli.pyindex 1f20bac..dc26206 100644--- a/backend/cli.py+++ b/backend/cli.py@@ -1076,6 +1076,70 @@ def cmd_thumbnails(args):print(f" {gray}Edit .podcli/thumbnail-config.json to customize colors, fonts, layout.{reset}\n")+def cmd_cache(args):+ """Manage transcription cache."""+ cache_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".podcli", "cache")++ accent = "\033[38;2;212;135;74m"+ gray = "\033[38;5;245m"+ green = "\033[38;2;74;222;128m"+ bold = "\033[1m"+ reset = "\033[0m"++ action = getattr(args, "cache_action", None) or "status"++ if action == "clear":+ if os.path.exists(cache_dir):+ import shutil+ count = len([f for f in os.listdir(cache_dir) if f.endswith(".json")])+ shutil.rmtree(cache_dir)+ print(f"\n {green}✓{reset} Cleared {count} cached transcription(s)")+ else:+ print(f"\n {gray}Cache is already empty{reset}")+ print()+ return++ # Status (default)+ print(f"\n {bold}Transcription Cache{reset}")+ print(f" {'─' * 35}")++ if not os.path.exists(cache_dir):+ print(f" {gray}Empty — no cached transcriptions{reset}\n")+ return++ files = [f for f in os.listdir(cache_dir) if f.endswith(".json")]+ if not files:+ print(f" {gray}Empty — no cached transcriptions{reset}\n")+ return++ total_size = 0+ for fname in files:+ fpath = os.path.join(cache_dir, fname)+ size = os.path.getsize(fpath)+ total_size += size++ # Try to read the cached file to show what video it's for+ try:+ with open(fpath) as f:+ data = json.load(f)+ n_words = len(data.get("words", []))+ n_segs = len(data.get("segments", []))+ lang = data.get("language", "?")+ mtime = os.path.getmtime(fpath)+ import datetime+ age = datetime.datetime.fromtimestamp(mtime).strftime("%b %d %H:%M")+ print(f" {accent}•{reset} {n_segs} segments, {n_words} words, {lang} {gray}({size/1024:.0f}KB, {age}){reset}")+ except Exception:+ print(f" {accent}•{reset} {fname} {gray}({size/1024:.0f}KB){reset}")++ print(f" {'─' * 35}")+ if total_size > 1024 * 1024:+ print(f" Total: {bold}{total_size / (1024*1024):.1f}MB{reset} ({len(files)} file{'s' if len(files) != 1 else ''})")+ else:+ print(f" Total: {bold}{total_size / 1024:.0f}KB{reset} ({len(files)} file{'s' if len(files) != 1 else ''})")+ print(f" {gray}Run {accent}podcli cache clear{reset} {gray}to delete all{reset}\n")++def cmd_info(args):"""Show system info."""from services.encoder import get_encoder_info@@ -1152,10 +1216,17 @@ def print_banner():print(f" {bold}podcli{reset} v{VERSION}")+ # Cache info+ cache_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".podcli", "cache")+ cache_count = 0+ if os.path.isdir(cache_dir):+ cache_count = len([f for f in os.listdir(cache_dir) if f.endswith(".json")])+# Status — one lineclaude_tag = f"{green}✓{reset}" if claude_path else f"{yellow}✗{reset}"speaker_tag = f"{green}✓{reset}" if speakers_ok else f"{yellow}✗{reset}"- print(f" {gray}Encoder {green}{encoder_label}{reset} {gray}· Claude {claude_tag} {gray}· Speakers {speaker_tag} {gray}· Knowledge {green}{kb_count}{reset}")+ cache_tag = f"{green}{cache_count}{reset}" if cache_count else f"{gray}0{reset}"+ print(f" {gray}Encoder {green}{encoder_label}{reset} {gray}· Claude {claude_tag} {gray}· Speakers {speaker_tag} {gray}· Cache {cache_tag}{reset}")# Assets — one line if anytry:@@ -1201,6 +1272,7 @@ def print_help():print(f" {accent}assets{reset} {gray}<action>{reset} Manage logos, intros, outros")print(f" {accent}presets{reset} {gray}<action>{reset} Save/load rendering presets")print(f" {accent}thumbnails{reset} {gray}<title>{reset} Generate thumbnail variations")+ print(f" {accent}cache{reset} {gray}[clear]{reset} Show/clear transcription cache")print(f" {accent}info{reset} Show system info (encoder, codecs)")print()print(f" {bold}Process options:{reset}")@@ -1312,6 +1384,12 @@ def main():thumb.add_argument("--logo", help="Logo (asset name or path)")thumb.add_argument("-n", "--variations", type=int, default=3, help="Number of variations")+ # ── cache ──+ cache_p = sub.add_parser("cache", help="Manage transcription cache")+ cache_sub = cache_p.add_subparsers(dest="cache_action")+ cache_sub.add_parser("status", help="Show cache size and contents")+ cache_sub.add_parser("clear", help="Delete all cached transcriptions")+# ── info ──sub.add_parser("info", help="Show system info (encoder, etc.)")@@ -1331,6 +1409,8 @@ def main():cmd_presets(args)elif args.command == "assets":cmd_assets(args)+ elif args.command == "cache":+ cmd_cache(args)elif args.command == "info":cmd_info(args)else:@@ -1354,6 +1434,7 @@ def interactive_menu():print(f" {accent}1{reset} Process a video → shorts + content package")print(f" {accent}2{reset} Open Web UI")print(f" {accent}3{reset} Manage assets")+ print(f" {accent}4{reset} Cache {gray}(view/clear transcription cache){reset}")print(f" {accent}q{reset} Quit")print()@@ -1371,12 +1452,16 @@ def interactive_menu():print(f"\n {gray}Starting Web UI...{reset}\n")import subprocess as spsp.run(["npm", "run", "ui"], cwd=os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))+ interactive_menu()elif choice == "3":_interactive_assets()- elif choice in ("q", "Q", ""):+ interactive_menu()+ elif choice == "4":+ _interactive_cache()+ elif choice in ("q", "Q"):returnelse:- print(f"\n {gray}Unknown option.{reset}\n")+ interactive_menu()def _clean_path(val):@@ -1592,6 +1677,28 @@ def _interactive_process():sys.exit(exit_code)+def _interactive_cache():+ """Interactive cache management."""+ import argparse as _ap+ # Show status first+ cmd_cache(_ap.Namespace(cache_action=None))++ accent = "\033[38;2;212;135;74m"+ gray = "\033[38;5;245m"+ reset = "\033[0m"++ try:+ choice = input(f" {gray}Clear cache? (y/n/enter=back){reset} {accent}▸{reset} ").strip().lower()+ except (EOFError, KeyboardInterrupt):+ print()+ return interactive_menu()++ if choice in ("y", "yes"):+ cmd_cache(_ap.Namespace(cache_action="clear"))++ interactive_menu()++def _interactive_assets():"""Interactive asset management."""from services.asset_store import register, unregister, list_assetsdiff --git a/backend/services/claude_suggest.py b/backend/services/claude_suggest.pyindex 3afa50e..06b739c 100644--- a/backend/services/claude_suggest.py+++ b/backend/services/claude_suggest.py@@ -69,6 +69,15 @@ DURATION RULES (CRITICAL):- Minimum: 20 seconds (too short = no value)- If a moment runs longer than 50 seconds, find a tighter cut point+CUTTING RULES (CRITICAL):+- Cut TIGHT. Every second must earn its place.+- Start at the exact moment the hook hits — no preamble, no "so", no "well"+- End the INSTANT the point lands — don't let it trail off+- If the speaker rambles before making a point, start AFTER the ramble+- If there's filler/tangent in the middle, pick the tighter segment that preserves the core idea+- The transcript timestamps are your scalpel — use them precisely+- A 30s clip with zero dead weight beats a 50s clip with 20s of fluff+MOMENT SELECTION:- Must start with a strong hook (first 3 seconds grab attention)- Must make complete sense standalone — no "as I mentioned" or "going back to"@@ -76,7 +85,6 @@ MOMENT SELECTION:- Single focused idea per clip — one concept, fully delivered- Prioritize: surprising facts, bold claims, founder stories, counterintuitive insights, "aha" moments- Variety across content types-- In conversations, include moments where both speakers contribute (back-and-forth exchanges can be powerful shorts){f"KNOWLEDGE BASE:{kb_context}" if kb_context else ""}diff --git a/backend/services/video_processor.py b/backend/services/video_processor.pyindex 3498845..15695cf 100644--- a/backend/services/video_processor.py+++ b/backend/services/video_processor.py@@ -488,7 +488,7 @@ def _build_speaker_aware_crop(for obs_t, obs_cx, obs_fw in face_observations:if abs(obs_t - t) < 1.0:for ci, cl in enumerate(clusters):- if abs(obs_cx - cl["center_x"]) < cluster_radius:+ if abs(obs_cx - cl["center_x"]) < width * 0.15:cluster_votes[ci] += 1if any(cluster_votes):best = max(range(len(cluster_votes)), key=lambda i: cluster_votes[i])@@ -537,34 +537,25 @@ def _build_speaker_aware_crop(default_cluster = speaker_to_cluster.get(dominant_speaker) or clusters[0]default_x = default_cluster["crop_x"]- # Build a timeline: list of (time, target_x) keyframes with smooth transitions.- # Instead of nested if/between (breaks with many segments), use a linear- # interpolation chain: lerp between keyframes.- pan_duration = 0.4 # 400ms smooth pan (was 300ms, felt jerky)+ # Build a timeline: list of (time, target_x) keyframes.+ # Split-screen: instant cut (panning through the center seam looks bad).+ # Non-split-screen: smooth 400ms pan.+ pan_duration = 0.0 if is_split_screen else 0.4- # Build keyframe list: (time, crop_x)- # In split-screen, verify target face is visible before panning.- # If face isn't detected at that time, stay at current position.keyframes = []prev_x = default_xfor start_t, end_t, speaker in segments:cl = speaker_to_cluster.get(speaker)target_x = cl["crop_x"] if cl else default_x- # Verify target face is visible at this time (avoid panning to empty space)- if is_split_screen and cl:- # Check if any face detection near the target cluster exists at segment start- face_near_target = any(- abs(obs_t - start_t) < 1.5 and abs(obs_cx - cl["center_x"]) < cluster_radius- for obs_t, obs_cx, obs_fw in face_observations- )- if not face_near_target:- target_x = prev_x # Stay at current position-if target_x != prev_x:- # Ease into the new position over pan_duration- keyframes.append((start_t, prev_x))- keyframes.append((start_t + pan_duration, target_x))+ if pan_duration > 0:+ keyframes.append((start_t, prev_x))+ keyframes.append((start_t + pan_duration, target_x))+ else:+ # Instant cut — jump at speaker change+ keyframes.append((start_t, prev_x))+ keyframes.append((start_t + 0.01, target_x))prev_x = target_xif not keyframes: