AVMutableVideoCompositionLayerInstruction assetTrack

For AVVideoComposition to work correctly, you should init AVMutableVideoCompositionLayerInstruction with AVCompositionTrack created by you, instead of AVAssetTrack provided by AVAsset. This may be unintuitive at first, because how do you apply instructions to the track you want? How do you do transitions if there is only one AVCompositionTrack? Well, you’d create two, and alternate between them. And yes, this requires a lot of work with time ranges.

See WWDC for basic graphical of this approach: 2011 Working with Media in AV Foundation https://developer.apple.com/videos/play/wwdc2011/415/.

Also take a look at AVCompositionDebugView to see this approach in action https://developer.apple.com/library/archive/technotes/tn2447/_index.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: