Skip to content

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

feat: outro support with crossfade transition

Nika Siradzebbce3a329227
diff --git a/backend/cli.py b/backend/cli.py
index 5ecffc8..f85b34f 100644
--- a/backend/cli.py
+++ b/backend/cli.py
@@ -130,6 +130,14 @@ def cmd_process(args):
else:
print(f" Warning: Logo '{args.logo}' not found (checked assets and filesystem)", file=sys.stderr)
config["logo_path"] = args.logo # pass through anyway
+ if args.outro:
+ from services.asset_store import resolve as resolve_asset_outro
+ resolved = resolve_asset_outro(args.outro)
+ if resolved:
+ config["outro_path"] = resolved
+ else:
+ print(f" Warning: Outro '{args.outro}' not found (checked assets and filesystem)", file=sys.stderr)
+ config["outro_path"] = args.outro
if args.time_adjust is not None:
config["time_adjust"] = args.time_adjust
if args.no_energy:
@@ -314,6 +322,7 @@ def cmd_process(args):
title=clip.get("title", f"clip_{i+1}"),
output_dir=output_dir,
logo_path=config.get("logo_path") or None,
+ outro_path=config.get("outro_path") or None,
)
results.append(result)
print(f" ✓ {result['file_size_mb']}MB")
@@ -918,7 +927,8 @@ def main():
proc.add_argument("-p", "--preset", help="Load a saved preset")
proc.add_argument("--caption-style", choices=["branded", "hormozi", "karaoke", "subtle"])
proc.add_argument("--crop", choices=["center", "face"])
- proc.add_argument("--logo", help="Path to logo image")
+ 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("--time-adjust", type=float, help="Timestamp offset in seconds")
proc.add_argument("--no-energy", action="store_true", help="Skip audio energy analysis")
proc.add_argument("--quality", choices=["low", "medium", "high", "max"], help="Output quality (default: high)")
@@ -1156,12 +1166,41 @@ def _interactive_process():
except Exception:
pass
+ # 7. Outro
+ outro = None
+ try:
+ from services.asset_store import list_assets as list_assets_outro
+ outros = [a for a in list_assets_outro() if a["type"] == "video" and os.path.exists(a["path"])]
+ if outros:
+ print(f"\n {bold}Outro{reset} {dim}(default 0 = none):{reset}")
+ for i, a in enumerate(outros):
+ print(f" {accent}{i+1}{reset} {a['name']} {dim}{os.path.basename(a['path'])}{reset}")
+ print(f" {accent}0{reset} none")
+ oc = _prompt(f" {accent}▸{reset} ", default="0") or "0"
+ if oc != "0":
+ idx = int(oc) - 1
+ if 0 <= idx < len(outros):
+ outro = outros[idx]["path"]
+ print(f" {green}✓{reset} {outros[idx]['name']}")
+ else:
+ print(f"\n {bold}Outro:{reset} {dim}(drag video or press Enter to skip):{reset}")
+ o = _prompt(f" {accent}▸{reset} ", default="")
+ if o:
+ o = _clean_path(o)
+ if os.path.exists(o):
+ outro = o
+ print(f" {green}✓{reset} {os.path.basename(outro)}")
+ except Exception:
+ pass
+
# Summary + confirm
print(f"\n {'─' * 45}")
print(f" {bold}Video:{reset} {os.path.basename(video)}")
print(f" {bold}Style:{reset} {caption_style} · Quality: {quality} · Clips: {top_n}")
if logo:
print(f" {bold}Logo:{reset} ✓")
+ if outro:
+ print(f" {bold}Outro:{reset} ✓ {dim}{os.path.basename(outro)}{reset}")
print(f" {bold}Transcript:{reset} {'auto (Whisper)' if not transcript else os.path.basename(transcript)}")
try:
input(f"\n {green}Ready!{reset} {bold}Press Enter to start{reset} {dim}(q to cancel){reset} ")
@@ -1178,6 +1217,8 @@ def _interactive_process():
cmd += ["--top", str(top_n)]
if logo:
cmd += ["--logo", logo]
+ if outro:
+ cmd += ["--outro", outro]
print(f"\n {green}▶{reset} Starting...\n")
sys.stdout.flush()
diff --git a/backend/services/video_processor.py b/backend/services/video_processor.py
index d68a991..c9b1ab4 100644
--- a/backend/services/video_processor.py
+++ b/backend/services/video_processor.py
@@ -519,16 +519,30 @@ def concat_outro(
input_path: str,
outro_path: str,
output_path: str,
+ crossfade_duration: float = 0.5,
) -> str:
"""
- Append an outro video to the end of the main clip.
- Re-encodes the outro to match the main clip's resolution and codec.
+ Append an outro video to the end of the main clip with a crossfade transition.
+
+ Uses FFmpeg xfade filter for a smooth video crossfade and acrossfade for audio.
+ Falls back to hard cut if xfade fails (older FFmpeg).
"""
width, height = get_dimensions(input_path)
- concat_list = os.path.join(os.path.dirname(output_path), "concat_list.txt")
+ # Get main clip duration for crossfade offset
+ probe_cmd = [
+ "ffprobe", "-v", "quiet", "-print_format", "json",
+ "-show_format", input_path,
+ ]
+ probe = subprocess.run(probe_cmd, capture_output=True, text=True)
+ try:
+ main_duration = float(json.loads(probe.stdout)["format"]["duration"])
+ except Exception:
+ main_duration = 30.0
- # Re-encode outro to match main clip's dimensions
+ fade_offset = max(0, main_duration - crossfade_duration)
+
+ # Re-encode outro to match dimensions
outro_scaled = output_path + ".outro_scaled.mp4"
_run_ffmpeg_with_fallback(
cmd_parts_before_enc=[
@@ -538,15 +552,43 @@ def concat_outro(
f"pad={width}:{height}:(ow-iw)/2:(oh-ih)/2:black",
],
cmd_parts_after_enc=[
- "-c:a", "aac", "-b:a", "128k", "-ar", "44100",
+ "-c:a", "aac", "-b:a", "192k", "-ar", "44100",
"-movflags", "+faststart",
],
output_path=outro_scaled,
label="outro_scale",
)
- # Re-encode main clip to ensure compatible streams for concat
+ # Try crossfade first (requires FFmpeg 4.3+)
+ try:
+ xfade_cmd = [
+ "ffmpeg", "-y",
+ "-i", input_path,
+ "-i", outro_scaled,
+ "-filter_complex",
+ f"[0:v][1:v]xfade=transition=fade:duration={crossfade_duration}:offset={fade_offset}[v];"
+ f"[0:a][1:a]acrossfade=d={crossfade_duration}[a]",
+ "-map", "[v]", "-map", "[a]",
+ ]
+ xfade_cmd += get_video_encode_flags()
+ xfade_cmd += [
+ "-c:a", "aac", "-b:a", "192k",
+ "-movflags", "+faststart",
+ output_path,
+ ]
+ result = subprocess.run(xfade_cmd, capture_output=True, text=True)
+ if result.returncode == 0:
+ # Clean up
+ if os.path.exists(outro_scaled):
+ os.remove(outro_scaled)
+ return output_path
+ except Exception:
+ pass
+
+ # Fallback: hard cut concat
main_reenc = output_path + ".main_reenc.mp4"
+ concat_list = os.path.join(os.path.dirname(output_path), "concat_list.txt")
+
_run_ffmpeg_with_fallback(
cmd_parts_before_enc=[
"ffmpeg", "-y",
@@ -554,7 +596,7 @@ def concat_outro(
"-vf", f"scale={width}:{height}",
],
cmd_parts_after_enc=[
- "-c:a", "aac", "-b:a", "128k", "-ar", "44100",
+ "-c:a", "aac", "-b:a", "192k", "-ar", "44100",
"-movflags", "+faststart",
],
output_path=main_reenc,