Skip to content

Commit 45fcddd

Browse files
committed
Attempt to fix a timing ambiguity / interpretation issue in the Premiere Pro OTIO usage of global start time.
1 parent ea1fcb5 commit 45fcddd

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,24 @@ public extension AVComposition
3232
{
3333
print("Making Timeline from Composition", self)
3434

35-
let timeline = Timeline(name: name, globalStartTime: config.globalStartTime )
35+
// Today OTIO has no way of describing frame rates
36+
// So some integrations presume the rate of the global start time
37+
// implies the frame rate of the sequence or project
38+
39+
let minFrameDuration = self.tracks(withMediaType: .video).reduce(.positiveInfinity) { min($0, $1.minFrameDuration) }
40+
41+
let globalStartTime:RationalTime
42+
43+
if minFrameDuration.isValid && minFrameDuration != .positiveInfinity
44+
{
45+
globalStartTime = config.globalStartTime.rescaled(to: Double(minFrameDuration.timescale) )
46+
}
47+
else
48+
{
49+
globalStartTime = config.globalStartTime
50+
}
51+
52+
let timeline = Timeline(name: name, globalStartTime: globalStartTime )
3653

3754
let all_tracks:[Track] = try self.tracks.compactMap { try $0.toOTIOTrack(config: config) }
3855

0 commit comments

Comments
 (0)