Skip to content

Commit

Permalink
#551 AAF Adapter creates ExternalReference for UNC Path (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshBurnell authored and jminor committed Aug 28, 2019
1 parent 0209b17 commit 0c9655c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,20 @@ def _transcribe(item, parents, editRate, masterMobs):
mastermob = child_mastermob or parent_mastermob or None

if mastermob:
media = otio.schema.MissingReference()
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("\\", "/")
else:
media = otio.schema.MissingReference()
media.available_range = otio.opentime.TimeRange(
otio.opentime.RationalTime(media_start, editRate),
otio.opentime.RationalTime(media_length, editRate)
)
# copy the metadata from the master into the media_reference
mastermob_child = masterMobs.get(str(mastermob.mob_id))
media.metadata["AAF"] = mastermob_child.metadata.get("AAF", {})
result.media_reference = media

Expand Down
16 changes: 16 additions & 0 deletions contrib/opentimelineio_contrib/adapters/tests/test_aaf_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,22 @@ def test_multiple_top_level_mobs(self):
self.assertIsInstance(result, otio.schema.SerializableCollection)
self.assertEqual(2, len(result))

def test_external_reference_from_unc_path(self):
timeline = otio.adapters.read_from_file(SIMPLE_EXAMPLE_PATH)
video_track = timeline.video_tracks()[0]
first_clip = video_track[0]
self.assertIsInstance(first_clip.media_reference,
otio.schema.ExternalReference)

unc_path = first_clip.media_reference.metadata.get("AAF", {}) \
.get("UserComments", {}) \
.get("UNC Path")
unc_path = "file://" + unc_path
self.assertEqual(
first_clip.media_reference.target_url,
unc_path
)


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

0 comments on commit 0c9655c

Please sign in to comment.