def test_rewrite(self): result_file = os.path.join(result_dir, 'rewrite.avb') with avb.open(test_file_01) as f: f.debug_copy_refs = True f.octx = AVBIOContext() with open(result_file, 'wb') as f2: count_pos = f.write_header(f2) obj_count = len(f.object_positions) pos = f2.tell() f2.seek(count_pos) AVBIOContext.write_u32le(f2, obj_count-1) AVBIOContext.write_u32le(f2, obj_count-1) f2.seek(pos) for i in range(1, obj_count): obj = f.read_object(i) f.write_object(f2, obj) with avb.open(test_file_01) as a: with avb.open(result_file) as b: s = f.object_positions[1] a.f.seek(s) b.f.seek(s) assert a.f.read() == b.f.read()
def test_create_empty(self): result_file = os.path.join(result_dir, 'empty.avb') with avb.open() as f: f.write(result_file) with avb.open(result_file) as f: assert f.content.view_setting.name == u'Untitled' assert len(f.content.items) == 0
def test_rewrite_all_be(self): result_file = os.path.join(result_dir, 'rewrite_be.avb') with avb.open(test_file_01) as f: f.write(result_file, byte_order='big') with avb.open(test_file_01, use_ext=False) as a: with avb.open(result_file, use_ext=False) as b: compare(a.content, b.content)
def test_modify(self): result_file = os.path.join(result_dir, 'modifed.avb') with avb.open(test_file_01) as f: for mob in f.content.mobs: mob.name = u"Cow" mob.attributes['Test'] = 5 assert f.modified_objects f.write(result_file) with avb.open(result_file) as f: for mob in f.content.mobs: assert mob.name == u"Cow" assert mob.attributes['Test'] == 5
def test_create_mastermob(self): result_file = os.path.join(result_dir, 'mastermob.avb') mob_id = None with avb.open() as f: mob = create_mastermob(f) mob_id = mob.mob_id f.write(result_file) with avb.open(result_file) as f: mobs = list(f.content.mobs) mob = mobs[0] assert mob.name == u"Clip1" assert mob.mob_id == mob_id assert mob.mob_type == 'MasterMob'
def avb2aaf_main(path): with avb.open(path) as avb_file: with aaf2.open(path + ".aaf", 'w') as aaf_file: register_definitions(aaf_file) avb_file.content.build_mob_dict() avb2aaf(aaf_file, avb_file)
def test_no_modify(self): result_file = os.path.join(result_dir, 'modifed.avb') with avb.open(test_file_01) as f: for mob in f.content.mobs: for track in mob.tracks: c = track.component if isinstance(c, avb.components.Sequence): for item in c.components: pass # nothin should be modified assert not f.modified_objects
def __init__(self, filename): self.data = avb.open(filename)
def main(path): with avb.open(path) as f: for mob in f.content.toplevel(): print(mob.name) dump_markers(mob)
def display_object(obj, indent=""): if isinstance(obj, list): for idx, item in enumerate(obj): display_object(item, indent + f"[{idx}]") else: print(indent, cleanup_string(str(obj))) if hasattr(obj, 'propertydefs'): defs = [x.name for x in obj.propertydefs] for x in defs: if x == 'attributes': if hasattr(obj, 'attributes') and obj.attributes: attr = obj.attributes for item in attr: display_object(attr[item], indent=f"{indent}.{item}") elif hasattr(obj, x): # print(indent, x, ":") display_object(getattr(obj, x), indent=f"{indent}.{x}") parser = ArgumentParser() parser.add_argument('avbfile') args = parser.parse_args() data = avb.open(args.avbfile) display_object(data.content)
from PySide2 import QtWidgets from optparse import OptionParser parser = OptionParser() parser.add_option('-m', '--mobs', action="store_true", default=False) parser.add_option('-t', '--toplevel', action="store_true", default=False) (options, args) = parser.parse_args() if not args: parser.error("not enough arguments") file_path = args[0] f = avb.open(file_path) root = f.content if options.toplevel: root = list(f.content.toplevel()) if options.mobs: root = list(f.content.mobs) app = QtWidgets.QApplication(sys.argv) model = AVBModel(root) use_column = False if use_column: tree = QtWidgets.QColumnView()
def test_create_sequence(self): result_file = os.path.join(result_dir, 'sequence.avb') with avb.open() as f: edit_rate = 25 mob1 = create_mastermob(f) mob2 = create_mastermob(f) comp = f.create.Composition(mob_type="CompositionMob") comp.name = "Test Sequence" # timecode track track = f.create.Track() track.index = 1 track.component = f.create.Timecode(edit_rate=edit_rate, media_kind='timecode') track.component.start = 90000 track.component.fps = 25 track.component.length = 500 comp.tracks.append(track) # V1 track = f.create.Track() track.index = 1 track.filler_proxy = f.create.TrackRef(edit_rate=edit_rate, media_kind='picture') track.filler_proxy.length = 2147483647 track.filler_proxy.relative_scope = 0 track.filler_proxy.relative_track sequence = f.create.Sequence(edit_rate=edit_rate, media_kind='picture') sequence.components.append(f.create.Filler(edit_rate=edit_rate, media_kind='picture')) clip = f.create.SourceClip(edit_rate=edit_rate, media_kind='picture') clip.track_id = 1 clip.start_time = 25 clip.length = 50 clip.mob_id = mob1.mob_id sequence.components.append(clip) fill = f.create.Filler(edit_rate=edit_rate, media_kind='picture') fill.length = 50 sequence.components.append(fill) clip = f.create.SourceClip(edit_rate=edit_rate, media_kind='picture') clip.track_id = 1 clip.start_time = 25 clip.length = 50 clip.mob_id = mob2.mob_id sequence.components.append(clip) sequence.components.append(f.create.Filler(edit_rate=edit_rate, media_kind='picture')) track.component = sequence comp.tracks.append(track) comp.length = sequence.length # A1 track = f.create.Track() track.index = 1 sequence = f.create.Sequence(edit_rate=edit_rate, media_kind='sound') fill = f.create.Filler(edit_rate=edit_rate, media_kind='sound') fill.length = comp.length sequence.components.append(fill) track.component = sequence comp.tracks.append(track) # A2 track = f.create.Track() track.index = 2 sequence = f.create.Sequence(edit_rate=edit_rate, media_kind='sound') fill = f.create.Filler(edit_rate=edit_rate, media_kind='sound') fill.length = comp.length sequence.components.append(fill) track.component = sequence comp.tracks.append(track) f.content.add_mob(comp) f.write(result_file)
def main(path): with avb.open(path) as f: dump(f.content)
def test_read_all_known_classes(self): with avb.open(test_file_01) as f: for i, chunk in enumerate(f.chunks()): if chunk.class_id in avb.utils.AVBClaseID_dict: item = f.read_object(i)
def test_basic(self): with avb.open(test_file_01) as f: for item in f.content.mobs: pass
def __init__(self, filename, debug=False, mxf_files=None): self.data = avb.open(filename) self.debug = debug self.mxf_files = mxf_files self.mxf_file_name_generator = MxfFileNameGenerator(mxf_files)