Skip to content

Commit 65532c3

Browse files
committed
Update gap calculations
1 parent 242c790 commit 65532c3

File tree

1 file changed

+12
-6
lines changed
  • Sources/OpenTimelineIO-AVFoundation/OpenTimelineIO-Extensions

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,32 +83,38 @@ public extension Timeline
8383
let compositionVideoTrack = compositionVideoTrack //composition.mutableTrack(compatibleWith: sourceAssetFirstVideoTrack) ??
8484
else
8585
{
86-
8786
// TODO: GAP !?
8887
if let gap = item as? Gap,
8988
let compositionVideoTrack = compositionVideoTrack
9089
{
9190
do
9291
{
93-
let gapTimeRange = try gap.rangeInParent().toCMTimeRange()
92+
let gapTimeRangeOTIO = try gap.trimmedRangeInParent() ?? gap.rangeInParent()
93+
let gapTimeRange = gapTimeRangeOTIO.toCMTimeRange()
9494
compositionVideoTrack.insertEmptyTimeRange(gapTimeRange)
95-
95+
compositionVideoTrack.preferredTransform = .identity
96+
9697
let compositionLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: compositionVideoTrack)
9798
let compositionLayerInstructions = [compositionLayerInstruction]
9899

99100
// Video Composition Instruction
100101
let compositionVideoInstruction = AVMutableVideoCompositionInstruction()
101102
compositionVideoInstruction.layerInstructions = compositionLayerInstructions
102103
compositionVideoInstruction.timeRange = gapTimeRange
103-
compositionVideoInstruction.enablePostProcessing = true
104-
compositionVideoInstruction.backgroundColor = CGColor.black
104+
compositionVideoInstruction.enablePostProcessing = false
105+
compositionVideoInstruction.backgroundColor = CGColor(gray: 0, alpha: 0)
105106
compositionVideoInstructions.append( compositionVideoInstruction)
106107
}
107108
catch
108109
{
109110
continue
110111
}
111112
}
113+
else
114+
{
115+
print("Got unsupported Item type")
116+
}
117+
112118
continue
113119
}
114120

@@ -153,7 +159,7 @@ public extension Timeline
153159
compositionVideoInstruction.layerInstructions = compositionLayerInstructions
154160
compositionVideoInstruction.timeRange = trackTimeRange
155161
compositionVideoInstruction.enablePostProcessing = true
156-
compositionVideoInstruction.backgroundColor = CGColor(gray: 0, alpha: 1)
162+
compositionVideoInstruction.backgroundColor = CGColor(gray: 0, alpha: 0)
157163
compositionVideoInstructions.append( compositionVideoInstruction)
158164
}
159165
}

0 commit comments

Comments
 (0)