markreidvfx / pyaaf2

Read and write Advanced Authoring Format (AAF) files
http://pyaaf.readthedocs.io
MIT License
133 stars 36 forks source link

Adding nested attributes to master mob attributes... #128

Closed TrevorAyl closed 1 month ago

TrevorAyl commented 8 months ago

I'm seeing if there is a way to add the modified clip audio to a master mob? (i.e. where a multiple channel file is set to be stereo / 7.1 etc)

This is the attributes I'm trying to add - (16 channel clip is modified in Avid Media Composer to be A1&2: Stereo A3: Mono A4: Mono A5&6: Stereo A7: Mono A8: Mono A9-16: 7.1 SMPTE)

    ('_CHANNEL_GROUP_LIST', 'ST:A1A2,ST:A5A6,71:A9A11A10A13A14A15A16A12,'), 
    ('_ASOUND_FIELD_GROUP_LIST', 
        Attributes  ([
            ('MCA_SGL_SIZE', 3), 
            ('MCA_SGL_ITEM_0', 
                Attributes  ([
                    ('MCA_SG_FORMAT', 2), 
                    ('MCA_SG_TRACKS', '1,2'),   
                    ('MCA_SG_RFC5646_SPOKEN_LANGUAGE', ''), 
                    ('MCA_SG_AUDIO_CONTENT_KIND', bytearray(b'\x00\x00\x00')), 
                    ('MCA_SG_AUDIO_ELEMENT_KIND', bytearray(b'\x00\x00\x00')), 
                    ('MCA_SG_TITLE', bytearray(b'\x00\x00\x00')), 
                    ('MCA_SG_TITLE_VERSION', bytearray(b'\x00\x00\x00'))
                ])
            ), 
    ('MCA_SGL_ITEM_1', 
        Attributes ([
            ('MCA_SG_FORMAT', 2), 
            ('MCA_SG_TRACKS', '5,6'), 
            ('MCA_SG_RFC5646_SPOKEN_LANGUAGE', ''), 
            ('MCA_SG_AUDIO_CONTENT_KIND', bytearray(b'\x00\x00\x00')), 
            ('MCA_SG_AUDIO_ELEMENT_KIND', bytearray(b'\x00\x00\x00')),  
            ('MCA_SG_TITLE', bytearray(b'\x00\x00\x00')), 
            ('MCA_SG_TITLE_VERSION', bytearray(b'\x00\x00\x00'))
        ])
    ), 
    ('MCA_SGL_ITEM_2', 
        Attributes([
            ('MCA_SG_FORMAT', 4), 
            ('MCA_SG_TRACKS', '9,14,11,10,13,15,16,12'), 
            ('MCA_SG_RFC5646_SPOKEN_LANGUAGE', ''), 
            ('MCA_SG_AUDIO_CONTENT_KIND', bytearray(b'\x00\x00\x00')), 
            ('MCA_SG_AUDIO_ELEMENT_KIND', bytearray(b'\x00\x00\x00')), 
            ('MCA_SG_TITLE', bytearray(b'\x00\x00\x00')),
            ('MCA_SG_TITLE_VERSION', bytearray(b'\x00\x00\x00'))
        ])
    )
])

I'm using

    # Master Mob
    mob = f.create.Composition(mob_type="MasterMob")
    mob.name = clip_mob_name
    mob.edit_rate = edit_rate # otherwise defaults to 25

    # Add master mob colors here
    mob.attributes = f.create.Attributes()
    mob.attributes['_COLOR_R'] = convert_8_16bit(clip_color[0])
    mob.attributes['_COLOR_G'] = convert_8_16bit(clip_color[1])
    mob.attributes['_COLOR_B'] = convert_8_16bit(clip_color[2])

To add clip colours to the Master Mob.

Is there a way to get the SOUND listings above added to?

I tried a few things -

# Add channel group list and audio sound field group list attributes
mob.attributes['_CHANNEL_GROUP_LIST'] = 'ST:A1A2,ST:A5A6,71:A9A11A10A13A14A15A16A12'

asound_field_group_list = [
    ('MCA_SGL_SIZE', 3),
    ('MCA_SGL_ITEM_0', [
        ('MCA_SG_FORMAT', 2),
        ('MCA_SG_TRACKS', '1,2'),
        ('MCA_SG_RFC5646_SPOKEN_LANGUAGE', ''),
        ('MCA_SG_AUDIO_CONTENT_KIND', bytearray(b'\x00\x00\x00')),
        ('MCA_SG_AUDIO_ELEMENT_KIND', bytearray(b'\x00\x00\x00')),
        ('MCA_SG_TITLE', bytearray(b'\x00\x00\x00')),
        ('MCA_SG_TITLE_VERSION', bytearray(b'\x00\x00\x00'))
    ]),
    ('MCA_SGL_ITEM_1', [
        ('MCA_SG_FORMAT', 2),
        ('MCA_SG_TRACKS', '5,6'),
        ('MCA_SG_RFC5646_SPOKEN_LANGUAGE', ''),
        ('MCA_SG_AUDIO_CONTENT_KIND', bytearray(b'\x00\x00\x00')),
        ('MCA_SG_AUDIO_ELEMENT_KIND', bytearray(b'\x00\x00\x00')),
        ('MCA_SG_TITLE', bytearray(b'\x00\x00\x00')),
        ('MCA_SG_TITLE_VERSION', bytearray(b'\x00\x00\x00'))
    ]),
    ('MCA_SGL_ITEM_2', [
        ('MCA_SG_FORMAT', 4),
        ('MCA_SG_TRACKS', '9,14,11,10,13,15,16,12'),
        ('MCA_SG_RFC5646_SPOKEN_LANGUAGE', ''),
        ('MCA_SG_AUDIO_CONTENT_KIND', bytearray(b'\x00\x00\x00')),
        ('MCA_SG_AUDIO_ELEMENT_KIND', bytearray(b'\x00\x00\x00')),
        ('MCA_SG_TITLE', bytearray(b'\x00\x00\x00')),
        ('MCA_SG_TITLE_VERSION', bytearray(b'\x00\x00\x00'))
    ])
]

mob.attributes['_ASOUND_FIELD_GROUP_LIST'] = asound_field_group_list

But it's obviously not correct - I think it's around the nested attributes.

TrevorAyl commented 8 months ago

Sorry, put this in pyaaf2 but I'm actually using pyavb atm