Skip to content

Commit

Permalink
Writer: added support for mob attribute list
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Lehr <[email protected]>
  • Loading branch information
timlehr committed Jul 20, 2024
1 parent e784e3e commit 373f61e
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/otio_aaf_adapter/adapters/aaf_adapter/aaf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def __init__(self, input_otio, aaf_file, **kwargs):

# transcribe timeline comments onto composition mob
self._transcribe_user_comments(input_otio, self.compositionmob)
self._transcribe_mob_attributes(input_otio, self.compositionmob)

def _unique_mastermob(self, otio_clip):
"""Get a unique mastermob, identified by clip metadata mob id."""
Expand All @@ -126,12 +127,14 @@ def _unique_mastermob(self, otio_clip):
self.aaf_file.content.mobs.append(mastermob)
self._unique_mastermobs[mob_id] = mastermob

# transcribe clip comments onto master mob
self._transcribe_user_comments(otio_clip, mastermob)
# transcribe clip comments / mob attributes onto master mob
self._transcribe_user_comments(otio_clip.media_reference, mastermob)
self._transcribe_mob_attributes(otio_clip, mastermob)

# transcribe media reference comments onto master mob.
# this might overwrite clip comments.
# transcribe media reference comments / mob attributes onto master mob.
# this might overwrite clip comments / attributes.
self._transcribe_user_comments(otio_clip.media_reference, mastermob)
self._transcribe_mob_attributes(otio_clip.media_reference, mastermob)

return mastermob

Expand Down Expand Up @@ -226,6 +229,22 @@ def _transcribe_user_comments(self, otio_item, target_mob):
f"'{type(val)}' for key '{key}'."
)

def _transcribe_mob_attributes(self, otio_item, target_mob):
"""Transcribes mob attribute list onto the `target_mob`.
This can be used to roundtrip specific mob config values, like audio channel
settings.
"""
mob_attr_map = otio_item.metadata.get("AAF", {}).get("MobAttributeList", {})
mob_attr_list = aaf2.misc.TaggedValueHelper(target_mob['MobAttributeList'])
for key, val in mob_attr_map.items():
if isinstance(val, (int, str)):
mob_attr_list[key] = val
elif isinstance(val, (float, Rational)):
mob_attr_list[key] = aaf2.rational.AAFRational(val)
else:
raise ValueError(f"Unsupported mob attribute type '{type(val)}' for "
f"key '{key}'.")


def validate_metadata(timeline):
"""Print a check of necessary metadata requirements for an otio timeline."""
Expand Down

0 comments on commit 373f61e

Please sign in to comment.