Fix import csv and update edit
This commit is contained in:
+50
-30
@@ -255,13 +255,15 @@ def render_strip(strip, output):
|
||||
scn.frame_current = scene_current
|
||||
scn.render.filepath = render_path
|
||||
|
||||
def import_edit(filepath, adapter="cmx_3600", channel='Shots'):
|
||||
def import_edit(filepath, adapter="cmx_3600", channel='Shots', match_by='name'):
|
||||
opentimelineio = install_module('opentimelineio')
|
||||
|
||||
from opentimelineio.schema import Clip
|
||||
|
||||
scn = bpy.context.scene
|
||||
sequencer = scn.sequence_editor.sequences
|
||||
strips = get_strips(channel='Shots')
|
||||
shot_channel = get_channel_index('Shots')
|
||||
|
||||
edl = Path(filepath)
|
||||
try:
|
||||
@@ -276,6 +278,9 @@ def import_edit(filepath, adapter="cmx_3600", channel='Shots'):
|
||||
scn.frame_start = (
|
||||
0 if timeline.global_start_time is None else timeline.global_start_time
|
||||
)
|
||||
|
||||
# Get all video clips only
|
||||
clips = []
|
||||
for track in timeline.tracks:
|
||||
for child in track.each_child(shallow_search=True):
|
||||
|
||||
@@ -285,41 +290,56 @@ def import_edit(filepath, adapter="cmx_3600", channel='Shots'):
|
||||
|
||||
# FIXME Exclude Audio for now
|
||||
if any(child.name.lower().endswith(ext) for ext in SOUND_SUFFIXES):
|
||||
channel = get_channel_index('Audio')
|
||||
continue
|
||||
|
||||
clips.append(child)
|
||||
|
||||
clips.sort(key=lambda x: x.range_in_parent().start_time)
|
||||
|
||||
|
||||
for i, clip in enumerate(clips):
|
||||
|
||||
channel = get_channel_index('Shots')
|
||||
frame_start = opentimelineio.opentime.to_frames(
|
||||
child.range_in_parent().start_time)
|
||||
frame_start = opentimelineio.opentime.to_frames(
|
||||
clip.range_in_parent().start_time)
|
||||
|
||||
frame_end = frame_start + opentimelineio.opentime.to_frames(
|
||||
child.range_in_parent().duration)
|
||||
|
||||
#try:
|
||||
strip = next((s for s in sequencer if s.vsetb_strip_settings.source_name == child.name), None)
|
||||
if strip:
|
||||
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')
|
||||
frame_end = frame_start + opentimelineio.opentime.to_frames(
|
||||
clip.range_in_parent().duration)
|
||||
|
||||
strip = None
|
||||
|
||||
strip.frame_final_start = frame_start
|
||||
strip.frame_final_end = frame_end
|
||||
else:
|
||||
strip = sequencer.new_effect(
|
||||
name=child.name,
|
||||
type='COLOR',
|
||||
channel=channel,
|
||||
frame_start=frame_start,
|
||||
frame_end=frame_end,
|
||||
)
|
||||
if match_by.lower() == 'name':
|
||||
strip = next((s for s in strips if s.vsetb_strip_settings.source_name == clip.name), None)
|
||||
elif match_by.lower() == 'index':
|
||||
try:
|
||||
strip = strips[i]
|
||||
except IndexError:
|
||||
print(f'No strip found for {clip.name}')
|
||||
|
||||
strip.blend_alpha = 0.0
|
||||
strip.select = False
|
||||
strip.vsetb_strip_settings.source_name = child.name
|
||||
if strip:
|
||||
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')
|
||||
|
||||
#except Exception as e:
|
||||
# print('e: ', e)
|
||||
# continue
|
||||
strip.frame_final_start = frame_start
|
||||
strip.frame_final_end = frame_end
|
||||
|
||||
else:
|
||||
print('Create a new strip')
|
||||
strip = sequencer.new_effect(
|
||||
name=clip.name,
|
||||
type='COLOR',
|
||||
channel=shot_channel,
|
||||
frame_start=frame_start,
|
||||
frame_end=frame_end,
|
||||
)
|
||||
|
||||
strip.blend_alpha = 0.0
|
||||
strip.select = False
|
||||
strip.vsetb_strip_settings.source_name = clip.name
|
||||
|
||||
#except Exception as e:
|
||||
# print('e: ', e)
|
||||
# continue
|
||||
|
||||
scn.frame_end = frame_end-1
|
||||
return timeline
|
||||
|
||||
Reference in New Issue
Block a user