Group Group Group Group Group Group Group Group Group Forums

AVFoundation Tutorial: Adding Overlays and Animations to Videos

AVFoundation is the framework in iOS that lets you perform video editing. Add overlays and animations to your videos in this AVFoundation tutorial!

This is a companion discussion topic for the original entry at

I am adding an image overlay on the video at origin(0,0).But the generated video shows overlay at the bottom left corner instead of showing it at the top left corner.

Hi Raywenderlich.

I have one requirement and i was following your tutorial.

In this tutorial you have shown how to add effects on Video.

My requirement is to add animation on video.

There are two types of players

  1. Golf learner 2 Professional

Golf learner will record his video while playing golf and will send to Pro.

Now Pro will draw over the video and point out the mistakes using circle, Straight line etc…

And this drawing will be saved into a new video and then video will be sent back to Learner.

I am stuck here in this logic (Recording).

Help will be appreciated !

can you please reply?

Is there any way so I can overlay a video over a video?

Hi, I am relatively new to IOS development and AVFoundation. I am attempting to insert a text overlay in a project I have written in Swift. The text appears on the screen but it is distorted (skewed). I was not able to find any real examples of this topic written in Swift.
Would you be able to advise. Below is the code I am using. It is an attempt of a conversion from Objective-C code.
The “showInBounds” variable is a CGSize of a view in which the AVPlayer is located.
Thank you.

let textLayer = CATextLayer()
textLayer.backgroundColor = UIColor.clearColor().CGColor
textLayer.foregroundColor = UIColor.whiteColor().CGColor
textLayer.string = “T E S T”
textLayer.font = UIFont(name: “Helvetica”, size: 28)
textLayer.shadowOpacity = 0.5
textLayer.alignmentMode = kCAAlignmentCenter
textLayer.frame = CGRectMake(0, 50, showInBounds.width, showInBounds.height/6)
textLayer.shouldRasterize = true

    let parentLayer = CALayer()
    let videoLayer = CALayer()
    parentLayer.frame = CGRectMake(0, 0, showInBounds.width, showInBounds.height);
    videoLayer.frame = CGRectMake(0, 0, showInBounds.width, showInBounds.height);
    mainComposition.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videoLayer, inLayer: parentLayer)
    return (mixComposition, mainComposition)

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]