You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've seen examples with this same code, but when I try to run it, it gives me an error.
I'm trying to add a marker to an AAF using this code:
with aaf2.open(destination, 'rw') as destination_aaf:
destination_mob_toplevel = next(destination_aaf.content.toplevel(), None)
ems = destination_aaf.create.EventMobSlot()
ems['EditRate'].value = '24000/1001'
ems['SlotID'].value = 1000
ems['PhysicalTrackNumber'].value = 10
sequence = destination_aaf.create.Sequence("DescriptiveMetadata") # This is the line causing the error
marker = destination_aaf.create.DescriptiveMarker()
marker.media_kind = "DescriptiveMetadata"
described_slots = set([1])
marker['DescribedSlots'].value = described_slots
marker['Position'].value = 100
marker['Comment'].value = "This is a comment"
marker['CommentMarkerUser'].value = "User Name"
sequence.components.append(marker)
ems.segment = sequence
destination_mob_toplevel.slots.append(ems)
I get the following error:
line 183, in add_markers
sequence = destination_aaf.create.Sequence("DescriptiveMetadata")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/file.py", line 63, in create_instance
return self.from_name(self.class_name, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/file.py", line 54, in from_name
obj.__init__(*args, **kwargs)
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/components.py", line 75, in __init__
super(Sequence, self).__init__(media_kind, length)
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/components.py", line 21, in __init__
self.media_kind = media_kind or 'picture'
^^^^^^^^^^^^^^^
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/components.py", line 48, in media_kind
self.datadef = self.root.dictionary.lookup_datadef(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/dictionary.py", line 239, in lookup_datadef
return lookup_def(self, name, DataDef, 'DataDefinitions')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/dictionary.py", line 37, in lookup_def
raise Exception("No Definition: %s" % str(name))
Exception: No Definition: descriptivemetadata
Oddly, if I change the line from "DescriptiveMetadata" to "Descriptive metadata" with a space like this: sequence = destination_aaf.create.Sequence("Descriptive metadata")
it gets past that line but has an error on the next line:
in edit_aaf_main
marker = destination_aaf.create.DescriptiveMarker()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/file.py", line 63, in create_instance
return self.from_name(self.class_name, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/file.py", line 54, in from_name
obj.__init__(*args, **kwargs)
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/components.py", line 339, in __init__
super(Event, self).__init__(media_kind='DescriptiveMetadata')
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/components.py", line 21, in __init__
self.media_kind = media_kind or 'picture'
^^^^^^^^^^^^^^^
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/components.py", line 48, in media_kind
self.datadef = self.root.dictionary.lookup_datadef(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/dictionary.py", line 239, in lookup_datadef
return lookup_def(self, name, DataDef, 'DataDefinitions')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/X/.local/share/virtualenvs/X/lib/python3.11/site-packages/aaf2/dictionary.py", line 37, in lookup_def
raise Exception("No Definition: %s" % str(name))
Exception: No Definition: descriptivemetadata
The text was updated successfully, but these errors were encountered:
I think I figured out the cause of the issue. The destination_aaf that I was modifying had a dictionary with some differences to an empty AAF created using pyaaf2. Since there was no definition of "descriptivemetadata" in that dictionary, an error was happening on those lines. That dictionary did have a definition of "Descriptive Metadata" with a space, so it got through that first step with that change, but then would fail on creating the marker, which again is expecting "descriptivemetadata" in the dictionary.
Is there a way to add new entries to an AAF's dictionary to resolve this issue?
I've seen examples with this same code, but when I try to run it, it gives me an error.
I'm trying to add a marker to an AAF using this code:
I get the following error:
Oddly, if I change the line from "DescriptiveMetadata" to "Descriptive metadata" with a space like this:
sequence = destination_aaf.create.Sequence("Descriptive metadata")
it gets past that line but has an error on the next line:
The text was updated successfully, but these errors were encountered: