Adding support for audio again

This commit is contained in:
2026-05-08 08:08:08 +02:00
parent 26d027a44e
commit f0387f24bb
3 changed files with 22 additions and 12 deletions
+1 -1
View File
@@ -2071,7 +2071,7 @@ def _print_render_plan_details(plan, marker_timings, slides: dict) -> None:
print(f" {time_str} [{marker_id}]") print(f" {time_str} [{marker_id}]")
elif marker_id.startswith("audio:"): elif marker_id.startswith("audio:"):
aligned_count += 1 aligned_count += 1
print(f" {time_str} [audio:{marker_id[1:]}]") print(f" {time_str} [{marker_id}]")
else: else:
aligned_count += 1 aligned_count += 1
print(f' {marker_id:6} {time_str} "{context}"') print(f' {marker_id:6} {time_str} "{context}"')
+18 -11
View File
@@ -142,11 +142,15 @@ def _is_known_marker(
if marker_id in CAMERA_PRESETS: if marker_id in CAMERA_PRESETS:
return True return True
# Audio markers (A followed by id) # Audio markers (A followed by id, e.g., Awoosh) or audio: prefix (e.g., audio:woosh)
if marker_id.startswith("A") and len(marker_id) > 1: if marker_id.startswith("A") and len(marker_id) > 1:
audio_id = marker_id[1:] audio_id = marker_id[1:]
if audio_id in audio or audio_id.isdigit(): if audio_id in audio or audio_id.isdigit():
return True return True
if marker_id.startswith("audio:") and audio is not None:
audio_id = marker_id[6:]
if audio_id in audio:
return True
return False return False
@@ -1014,19 +1018,22 @@ def _extract_audio_events(
continue continue
marker_id = timing.marker_id marker_id = timing.marker_id
audio_id = None
if marker_id.startswith("A") and len(marker_id) > 1: if marker_id.startswith("A") and len(marker_id) > 1:
audio_id = marker_id[1:] audio_id = marker_id[1:]
if audio_id in audio: elif marker_id.startswith("audio:"):
if timing.timestamp < range_start or timing.timestamp >= range_end: audio_id = marker_id[6:]
continue if audio_id is not None and audio_id in audio:
start_time = max(0, timing.timestamp - AUDIO_OFFSET_SECONDS) if timing.timestamp < range_start or timing.timestamp >= range_end:
events.append( continue
AudioEvent( start_time = max(0, timing.timestamp - AUDIO_OFFSET_SECONDS)
audio_id=audio_id, events.append(
start_time=start_time, AudioEvent(
audio_def=audio[audio_id], audio_id=audio_id,
) start_time=start_time,
audio_def=audio[audio_id],
) )
)
return events return events
+3
View File
@@ -57,6 +57,9 @@ def validate_project(
# Skip audio markers (start with 'A' followed by audio id, e.g., Awoosh) # Skip audio markers (start with 'A' followed by audio id, e.g., Awoosh)
if marker.startswith("A") and len(marker) > 1 and marker[1:].isalnum(): if marker.startswith("A") and len(marker) > 1 and marker[1:].isalnum():
continue continue
# Skip audio: prefix markers (e.g., audio:woosh)
if marker.startswith("audio:"):
continue
# Validate video trigger markers — both legacy [video:xxx] and # Validate video trigger markers — both legacy [video:xxx] and
# shorthand [vft:xxx] / [vfb:xxx] / [vst:xxx] / [vsb:xxx]. # shorthand [vft:xxx] / [vfb:xxx] / [vst:xxx] / [vsb:xxx].
_VIDEO_PREFIXES = { _VIDEO_PREFIXES = {