0

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?

mathlete
  • 185
  • 13

2 Answers2

0

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

Martin Le
  • 719
  • 7
  • 14
0

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

Vijay Kachhadiya
  • 366
  • 2
  • 11
  • I've seen this code before. The animationTool is not available on AVAssets or AVURLAsset. – mathlete May 07 '16 at 17:44
  • I've seen this code before. The animationTool is not available on AVAssets or AVURLAsset. I'm already generating a new video to add video together so my player is player exporter.asset. I need a way to add the overlay to that. @Vijay Kachhadiya – mathlete May 07 '16 at 19:48
  • please look into this: https://stackoverflow.com/questions/51017511/how-to-add-watermark-on-final-video-after-merging-video-and-audio-asset-into-one – user2786 Jun 25 '18 at 06:50