Fixing a few things

This commit is contained in:
2026-07-24 13:17:35 +02:00
parent c3e892cf89
commit 5a439380ae
7 changed files with 162 additions and 6 deletions
+26
View File
@@ -1222,6 +1222,10 @@ def _extract_video_events(
continue
video_markers.append((timing.timestamp, video_id, "narration", False))
# Sorted start times of all video markers — used by end_on="next_video" to cap
# a clip when the next video begins, so videos never overlap.
video_start_times = sorted(t for t, _, _, _ in video_markers)
events: list[VideoEvent] = []
for start_time, video_id, marker_type, pause_narration in video_markers:
video_source = videos[video_id]
@@ -1235,7 +1239,29 @@ def _extract_video_events(
if end_on == "take" and video_source.take is not None:
end_time = start_time + video_source.take
elif end_on == "end":
# Play the clip once through its natural length, then stop — no looping.
# Natural length = explicit take, else the file's own duration past skip.
if video_source.take is not None:
natural = video_source.take
elif video_source.duration is not None:
natural = max(0.0, video_source.duration - (video_source.skip or 0.0))
else:
natural = None # unknown length — fall back to running to render end
end_time = (start_time + natural) if natural is not None else total_duration
elif end_on == "loop":
# Loop the clip to fill the rest of the render.
end_time = total_duration
elif end_on in ("next_video", "video"):
# End when the next video (any) starts, so clips never overlap. Lets a
# video span multiple slides yet still yield to the following video.
end_time = total_duration
for vt in video_start_times:
if vt > start_time:
end_time = vt
break
# A pause-narration video must stay for at least the pause it holds.
if video_source.pause_narration:
end_time = max(end_time, start_time + video_source.pause_narration)
elif end_on in ("next_slide", "slide") or (end_on is None and marker_type == "video"):
# End at next slide marker ("slide" is a recognised alias for "next_slide")
end_time = total_duration