Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS SDK AVFoundation ... How do I compose a video asset with a drawing asset

What I have achieved so far:

Using AVFoundation services, I have placed a video in a UIView that a user can play, pause, etc (using AVPlayer, AVPlayerItem, AVPlayerLayer, etc)

I have placed a UIView (with transparent/clear background color) on top of the view that is supposed to show the playing video. I have also handled UIKit touch events to draw lines based on user interaction.

Now when I play the video and touch the UIView which is overlayed on that view, I can see lines drawn on the playing video.

What I want to do:

After the user is done with the drawing (which he thinks is overlayed on the video), I want my app to compose the original video and what the user interaction (lines being drawn, removed, etc) and export the result as another video file.

Any help or sample code will be highly appreciated.

like image 481
iexpert Avatar asked Jun 22 '12 10:06

iexpert


1 Answers

For compositing the content together, have a look at AVVideoCompositionCoreAnimationTool. It lets you add animations to a movie using CALayer objects.

For exporting, once you have your composition built and the CALayers rendering together, you can pass it straight to an AVAssetExportSession which will write it out to a video file.

like image 165
damian Avatar answered Oct 17 '22 01:10

damian