Skip to content
Permalink
Browse files

Extract target_url from Essence locator in SourceMob (#588)

* Added test AAF and unittest (and adapters/tests/__init__.py for convenience)
  • Loading branch information...
JoshBurnell authored and jminor committed Oct 3, 2019
1 parent b709091 commit 977b65b2d19940b3eca72335055afcee82570a21
@@ -298,15 +298,38 @@ def _transcribe(item, parents, editRate, masterMobs):
mastermob = child_mastermob or parent_mastermob or None

if mastermob:
# get target path
mastermob_child = masterMobs.get(str(mastermob.mob_id))
unc_path = (mastermob_child.metadata.get("AAF", {})
.get("UserComments", {})
.get("UNC Path"))
if unc_path:
media = otio.schema.ExternalReference()
media.target_url = "file://" + unc_path.replace("\\", "/")
target_path = (mastermob_child.metadata.get("AAF", {})
.get("UserComments", {})
.get("UNC Path"))
if not target_path:
# retrieve locator form the MasterMob's Essence
for mobslot in mastermob.slots:
if isinstance(mobslot.segment, aaf2.components.SourceClip):
sourcemob = mobslot.segment.mob
locator = None
# different essences store locators in different places
if (isinstance(sourcemob.descriptor,
aaf2.essence.DigitalImageDescriptor)
and sourcemob.descriptor.locator):
locator = sourcemob.descriptor.locator[0]
elif "Locator" in sourcemob.descriptor.keys():
locator = sourcemob.descriptor["Locator"].value[0]

if locator:
target_path = locator["URLString"].value

# if we have target path, create an ExternalReference, otherwise
# create an MissingReference.
if target_path:
if not target_path.startswith("file://"):
target_path = "file://" + target_path
target_path = target_path.replace("\\", "/")
media = otio.schema.ExternalReference(target_url=target_path)
else:
media = otio.schema.MissingReference()

media.available_range = otio.opentime.TimeRange(
otio.opentime.RationalTime(media_start, editRate),
otio.opentime.RationalTime(media_length, editRate)
No changes.
Binary file not shown.
@@ -134,6 +134,10 @@
SAMPLE_DATA_DIR,
"gaps.otio"
)
COMPOSITE_PATH = os.path.join(
SAMPLE_DATA_DIR,
"composite.aaf"
)


def safe_str(maybe_str):
@@ -848,6 +852,38 @@ def test_external_reference_from_unc_path(self):
unc_path
)

def test_external_reference_paths(self):
timeline = otio.adapters.read_from_file(COMPOSITE_PATH)
video_target_urls = [
[
"file:////animation/root/work/editorial/jburnell/700/1.aaf",
"file:////animation/root/work/editorial/jburnell/700/2.aaf",
"file:////animation/root/work/editorial/jburnell/700/3.aaf"
],
[
"file:///C%3A/Avid%20MediaFiles/MXF/1/700.Exported.03_Vi48896FA0V.mxf"
]
]
audio_target_urls = [
[
"file:///C%3A/OMFI%20MediaFiles/700.ExportA01.5D8A14612890A.aif"
]
]

for track_index, video_track in enumerate(timeline.video_tracks()):
for clip_index, clip in enumerate(video_track):
self.assertIsInstance(clip.media_reference,
otio.schema.ExternalReference)
self.assertEqual(clip.media_reference.target_url,
video_target_urls[track_index][clip_index])

for track_index, audio_track in enumerate(timeline.audio_tracks()):
for clip_index, clip in enumerate(audio_track):
self.assertIsInstance(clip.media_reference,
otio.schema.ExternalReference)
self.assertEqual(clip.media_reference.target_url,
audio_target_urls[track_index][clip_index])


class AAFWriterTests(unittest.TestCase):
def test_aaf_writer_gaps(self):

0 comments on commit 977b65b

Please sign in to comment.
You can’t perform that action at this time.