From 84a5b933878023d72a4f6c6f2d9a5ff25b94e370 Mon Sep 17 00:00:00 2001 From: "christophe.seux" Date: Thu, 23 Jan 2025 19:49:28 +0100 Subject: [PATCH] fix otio, remove double clips --- operators/exports.py | 1 + sequencer_utils.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/operators/exports.py b/operators/exports.py index 9eaf7f2..9c3176d 100644 --- a/operators/exports.py +++ b/operators/exports.py @@ -217,6 +217,7 @@ class VSETB_OT_export_edl(Operator): def execute(self, context): opentimelineio = install_module('opentimelineio') + opentimelineio = install_module('opentimelineio-plugins') from opentimelineio.schema import (Clip, Timeline, Track, ExternalReference) from opentimelineio.opentime import (RationalTime, TimeRange) diff --git a/sequencer_utils.py b/sequencer_utils.py index 9387d74..f6ddc5b 100644 --- a/sequencer_utils.py +++ b/sequencer_utils.py @@ -356,7 +356,7 @@ def import_edit(filepath, adapter="cmx_3600", channel='Shots', match_by='name'): # Get all video clips only clips = [] for track in timeline.tracks: - for child in track.each_child(shallow_search=True): + for child in track.find_clips(shallow_search=True): # FIXME Exclude Gaps for now. Gaps are Transitions, Blank Spaces... if not isinstance(child, Clip): @@ -366,12 +366,16 @@ def import_edit(filepath, adapter="cmx_3600", channel='Shots', match_by='name'): if any(child.name.lower().endswith(ext) for ext in SOUND_SUFFIXES): continue + if [c for c in clips if child.range_in_parent() == c.range_in_parent()]: + continue + clips.append(child) clips.sort(key=lambda x: x.range_in_parent().start_time) for i, clip in enumerate(clips): + #print(clip) frame_start = opentimelineio.opentime.to_frames( clip.range_in_parent().start_time) @@ -390,6 +394,7 @@ def import_edit(filepath, adapter="cmx_3600", channel='Shots', match_by='name'): print(f'No strip found for {clip.name}') if strip: + #print('Strip already existing', clip) if frame_start != strip.frame_final_start or frame_end !=strip.frame_final_end: print(f'The strip {strip.name} is updated with new range') #self.report({'INFO'}, f'The strip {strip.name} is updated with new range') @@ -399,7 +404,7 @@ def import_edit(filepath, adapter="cmx_3600", channel='Shots', match_by='name'): strip.frame_final_end = frame_end else: - print('Create a new strip') + print('Create a new strip', clip) strip = sequencer.new_effect( name=clip.name, type='COLOR',