RealCasually
RealCasually

Reputation: 3613

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

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?

Upvotes: 3

Views: 310

Answers (1)

Frank Rupprecht
Frank Rupprecht

Reputation: 10408

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.

Upvotes: 1

Related Questions