Skip to content

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

fix: Claude returning 1-second clips — timestamps were in M:SS not seconds

Nika Siradze18b7e426fe52
diff --git a/backend/services/claude_suggest.py b/backend/services/claude_suggest.py
index 5f6282c..53f5419 100644
--- a/backend/services/claude_suggest.py
+++ b/backend/services/claude_suggest.py
@@ -63,6 +63,9 @@ def _build_prompt(transcript_text: str, segment_count: int, duration_min: float,
IMPORTANT: Return ONLY valid JSON. No markdown, no explanation, no code fences.
+TIMESTAMP FORMAT: All timestamps in the transcript are in SECONDS (e.g., [123.4s]).
+All timestamps you return MUST be in SECONDS as numbers (e.g., 123.4), NOT minutes:seconds.
+
DURATION RULES (CRITICAL):
- Target: 30-45 seconds per clip (ideal for YouTube Shorts)
- Maximum: 60 seconds (hard limit — YouTube Shorts cuts off at 60s)
@@ -161,11 +164,10 @@ def suggest_with_claude(
speaker = seg.get("speaker", "")
speaker_label = f"[{speaker}] " if speaker else ""
start = seg.get("start", 0)
- mins = int(start) // 60
- secs = int(start) % 60
text = seg.get("text", "").strip()
if text:
- lines.append(f"({mins}:{secs:02d}) {speaker_label}{text}")
+ # Use absolute seconds (not M:SS) so Claude returns seconds too
+ lines.append(f"[{start:.1f}s] {speaker_label}{text}")
transcript_text = "\n".join(lines)
@@ -271,6 +273,10 @@ def suggest_with_claude(
# Compute actual kept duration
kept_duration = sum(seg["end"] - seg["start"] for seg in keep_segments)
+ # Reject clips shorter than 15 seconds (Claude returned bad timestamps)
+ if kept_duration < 15:
+ continue
+
normalized.append({
"title": c.get("title", "Untitled")[:55],
"start_second": keep_segments[0]["start"] if keep_segments else start_sec,
diff --git a/backend/services/video_processor.py b/backend/services/video_processor.py
index ae44c4f..8850191 100644
--- a/backend/services/video_processor.py
+++ b/backend/services/video_processor.py
@@ -984,6 +984,12 @@ def normalize_audio(
except (json.JSONDecodeError, ValueError):
loudnorm_data = None
+ # Check for invalid measurements (e.g., -inf from silence/very short clips)
+ if loudnorm_data:
+ measured_i = str(loudnorm_data.get("input_i", ""))
+ if "inf" in measured_i.lower() or measured_i == "":
+ loudnorm_data = None
+
if loudnorm_data:
# Second pass: apply measured correction
af_filter = (