mathlete
mathlete

Reputation: 181

Overlay to AVAsset Video

I have a video saved in an AVAsset. Is there a simply way for me to add an overlay to the video so that I can have a watermark in the corner of the screen?

I am already adding it to an AVMutableCompositionTrack then creating an AVAssetExportSession. Or is it impossible and do I need to create an instance of AVMutableVideoComposition as well and how do I so?

Is there a way for me to convert my AVAsset to an AVMutableVideoComposition and back?

Upvotes: 0

Views: 481

Answers (2)

Vijay Kachhadiya
Vijay Kachhadiya

Reputation: 376

Please try this code to add overlay on video:

 CALayer *overlayLayer = [CALayer layer];
 UIImage *overlayImage = [UIImage imageNamed:@"overlay.png"];
 [overlayLayer setContents:(id)[overlayImage CGImage]];
 overlayLayer.frame = CGRectMake(0, 0, size.width, size.height);
 [overlayLayer setMasksToBounds:YES];

 //Set Up the Parent Layer
 CALayer *parentLayer = [CALayer layer];
 CALayer *videoLayer = [CALayer layer];
 parentLayer.frame = CGRectMake(0, 0, size.width, size.height);
 videoLayer.frame = CGRectMake(0, 0, size.width, size.height);
 [parentLayer addSublayer:videoLayer];
 [parentLayer addSublayer:overlayLayer];

Please check following link also Its may be helpful to you

http://www.raywenderlich.com/30200/avfoundation-tutorial-adding-overlays-and-animations-to-videos

Upvotes: 0

Martin Le
Martin Le

Reputation: 719

This library has your request function. You can find your answer by reading source code. Hope this help ;)

Upvotes: 0

Related Questions