Refacto of the scene cut detection, make it generic and add another algorythm as an option

This commit is contained in:
2025-01-10 16:24:52 +01:00
parent de16df05ef
commit 425c842bfd
8 changed files with 248 additions and 155 deletions
+21 -7
View File
@@ -460,16 +460,25 @@ class VSETB_OT_import_shots(Operator):
conformed = False
scn.sequence_editor_clear()
scn.sequence_editor_create()
if import_shots.clear:
frame_index = 1
scn.sequence_editor_clear()
scn.sequence_editor_create()
else:
frame_index = scn.frame_end +1
self.set_sequencer_channels([t.name for t in task_types])
frame_index = 1
for sequence in sequences:
shots_data = tracker.get_shots(sequence=sequence.id)
sequence_start = frame_index
for shot_data in shots_data:
frames = int(shot_data['nb_frames'])
frames = shot_data['nb_frames']
if not frames:
frames = 100
print(f'No nb frames on tracker for {shot_data["name"]}')
frames = int(frames)
frame_end = frame_index + frames
strip = scn.sequence_editor.sequences.new_effect(
@@ -497,9 +506,13 @@ class VSETB_OT_import_shots(Operator):
print(f'Loading Preview from {preview}')
channel_index = get_channel_index(f'{task_type.name} Video')
video_clip = import_movie(preview, frame_start=frame_index, frame_end=frame_end)
video_clip = import_movie(preview, frame_start=frame_index)
video_clip.channel = channel_index
if strip.frame_final_end != video_clip.frame_final_end: # Conform shot duration to longest media
frames = video_clip.frame_final_duration
strip.frame_final_end = video_clip.frame_final_end
if video_clip.frame_offset_end:
video_clip.color_tag = 'COLOR_01'
@@ -511,8 +524,7 @@ class VSETB_OT_import_shots(Operator):
# Load Audio
channel_index = get_channel_index(f'{task_type.name} Audio')
audio_clip = import_sound(preview, frame_start=frame_index,
frame_end=frame_end)
audio_clip = import_sound(preview, frame_start=frame_index)
audio_clip.channel = channel_index
if video_clip.frame_offset_end:
audio_clip.color_tag = 'COLOR_01'
@@ -632,6 +644,8 @@ class VSETB_OT_import_shots(Operator):
row = split.row()
row.label(icon="ERROR")
row.label(text='Add at least one Sequence')
layout.prop(import_shots, 'clear', text='Clear')
def invoke(self, context, event):
scn = context.scene