Skip to content

Commit b0fa788

Browse files
committed
Add a fix to discover local files that may be referenced off of an otio exported from a different machine with different root file paths.
1 parent 06f969f commit b0fa788

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Sources/OpenTimelineIO-AVFoundation/OpenTimelineIO-Extensions/ExternalReference.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,23 @@ extension ExternalReference
8181
return self.tryLoadAssetAtResolvedURL(url: sourceURL)
8282
}
8383
}
84+
85+
// edge case -
86+
// if a OTIO file was packaged with media but paths werent linked, we should check CWD for the file
87+
// as a last case attempt.
88+
if let filename = path.components(separatedBy: "/").last
89+
{
90+
let newFileURL = baseURL.appending(component: filename)
91+
92+
return self.tryLoadAssetAtResolvedURL(url: newFileURL)
93+
}
94+
95+
8496
}
8597

98+
99+
100+
86101
let missingMediaURL = Bundle.main.url(forResource: "MediaNotFound", withExtension: "mp4")!
87102

88103
return AVURLAsset(url: missingMediaURL)
@@ -122,12 +137,12 @@ extension ExternalReference
122137

123138
if supported
124139
{
125-
return AVURLAsset(url: url)
140+
return AVURLAsset(url: url, options: [AVURLAssetPreferPreciseDurationAndTimingKey : true])
126141
}
127142

128143
let notSupportedMedia = Bundle.main.url(forResource: "MediaNotSupported", withExtension: "mp4")!
129144

130-
return AVURLAsset(url: notSupportedMedia)
145+
return AVURLAsset(url: notSupportedMedia, options: [AVURLAssetPreferPreciseDurationAndTimingKey : true])
131146

132147
}
133148

0 commit comments

Comments
 (0)