@@ -1627,6 +1627,50 @@ def _contains_something_valuable(thing):
1627
1627
return True
1628
1628
1629
1629
1630
+ def _get_mobs_for_transcription (storage ):
1631
+ """
1632
+ When we describe our AAF into OTIO space, we apply the following heuristic:
1633
+
1634
+ 1) First look for top level mobs and if found use that to transcribe.
1635
+
1636
+ 2) If we don't have top level mobs, look for composition mobs and use them to
1637
+ transcribe.
1638
+
1639
+ 3) Lastly if we don't have either, try to use master mobs to transcribe.
1640
+
1641
+ If we don't find any Mobs, just tell the user and do transcrption on an empty
1642
+ list (to generate some 'empty-level' OTIO structure)
1643
+
1644
+ This heuristic is based on 'real-world' examples. There may still be some
1645
+ corner cases / open questions (like could there be metadata on both
1646
+ a composition mob and master mob? And if so, who would 'win'?)
1647
+
1648
+ In any way, this heuristic satisfies the current set of AAFs we are using
1649
+ in our test-environment.
1650
+
1651
+ """
1652
+
1653
+ top_level_mobs = list (storage .toplevel ())
1654
+
1655
+ if len (top_level_mobs ) > 0 :
1656
+ _transcribe_log ("---\n Transcribing top level mobs\n ---" )
1657
+ return top_level_mobs
1658
+
1659
+ composition_mobs = list (storage .compositionmobs ())
1660
+ if len (composition_mobs ) > 0 :
1661
+ _transcribe_log ("---\n Transcribing composition mobs\n ---" )
1662
+ return composition_mobs
1663
+
1664
+ master_mobs = list (storage .mastermobs ())
1665
+ if len (master_mobs ) > 0 :
1666
+ _transcribe_log ("---\n Transcribing master mobs\n ---" )
1667
+ return master_mobs
1668
+
1669
+ _transcribe_log ("---\n No mobs found to transcribe\n ---" )
1670
+
1671
+ return []
1672
+
1673
+
1630
1674
def read_from_file (
1631
1675
filepath ,
1632
1676
simplify = True ,
@@ -1657,25 +1701,20 @@ def read_from_file(
1657
1701
_BAKE_KEYFRAMED_PROPERTIES_VALUES = bake_keyframed_properties
1658
1702
1659
1703
with aaf2 .open (filepath ) as aaf_file :
1660
-
1661
- storage = aaf_file .content
1662
-
1663
- # Note: We're skipping: f.header
1704
+ # Note: We're skipping: aaf_file.header
1664
1705
# Is there something valuable in there?
1665
- _transcribe_log ("---\n Transcribing top level mobs\n ---" , 0 )
1666
1706
1667
- # Get just the top-level MOBS from the AAF
1668
- top = list (storage . toplevel () )
1707
+ storage = aaf_file . content
1708
+ mobs_to_transcribe = _get_mobs_for_transcription (storage )
1669
1709
1670
- # Transcribe just the top-level mobs
1671
- result = _transcribe (top , parents = list (), edit_rate = None )
1710
+ result = _transcribe (mobs_to_transcribe , parents = list (), edit_rate = None )
1672
1711
1673
1712
# Attach marker to the appropriate clip, gap etc.
1674
1713
if attach_markers :
1675
1714
result = _attach_markers (result )
1676
1715
1677
1716
# AAF is typically more deeply nested than OTIO.
1678
- # Lets try to simplify the structure by collapsing or removing
1717
+ # Let's try to simplify the structure by collapsing or removing
1679
1718
# unnecessary stuff.
1680
1719
if simplify :
1681
1720
result = _simplify (result )
0 commit comments