You want to overlay UIView
's, but if you don't mind using CALayer
s you could
add your overlay after export using AVAssetExportSession
's AVVideoComposition
property. It has a property, AVVideoCompositionCoreAnimationTool *animationTool
which lets you add animating CALayer
s to your output, although I think you're out of luck if your overlay's appearance can't be described by CABasicAnimation
. Your example of a display heading may be possible, although I imagine something as simple as a current time counter would not. If you can live with this restriction, the WWDC 2010 code sample 'AVEditDemo' is a good starting point.
If you need more control, you could manually render the overlay UIView
onto the capture frames, using [view.layer renderInContext:contextToThenRenderToFrame]
and then write these frames to file using AVAssetWriter
(once you capture frames to memory you can no longer use AVCaptureMovieFileOutput
).
Warning: the frames you are capturing may not arrive at a uniform rate and depend on ambient lighting and even system load. If your overlay changes at a higher rate than the capture video, then you will need to repeat frames in the second solution. This is handled for you by AVVideoComposition
in the first solution.
P.S. Solution two is fiddly, but without going into details, iOS7 seems to have made this a lot easier.