Adding fixes to video build

This commit is contained in:
2026-07-23 19:04:15 +02:00
parent ee4d0b8b0e
commit 4913195b9d
3 changed files with 480 additions and 13 deletions
+18 -6
View File
@@ -639,6 +639,7 @@ def build_render_plan(
slide_range: Optional[tuple[str, Optional[str]]] = None,
narration_schedule: Optional[list] = None,
narration_source: Optional[VideoSource] = None,
marker_timings_override: Optional[list["MarkerTiming"]] = None,
) -> tuple[RenderPlan, list[MarkerTiming]]:
"""
Build a complete render plan from manuscript and transcription.
@@ -650,6 +651,12 @@ def build_render_plan(
manuscript_text: The manuscript.txt content (source of truth for markers)
transcription: Word-level timestamps from whisper transcription
slide_range: Optional tuple of (start_slide, end_slide) for partial rendering.
marker_timings_override: When provided (e.g. loaded from events.json /
scaffold.json), these timings are used verbatim instead of aligning
against the transcript. Their timestamps are already final-timeline
values, so the narration-skip adjustment below is skipped for them.
This is the seam that lets `render` consume a hand-edited scaffold
without re-running (and re-breaking on) fuzzy alignment.
Returns:
Tuple of (RenderPlan, list of MarkerTiming for display)
@@ -657,10 +664,14 @@ def build_render_plan(
audio = audio or {}
audio_dir = audio_dir or project_path
# Align markers to transcription timestamps
marker_timings = align_markers_to_transcription(
manuscript_text, transcription, slides=slides, videos=videos, audio=audio
)
# Align markers to transcription timestamps — unless caller supplied timings
# (from the scaffold/events layer), in which case those win verbatim.
if marker_timings_override is not None:
marker_timings = marker_timings_override
else:
marker_timings = align_markers_to_transcription(
manuscript_text, transcription, slides=slides, videos=videos, audio=audio
)
# Find shared_assets directory
shared_assets_dir = None
@@ -702,8 +713,9 @@ def build_render_plan(
full_duration = get_video_duration(video_path)
# Apply skip offset: if narration starts at `skip` seconds, subtract it from
# all marker timestamps so they line up with the trimmed timeline.
if narration_skip > 0:
# all marker timestamps so they line up with the trimmed timeline. Skipped for
# override timings, which are already expressed in the final timeline.
if narration_skip > 0 and marker_timings_override is None:
for timing in marker_timings:
if timing.timestamp >= 0:
timing.timestamp = max(0.0, timing.timestamp - narration_skip)