示例#1
0
    def test_material_id(self):
        for i in range(10000):
            material = AUID(int=i)
            m = MobID(int=i)
            assert m.material == material

        for i in range(100):
            material = uuid.uuid4()
            m = MobID.new()
            m.material = material
            assert m.material == material
示例#2
0
def convert_source_clip(f, avb_source_clip):
    slot_id = check_source_clip(f, avb_source_clip)

    mob_id = MobID(bytes_le=avb_source_clip.mob_id.bytes_le)
    if zero_mob_id(mob_id):
        mob_id = MobID()

    aaf_component = f.create.SourceClip()
    aaf_component['SourceID'].value = mob_id
    aaf_component['StartTime'].value = avb_source_clip.start_time
    aaf_component['SourceMobSlotID'].value = slot_id

    return aaf_component
示例#3
0
def check_source_clip(f, avb_source_clip):
    mob_id = MobID(bytes_le=avb_source_clip.mob_id.bytes_le)
    if zero_mob_id(mob_id):
        return 0
    avb_mob = avb_source_clip.root.content.mob_dict[avb_source_clip.mob_id]
    if mob_id in f.content.mobs:
        mob = f.content.mobs[mob_id]
    else:
        mob = convert_composition(f, avb_mob)

    try:
        slot_id = remap_track_id(avb_source_clip.track_id,
                                 avb_source_clip.media_kind, avb_mob)
        source_slot = mob.slot_at(slot_id)
    except:
        avb_dump(avb_mob)
        avb_dump(avb_source_clip)
        for i, track in enumerate(avb_mob.tracks):
            print(i + 1, track.index, track.component.media_kind)

        for slot in mob.slots:
            print(slot)

        print(avb_source_clip.track_id, avb_source_clip.media_kind)
        raise

    return slot_id
示例#4
0
    def test_mobs(self):

        result_file = common.get_test_file('mobs.aaf')

        mobs = {}
        now = datetime.datetime.now()
        count = 100
        with AAFFile(result_file, 'w') as f:

            for i in range(count):
                mob_id = MobID.new()
                m = f.create.MasterMob()
                m.name = "TestMob%d" % i
                m.mob_id = mob_id
                m['LastModified'].value = now
                m['CreationTime'].value = now
                m['Slots'].value = []

                f.content.mobs.append(m)

                mobs[mob_id] = m.name

        with AAFFile(result_file, 'r') as f:
            # file_mobs = f.content['Mobs'].value

            for mob in f.content.mobs:
                assert mob.mob_id in mobs
                assert mob.name == mobs[mob.mob_id]

            assert len(list(f.content.mobs)) == count
示例#5
0
    def test_mob_id(self):
        m = MobID.new()
        material_uuid = AUID("52c02cd8-6801-4806-986a-b68c0a0cf9d3")
        m.material = material_uuid
        m_str = "urn:smpte:umid:060a2b34.01010105.01010f20.13000000.52c02cd8.68014806.986ab68c.0a0cf9d3"

        m2 = MobID(str(m))

        assert m == m2
        m2 = MobID(bytes_le=m.bytes_le)
        assert m == m2
        assert m.int == m2.int

        assert m == MobID(m_str)
        assert hash(m) == hash(m2)
        assert str(m) == m_str

        assert m.material == material_uuid
示例#6
0
def convert_composition(f, avb_mob):
    mob_id = MobID(bytes_le=avb_mob.mob_id.bytes_le)
    if mob_id in f.content.mobs:
        return f.content.mobs.get(mob_id)

    if avb_mob.mob_type == 'MasterMob':
        if avb_mob.name:
            pass
            # print(mob_id, avb_mob.name)
        aaf_mob = f.create.MasterMob()
        aaf_mob.mob_id = mob_id
    elif avb_mob.mob_type == 'SourceMob':
        aaf_mob = f.create.SourceMob()
        aaf_mob.descriptor = convert_descriptor(avb_mob.descriptor, f)
        aaf_mob.mob_id = mob_id
    elif avb_mob.mob_type == 'CompositionMob':
        aaf_mob = f.create.CompositionMob()

        # use exsiting mob_id for non toplevel comps
        if avb_mob.usage is not None:
            aaf_mob.mob_id = mob_id
            aaf_mob['AppCode'].value = 1

        if avb_mob.usage_code == 0:
            aaf_mob.usage = "Usage_TopLevel"

    # avb_dump(avb_mob)
    aaf_mob.name = avb_mob.name or ""

    f.content.mobs.append(aaf_mob)
    convert_slots(f, avb_mob, aaf_mob)

    for key, value in avb_mob.attributes.get('_USER', {}).items():
        tag = f.create.TaggedValue(key, value)
        aaf_mob.comments.append(tag)

    return aaf_mob
示例#7
0
    def test_int(self):

        for i in range(1000):
            m = MobID()
            m.int = i
            assert m.int == i