Rukshan
Rukshan

Reputation: 8066

iOS combining videos using AVFoundation

What is the method of cropping and combining video using AVFoundation? I need to crop away x number of pixels from the top (of a video) and fill that potion of the video with a different video. Is this possible?

Upvotes: 2

Views: 382

Answers (2)

Bjorn Roche
Bjorn Roche

Reputation: 11469

Yes, it's possible, but tricky. You need to:

  • create an AVMutableVideoComposition and add two tracks with the two videos you want to combine.
  • shift the video on top up by the amount you want. You do this by figuring out the appropriate affine transform and build the AVMutableVideoCompositionInstructions with that affine transform applied.

It's all very messy. These slides will help you through it:

http://www.slideshare.net/invalidname/advanced-av-foundation-cocoaconf-aug-11

Upvotes: 1

Art Gillespie
Art Gillespie

Reputation: 8757

Unfortunately, no. There's no way to crop or mask video on the fly in AVFoundation. You could translate the video down the render area (effectively 'cropping' the bottom) using AVMutableVideoComposition and AVMutableVideoCompositionLayerInstructions setTransform:atTime:

Upvotes: 0

Related Questions