Source code for cgl.plugins.otio.tools.aaf.otio_duration_fix

import aaf2
import shutil
import sys

[docs] def is_shot(mob): shot = mob.comments.get("cgl:shot") if shot: return True return False
[docs] def otio_duration_fix(f): for mob in f.content.mastermobs(): if not is_shot(mob): continue length = None file_mob = None tape_mob = None for slot in mob.slots: child_mob = slot.segment.mob if isinstance(child_mob.descriptor, aaf2.essence.CDCIDescriptor): length = slot.segment.length file_mob = child_mob break for slot in file_mob.slots: child_mob = slot.segment.mob if isinstance(child_mob.descriptor, aaf2.essence.TapeDescriptor): tape_mob = child_mob # otio uses the timecode length to determine available range # early files in the pipeline don't have this set to match the mastermob length for slot in tape_mob.slots: if isinstance(slot.segment, aaf2.components.Timecode): slot.segment.length = length
[docs] def otio_file_fixups(aaf_path): with aaf2.open(aaf_path, 'rw') as f: otio_duration_fix(f)
if __name__ == "__main__": src_file = sys.argv[1] test_file = src_file + ".fix.aaf" shutil.copy(src_file , test_file) otio_file_fixups(test_file)