I used code from here ( https://stackoverflow.com/a/46560615/13671576 ) to create and save animated video from UIImages. When I used mask to CALayer, it takes too much time to save the video.
118 seconds video take approximately 20 minutes for saving.
code for mask :
let imageLayer = CALayer()
imageLayer.frame = CGRect(x: 0, y: 0, width: self.outputSize.width, height: self.outputSize.height)
imageLayer.contents = nextPhoto.cgImage
let path = UIBezierPath()
.... then I drew a path......
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.lineCap = .round
shapeLayer.strokeColor = UIColor.white.cgColor
shapeLayer.backgroundColor = UIColor.clear.cgColor
imageLayer.mask = shapeLayer
I used 40 images and added animation. Then I used Layer in the Video. when I'm trying to save, it takes too much time. But without masking, it takes approximately 40 seconds to save the video.
Can you share any efficient code/approach or any other technique to crate and save video?