Source code for cgl.plugins.otio.tools.edit_info

import sys
import opentimelineio as otio


[docs] def get_shotgrid_edit_data_from_clip(clip): ref_start = clip.media_reference.available_range.start_time.to_frames() ref_duration = clip.media_reference.available_range.duration.to_frames() # NOTE: source_range.start_time is an absolute time clip_start = clip.source_range.start_time.to_frames() - ref_start clip_duration = clip.source_range.duration.to_frames() cut_order = clip.metadata.get("unreal", {}).get("cut_order", None) d = {} d["sg_cut_in"] = clip_start d["sg_cut_out"] = clip_start + clip_duration d["sg_cut_duration"] = clip_duration d["sg_head_in"] = ref_start d["sg_tail_out"] = ref_start + ref_duration d["sg_working_duration"] = ref_duration if cut_order is not None: d["sg_cut_order"] = cut_order return d
[docs] def get_shotgrid_edit_data_from_otio_file(otio_file_path): timeline = otio.adapters.read_from_file(otio_file_path) clips = list(timeline.find_clips()) if len(clips) != 1: raise ValueError("OTIO file should only contain one clip") return get_shotgrid_edit_data_from_clip(clips[0])
[docs] def get_edit_data(path_object): """ Returns the edit data for the given path_object """ otio_file_path = path_object.copy(filename="timeline", ext="otio").get_path() otio_file_path = otio_file_path.replace(".####", "") print(otio_file_path) return get_shotgrid_edit_data_from_otio_file(otio_file_path)
if __name__ == "__main__": otio_file_path = sys.argv[1] data = get_shotgrid_edit_data_from_otio_file(otio_file_path) print(data)