7

I'm trying to place some text of a part of a video that I'm creating. I realize that I can use a layer with text over an entire length of the video using CALayers, but how do I do it over only part of the video? After some research I have found that you can create a AVMutableCompositionTrack of type AVMediaTypeText, and it seems like that might do the trick; however, I cannot find any examples of how to declare, instantiate, etc of such a track?

I'm declaring it as such :

AVMutableCompositionTrack *textTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeText preferredTrackID:kCMPersistentTrackID_Invalid];

now how do I actually add text to it or instantiate with it with a string?

any input appreciated.

pikovayadama
  • 808
  • 2
  • 8
  • 26
  • 1
    Did you ever solve this issue? I find I can't use CALayer since it introduces a lot of complicated calculations I don't think is necessary if all i want to do is display text at discrete times int he video – Michael Nguyen Jun 14 '14 at 06:14
  • 1
    @marina and @ Michael Nguyen have you found solution to this issue? I am also facing same issue. – Payal Maniyar Feb 24 '17 at 10:42

1 Answers1

0

To add a text overlay to a video, you can use AVMutableVideoComposition object that will be assigned to AVAssetExportSession's videoComposition property.

Check out this sample project from app:

https://developer.apple.com/library/ios/samplecode/AVSimpleEditoriOS/Introduction/Intro.html

Gaurav Singh
  • 1,897
  • 14
  • 22