Skip to content

Commit a44d71a

Browse files
jchen9jminor
authored andcommitted
AAF Adapter: Mob transcription heuristics (#1249)
* Look for composition mob first if it's available When we describe our AAF into OTIO space, we apply the following heuristic: 1) First look for top level mobs and if found use that to transcribe. 2) If we don't have top level mobs, look for composition mobs and use them to transcribe. 3) Lastly if we don't have either, try to use master mobs to transcribe. If we don't find any Mobs, just tell the user and do transcrption on an empty list (to generate some 'empty-level' OTIO structure) This heuristic is based on 'real-world' examples. There may still be some corner cases / open questions (like could there be metadata on both a composition mob and master mob? And if so, who would 'win'?) In any way, this heuristic satisfies the current set of AAFs we are using in our test-environment.
1 parent f0d7d83 commit a44d71a

File tree

1 file changed

+49
-10
lines changed

1 file changed

+49
-10
lines changed

contrib/opentimelineio_contrib/adapters/advanced_authoring_format.py

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,50 @@ def _contains_something_valuable(thing):
14541454
return True
14551455

14561456

1457+
def _get_mobs_for_transcription(storage):
1458+
"""
1459+
When we describe our AAF into OTIO space, we apply the following heuristic:
1460+
1461+
1) First look for top level mobs and if found use that to transcribe.
1462+
1463+
2) If we don't have top level mobs, look for composition mobs and use them to
1464+
transcribe.
1465+
1466+
3) Lastly if we don't have either, try to use master mobs to transcribe.
1467+
1468+
If we don't find any Mobs, just tell the user and do transcrption on an empty
1469+
list (to generate some 'empty-level' OTIO structure)
1470+
1471+
This heuristic is based on 'real-world' examples. There may still be some
1472+
corner cases / open questions (like could there be metadata on both
1473+
a composition mob and master mob? And if so, who would 'win'?)
1474+
1475+
In any way, this heuristic satisfies the current set of AAFs we are using
1476+
in our test-environment.
1477+
1478+
"""
1479+
1480+
top_level_mobs = list(storage.toplevel())
1481+
1482+
if len(top_level_mobs) > 0:
1483+
_transcribe_log("---\nTranscribing top level mobs\n---")
1484+
return top_level_mobs
1485+
1486+
composition_mobs = list(storage.compositionmobs())
1487+
if len(composition_mobs) > 0:
1488+
_transcribe_log("---\nTranscribing composition mobs\n---")
1489+
return composition_mobs
1490+
1491+
master_mobs = list(storage.mastermobs())
1492+
if len(master_mobs) > 0:
1493+
_transcribe_log("---\nTranscribing master mobs\n---")
1494+
return master_mobs
1495+
1496+
_transcribe_log("---\nNo mobs found to transcribe\n---")
1497+
1498+
return []
1499+
1500+
14571501
def read_from_file(
14581502
filepath,
14591503
simplify=True,
@@ -1484,25 +1528,20 @@ def read_from_file(
14841528
_BAKE_KEYFRAMED_PROPERTIES_VALUES = bake_keyframed_properties
14851529

14861530
with aaf2.open(filepath) as aaf_file:
1487-
1488-
storage = aaf_file.content
1489-
1490-
# Note: We're skipping: f.header
1531+
# Note: We're skipping: aaf_file.header
14911532
# Is there something valuable in there?
1492-
_transcribe_log("---\nTranscribing top level mobs\n---", 0)
14931533

1494-
# Get just the top-level MOBS from the AAF
1495-
top = list(storage.toplevel())
1534+
storage = aaf_file.content
1535+
mobs_to_transcribe = _get_mobs_for_transcription(storage)
14961536

1497-
# Transcribe just the top-level mobs
1498-
result = _transcribe(top, parents=list(), edit_rate=None)
1537+
result = _transcribe(mobs_to_transcribe, parents=list(), edit_rate=None)
14991538

15001539
# Attach marker to the appropriate clip, gap etc.
15011540
if attach_markers:
15021541
result = _attach_markers(result)
15031542

15041543
# AAF is typically more deeply nested than OTIO.
1505-
# Lets try to simplify the structure by collapsing or removing
1544+
# Let's try to simplify the structure by collapsing or removing
15061545
# unnecessary stuff.
15071546
if simplify:
15081547
result = _simplify(result)

0 commit comments

Comments
 (0)