Use beat context for segmented action retiming

This commit is contained in:
Melbar
2026-05-02 21:58:35 +02:00
parent 8415516f89
commit e293835a86
3 changed files with 104 additions and 9 deletions
+8 -4
View File
@@ -646,14 +646,18 @@ def _filter_semantically_invalid_vision_matches(results: list, beats: list, cfg)
beats_by_id = {beat.beat_id: beat for beat in beats}
scenes_by_id = {scene.scene_id: scene for scene in build_scene_index(cfg)}
def realign_window(check_beat, scene_id: int):
def realign_window(check_beat, scene_id: int, action_beat=None):
scene = scenes_by_id.get(scene_id)
if scene is None:
return None
found = find_action_window_in_scene(check_beat, scene, cfg)
found = find_action_window_in_scene(action_beat or check_beat, scene, cfg)
if found is None:
return None
start_s, end_s, semantic_score, reason = found
if action_beat is not None:
offset_delta_s = max(0.0, check_beat.start_s - action_beat.start_s)
start_s += offset_delta_s
end_s += offset_delta_s
window_s = max(3.0, min(8.0, (end_s - start_s) * 4.0))
aligned_in_s, combined_score, content_score, motion_score = align_in_point_by_content_and_motion(
check_beat,
@@ -737,7 +741,7 @@ def _filter_semantically_invalid_vision_matches(results: list, beats: list, cfg)
start_s=beat.start_s + segment.trailer_offset_s,
end_s=beat.start_s + segment.trailer_offset_s + segment.duration_s,
)
repair = realign_window(segment_beat, segment.scene_id)
repair = realign_window(segment_beat, segment.scene_id, action_beat=beat)
if repair is None:
new_segments.append(segment)
continue
@@ -809,7 +813,7 @@ def _filter_semantically_invalid_vision_matches(results: list, beats: list, cfg)
start_s=beat.start_s + segment.trailer_offset_s,
end_s=beat.start_s + segment.trailer_offset_s + segment.duration_s,
)
repair = realign_window(segment_beat, segment.scene_id)
repair = realign_window(segment_beat, segment.scene_id, action_beat=beat)
if repair is None:
all_repaired = False
break