How do I use AVVideoCompositionCoreAnimationTool with AVAssetExportSession without a preexisting background video?

All the examples of using AVVideoCompositionCoreAnimationTool with AVAssetExportSession that I've found set the properties of the session to match a preexisting video track passed as the asset in the session's init method. I need to export a cool CALayer with animations without a pre-existing video track. I know I need to use `AVVideoCompositionCoreAnimationTool(additionalLayer: ..., asTrackID: ...)` though I don't know what I'm suppossed to do with the track ID, or where I'm suppossed to get it. I figured out I need to initialize the session with an AVMutableComposition (which took hours to figure out), and I sort of expect I need to add a video track to that, but again I don't know what to do with the track id. So I'm still stuck when I begin exporting, with the two errors:


session error = Error Domain=AVFoundationErrorDomain Code=-11822 "Cannot Open" UserInfo={NSLocalizedFailureReason=This media format is not supported., NSLocalizedDescription=Cannot Open, NSUnderlyingError=0x604000259c20 {Error Domain=NSOSStatusErrorDomain Code=-16976 "(null)"}}


The output file is never created.


I tried fiddling with the presets of the session, I haven't found one which produces different errors yet.


Is there a recipe of how to use these two classes together somewhere, without a preexisting video background track?

I'd like for my users to be able to set the frame size & frame rate (perhaps from a popup list of predetermined options, if necessary).

I'm starting with macos.

Accepted Reply

I filed a technical support incident. There is no supported way to use the core animation tool without a pre-existing asset at a url. So I created a pre-existing video of 1 frame of nothing but black, and in my CA composition, I reduced it to a 0x0 area and gave it an opacity of 0.0. Feels like a complete waste to need to do all that work, and a complete waste to have burned one of my technical support tickets on finding out that's what I needed to do.

Replies

I filed a technical support incident. There is no supported way to use the core animation tool without a pre-existing asset at a url. So I created a pre-existing video of 1 frame of nothing but black, and in my CA composition, I reduced it to a 0x0 area and gave it an opacity of 0.0. Feels like a complete waste to need to do all that work, and a complete waste to have burned one of my technical support tickets on finding out that's what I needed to do.