I am using a
AVVideoCoreAnimationTool
to render titles on top of a video composition.
I used to use
+videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:inLayer:
to instantiate the animation tool.
However, I now need to use a custom compositor to render the video composition. I want to use
videoCompositionCoreAnimationToolWithAdditionalLayer:asTrackID:
so that I have access to an asset track with the titles in my compositor.
However, I can't get titles to render when adding the core animation layer as a track.
In my custom compositor I have access to the track, i.e. I can get a pixelBuffer for the trackID I have assigned for the Core Animation layer when instantiating the animation tool. But these pixel buffers are empty.
- (void)startVideoCompositionRequest:(AVAsynchronousVideoCompositionRequest *)request
{
CMPersistentTrackID titleTrackID = ...
CVPixelBufferRef titlePixelBuffer = [request sourceFrameByTrackID:titleTrackID];
//titlePixelBuffer is valid pixel buffer but never contains any pixel data
}
When I set up the core animation tool the same way, but don't use a custom compositor, the title layer also isn't rendered.
If I set up the animation tool using
+videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:inLayer:
and don't use a custom compositor the title layer is rendered as it should.
Is there anything I'm missing?
(I am also adding the sourceTrackID of the title track to the composition's AVVideoCompositionInstruction instances)