What is the best way to draw custom timestamp text over a video with AVFoundation?

Viewed 180

I've got an AVMutableVideoComposition that I'm exporting with AVAssetExportSession and I'm trying to overlay a custom timestamp that updates every second on top of it. Should I be using AVAssetWriter, multiple CALayers with CABasicAnimations, or something else entirely?

1 Answers

I recommend you write your own custom compositor by implementing the AVVideoCompositing protocol. Please refer to this answer and check out this (old) WWDC session.

Inside the startRequest method you can use Core Image to add the text overlay to the frame. You can generate a CIImage containing text using the CIAttributedTextImageGenerator filter.

Related