# SPDX-License-Identifier: GPL-2.0-or-later import bpy import re from pathlib import Path from vse_toolbox.bl_utils import get_settings def get_strips(channel=0, selected_only=False): scn = bpy.context.scene if isinstance(channel, str): channel = scn.sequence_editor.channels.keys().index(channel) strips = [s for s in scn.sequence_editor.sequences_all if s.channel==channel] if selected_only: strips = [s for s in strips if s.select] return sorted(strips, key=lambda x : x.frame_final_start) def get_shot_sequence(shot): sequences = get_strips(channel='Sequences') return next((s.name for s in sequences if s.frame_final_start<=shot.frame_final_start {name}') strip.name = name previous_sequence = sequence strip_number += 1 def set_channels(): scn = bpy.context.scene settings = get_settings() items = settings.rna_type.bl_rna.properties['channels'].enum_items for i, c in enumerate(items.keys(), start=1): scn.sequence_editor.channels[i].name = c.title() def render_strips(strips): for strip in strips: print(strip.name) def import_edl(filepath, adapter="cmx_3600"): import opentimelineio as otio scn = bpy.context.scene sequences = scn.sequence_editor.sequences edl = Path(filepath) try: timeline = otio.adapters.read_from_file( str(edl), adapter, rate=scn.render.fps, ignore_timecode_mismatch=True) except: data = edl.read_text(encoding='latin-1') timeline = otio.adapters.read_from_string( data, adapter, rate=scn.render.fps, ignore_timecode_mismatch=True) scn.frame_start = ( 0 if timeline.global_start_time is None else timeline.global_start_time ) scn.frame_end = otio.opentime.to_frames(timeline.duration()) - 1 for i, track in enumerate(timeline.tracks, 1): for child in track.each_child(shallow_search=False): frame_start = otio.opentime.to_frames( child.range_in_parent().start_time) frame_end = otio.opentime.to_frames( child.range_in_parent().duration) - 1 try: strip = sequences.new_effect( name='', type='COLOR', channel=i, frame_start=frame_start, frame_end=frame_end, ) except Exception as e: print('e: ', e) continue """ t = otio.adapters.read_from_file(edl, rate=C.scene.render.fps) t.video_tracks() # Video Tracks du fichiers. C'est une liste. Parcourir toutes les video_tracks ? Trouver comment fait Felix David """ print('timeline: ', timeline) return timeline """ def create_strip_effect(name, strip_type, channel, frame_start, frame_end): strip = scn.sequence_editor.sequences.new_effect( name=name, type=strip_type, channel=channel, frame_start=frame_start, frame_end=frame_end, ) return strip """