fix: preserve cue order when consolidated AD cues share same pause point
Add ad_cue_index as secondary sort key when sorting placements, ensuring that consolidated cues maintain their original VTT order (cue 0 before cue 1). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e371dc401a
commit
30483b3ec1
1 changed files with 3 additions and 2 deletions
|
|
@ -511,10 +511,11 @@ class VideoRendererService:
|
|||
logger.info(f"Starting pause-insert render for {source_video_path}")
|
||||
placements = analysis.get("placements", [])
|
||||
|
||||
# Sort placements by pause_point time
|
||||
# Sort placements by pause_point time, with ad_cue_index as secondary key
|
||||
# to ensure consolidated cues (sharing same pause_point) maintain VTT order
|
||||
sorted_placements = sorted(
|
||||
[p for p in placements if p.get("pause_point") is not None],
|
||||
key=lambda p: p["pause_point"]
|
||||
key=lambda p: (p["pause_point"], p.get("ad_cue_index", 0))
|
||||
)
|
||||
|
||||
# Debug logging for pause points (midpoint algorithm with silence buffers)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue