1

In my app I am recording camera output with AVFoundation. I am trying to save not just camera output, but also GUI layout(overlay) presented over camera surface.

I am executing some basic animations on GUI layer( showing and hiding of UIView and UIProgressView animation).

enter image description here

So is it somehow possible to record camera output with animated overlay?

My research:

1.) https://www.raywenderlich.com/2734-avfoundation-tutorial-adding-overlays-and-animations-to-videos

Post processing is not an option. And this solution would not work for my problem.

2.) iPhone Watermark on recorded Video. So it is possible to add watermark. Maybe it would be possible to capture frame from camera, capture frame from overlay then overlaying the captured camera frame with the captured overlay frame? :(

kostik
  • 639
  • 2
  • 10
  • 25

1 Answers1

0

My solution (i am working on it right now) is create an object that subclass a CALayer and add it to your preview uiview.layer.

protocol VideoCameraLayer {
  func playAnimation()
  func stopAnimation()
}

class CircleFaceLayer: : CALayer,VideoCameraLayer{
  init(){
   //... add sublayers to this layer or whatever you need 
  }

  func playAnimation(){
  //Add animation/s to your layer/sublayers
  }

  func stopAnimation(){
  //Pause animation/s to your layer/sublayers
  }
}

You could use this object and sublayering in your avassetexportsession.animatioToll and in your preview layer in your UIView:

 let animatedLayer:VideoCameraLayer = CircleFaceLayer()
 self.view.layer.addSublayer(animatedLayer)