From 4611ca119b9cdd658e86df7e1afccd81975b4540 Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Tue, 18 Aug 2026 19:41:15 +0200 Subject: [PATCH] fix(generate): scale scoring windows with the requested clip band The detail prompt keeps clips inside their candidate window, so the default 90s scoring windows silently capped user-requested long clips (a 60-90s band barely fit, anything above did not). Windows now grow to 1.5x the requested max length; the default band keeps the exact old behavior. --- main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index faabcd8..bda1189 100644 --- a/main.py +++ b/main.py @@ -1245,7 +1245,14 @@ def get_viral_clips(transcript_result, video_duration): words.append({'w': word['word'], 's': word['start'], 'e': word['end']}) try: - windows = build_transcript_windows(transcript_result, video_duration) + # Scoring windows must be able to CONTAIN a max-length clip (the detail + # prompt keeps clips inside their candidate window), so scale them with + # the requested band — a user asking for 60-90s clips on the default + # 90s windows would get clips squeezed against the window walls. + min_secs, max_secs = clip_duration_bounds() + windows = build_transcript_windows( + transcript_result, video_duration, + window_seconds=max(90, int(max_secs * 1.5))) print(f" Built {len(windows)} scoring window(s).") costs = [] @@ -1276,7 +1283,6 @@ def get_viral_clips(transcript_result, video_duration): # --- Pass 2: detailed clip extraction on the shortlist --- payload = [{"id": w["id"], "start": w["start"], "end": w["end"], "text": w["text"]} for w in shortlist] min_clips, max_clips = clip_count_targets(len(shortlist)) - min_secs, max_secs = clip_duration_bounds() prompt = gemini_worker.DETAIL_PROMPT_TEMPLATE.format( video_duration=video_duration, language=language, min_clips=min_clips, max_clips=max_clips,