{"id":2950,"date":"2012-12-20T11:50:58","date_gmt":"2012-12-20T11:50:58","guid":{"rendered":"http:\/\/www.mobisoftinfotech.com\/blog\/?p=2950"},"modified":"2019-05-24T17:50:12","modified_gmt":"2019-05-24T12:20:12","slug":"video-manipulation-tutorial-iphone","status":"publish","type":"post","link":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone","title":{"rendered":"Video Manipulating Tutorial On iPhone"},"content":{"rendered":"<p>\u201cVideo Overlapping means merging of two or more video clips. We can also provide special effects, position, duration etc. for video clips as per the needs.\u201d<\/p>\n<p>For such type of video manipulation\/Video Editing we can use AVFoundation framework available in iOS.<\/p>\n<p>There are various ways to manipulate videos. Those are<br>\n1. Video Trimming<br>\n2. Merging number of videos into one video<br>\n3. Adding special effects and transition to existing video<br>\n4. Manipulation of text, image and audio in frame of video<br>\n5. Sound mixing in a video.<\/p>\n<p>In this tutorial, will focus more on <strong>\u201cAVFoundation framework\u201d<\/strong>. So that you can do manipulations of video on your own.<\/p>\n<p><strong>What is AVFoundation? <\/strong><\/p>\n<p><noscript><img decoding=\"async\" class=\"alignnone size-full wp-image-14954\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-.png\" alt=\"What is AVFoundation - Mobisoft Infotech\" width=\"855\" height=\"363\" srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-.png 855w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation--300x127.png 300w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation--768x326.png 768w\" sizes=\"(max-width: 855px) 100vw, 855px\"><\/noscript><img decoding=\"async\" class=\"alignnone size-full wp-image-14954 lazyload\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20363%22%3E%3C%2Fsvg%3E\" alt=\"What is AVFoundation - Mobisoft Infotech\" width=\"855\" height=\"363\" srcset=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20363%22%3E%3C%2Fsvg%3E 855w\" sizes=\"(max-width: 855px) 100vw, 855px\" data-srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-.png 855w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation--300x127.png 300w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation--768x326.png 768w\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-.png\"><\/p>\n<p>AVFoundation &#8211;<br>\nThis AVFoundation is core framework.In iPhone Architecture \u201cAVFoundation\u201d is present in between the Application layer (UIKit Framework) and Core Media Services Layer.<\/p>\n<p>This framework has advantages mentioned as below.<\/p>\n<p>Inspect &#8211; If you need to know details of an asset<br>\nPlay &#8211; In more sophisticated ways than are possible with e.g. MPMoviePlayer<br>\nCompose\/edit &#8211; Use the media you want, where and when you want it<br>\nRe-encode\/export &#8211; Create new assets<br>\nEnjoy full access to camera &#8211; Obtain data from input devices, with the option to write it to storage<\/p>\n<p>Because of the above features \u201cAVFoundation\u201d used for video manipulation.<\/p>\n<p>This framework can be used for &#8211;<br>\n1. Media Asset management<br>\n2. Media Editing<br>\n3. Audio, Video recording<br>\n4. Playback<br>\n5. Metadata management for media items<br>\n6. Track management<\/p>\n<h4><strong>Let&#8217;s discuss about AVFoundation framework classes which we are going to use.<\/strong><\/h4>\n<p><strong>AVAsset<\/strong> \u2013 AVAsset is an abstract class of AVFoundation which indicates media of any like audio, video etc. Each asset is collection of tracks.<\/p>\n<p><strong>AVAssetExportSession<\/strong> \u2013 This class is used for displaying output in the required form by preset. The preset can be LowQuality, MediumQuality, HighestQuality.<\/p>\n<p><strong>AVMutableComposition<\/strong> &#8211; AVComposition is used for temporal editing. AVComposition it is collection of tracks. Each track presents media of specific type e.g. audios, videos according to it&#8217;s timeline. AVMutableComposition is mutable subclass of AVComposition. We can use it to create new composition from existing assets.<br>\nTracks are fixed in AVComposition. For Track manipulation AVMutableComposition is used.<\/p>\n<p><strong>AVMutableCompositionTrack<\/strong> \u2013 Each track represented by AVCompositionTrack. And tracks includes a media type, track identifier etc. AVMutableCompositionTrack this is mutable subclass of AVCompositionTrack, that allows us for insert, remove, scale etc. operations on track segments without affecting their lower level representation.<\/p>\n<p><strong>AVMutableVideoComposition<\/strong> \u2013 This class is provided to add instructions. AVMutableVideoComposition contains array of AVMutableVideoCompositionInstruction.<\/p>\n<p><strong>AVMutableVideoCompositionInstruction<\/strong> &#8211; AVMutableComposition maintains an array of instructions i.e. AVMutableVideoCompositionInstruction to perform it&#8217;s composition.<\/p>\n<p><strong>AVMutableVideoCompositionLayerInstruction<\/strong> &#8211; AVVideoCompositionInstructions itself contains an Array of AVVideoCompositionLayerInstruction defined for each layer.<\/p>\n<h4><strong>Other than AVFoundation we are using below mentioned frameworks-<\/strong><\/h4>\n<p><strong>MediaPlayer framework<\/strong> &#8211;<br>\nThis framework is present in Application layer [Above UIKit framework] and it is used to play audio, video, music, movie etc.<br>\nThis Framework Provides classes like <span style=\"text-decoration: underline;\">MPMediaController <\/span>and <span style=\"text-decoration: underline;\">MPMediaViewController<\/span> used to play streamed video content.<br>\nIn Our tutorial we are going to use it for playing overlapped video.<br>\nInstead you can use AVPlayer also for playing overlapped video if you want custom player for video.<\/p>\n<p><strong>AssetsLibrary framework<\/strong> &#8211;<br>\nThis framework used to access and store videos and pictures from Photos application.<br>\nWe are going to save our video after overlapping to photos application.<br>\nFor that we are using <span style=\"text-decoration: underline;\">ALAssetsLibrary<\/span> class.<\/p>\n<p><strong>CoreMedia framework<\/strong> &#8211;<br>\nThis is low-level C interface.<br>\nThis framework is present in Core Services Layer. which is below the Application layer [below AVFoundation framework].<br>\nIt provides many of the primitives used in AVFoundation like Time related data structures and objets for description and carriage for media data.<br>\nHere we are going to use Time related data structures<br>\n<span style=\"text-decoration: underline;\">CMTime<\/span> \u2013 For arithmetic comparisons.<br>\n<span style=\"text-decoration: underline;\">CMTimeRange<\/span> \u2013 For containment, unions and intersection.<br>\nand we can variantly use classes from this framework as per our requirement.<\/p>\n<p><strong>MobileCoreServices framework<\/strong> &#8211;<br>\nThis framework is also from Core Services Layer means it is below the Application layer [below AVFoundation framework].<br>\nDefines low level types used in Uniform Type Identifiers (UTI&#8217;s).<br>\nwe are using here class<\/p>\n<p><span style=\"text-decoration: underline;\">UTCoreTypes<\/span> &#8211; it defines number of constants. Out of them we are going to use kUTTypeMovie referencing when we selecting media.<\/p>\n<h5><strong>I am going to take merging of two videos as an example for this tutorial &#8211; <\/strong><\/h5>\n<p>1. Create a new project with view based application named &#8216;VideoOverlappingDemo&#8217;<br>\n2. Include Following framework<\/p>\n<p><noscript><img decoding=\"async\" class=\"alignnone size-full wp-image-15043\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-1-1.png\" alt=\"AVFoundation\" width=\"855\" height=\"363\" srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-1-1.png 855w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-1-1-300x127.png 300w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-1-1-768x326.png 768w\" sizes=\"(max-width: 855px) 100vw, 855px\"><\/noscript><img decoding=\"async\" class=\"alignnone size-full wp-image-15043 lazyload\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20363%22%3E%3C%2Fsvg%3E\" alt=\"AVFoundation\" width=\"855\" height=\"363\" srcset=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20855%20363%22%3E%3C%2Fsvg%3E 855w\" sizes=\"(max-width: 855px) 100vw, 855px\" data-srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-1-1.png 855w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-1-1-300x127.png 300w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-1-1-768x326.png 768w\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/12\/What-is-AVFoundation-1-1.png\"><\/p>\n<h2><strong>Common setup &#8211;<\/strong><\/h2>\n<p>1. Add Three buttons to ViewController.xib as in figure below &#8211;<\/p>\n<p>2. Add this code into our ViewController.h file<\/p>\n<pre>[objc]\n#import &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;UIKit\/UIKit.h&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;\n#import &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;MobileCoreServices\/UTCoreTypes.h&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;\n\n@interface ViewController : UIViewController\n\n@property (nonatomic, strong) IBOutlet UIButton *videoOneButton;\n@property (nonatomic, strong) IBOutlet UIButton *videoTwoButton;\n@property (nonatomic, strong) IBOutlet UIButton *overlapVideoButton;\n@property (nonatomic, strong) NSURL *videoOneURL;\n@property (nonatomic, strong) NSURL *videoTwoURL;\n@property (nonatomic, strong) UIImagePickerController *picker;\n\n- (IBAction)videoOneButtonTapped:(id)sender;\n- (IBAction)videoTwoButtonTapped:(id)sender;\n- (IBAction)overlapVideoButtonTapped:(id)sender;\n@end\n[\/objc]<\/pre>\n<p>Implement UIImagePickerControllerDelegate for UIImagePickerController.<\/p>\n<p>4. Make connection in xib for all buttons and button actions &#8211;<\/p>\n<p><strong>Step 1 &#8211; Get Video From Media Library<br>\nStep 2 &#8211; Manipulation on video and save<br>\nStep 3 &#8211; play video<\/strong><\/p>\n<h6><strong>Step 1 &#8211; Get Video From Media Library<\/strong><\/h6>\n<p>1. Add below code into ViewController.m<\/p>\n<pre>[objc]\n#pragma mark - Event Handlers\n\n-(IBAction)videoOneButtonTapped:(id)sender {\nisVideoOne = YES;\n[self browseMediaLibraryFromViewController:self withDelegate:self];\n}\n\n- (IBAction)videoTwoButtonTapped:(id)sender {\nisVideoOne = NO;\n[self browseMediaLibraryFromViewController:self withDelegate:self];\n}\n[\/objc]<\/pre>\n<p>This method will be called on VideoOneButton and VideoTwoButton tapped respectively.<\/p>\n<p>2. Definition for method browseMediaLibraryFromViewController:withDelegate: as below &#8211;<\/p>\n<pre>[objc]\n#pragma mark - Private Methods\n\n- (BOOL)browseMediaLibraryFromViewController:(UIViewController *)controller withDelegate:(id)delegate {\n\n\/\/Validation\nif (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)\n|| (delegate == nil)\n|| (controller == nil)) {\n\nreturn NO;\n}\n\/\/Create image picker\n_picker = [[UIImagePickerController alloc] init];\nself.picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;\nself.picker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];\nself.picker.allowsEditing = YES;\nself.picker.delegate = self;\n[self presentViewController:self.picker animated:YES completion:nil];\n\nreturn YES;\n}\n[\/objc]<\/pre>\n<p>In this method we are presented a UIImagePickerController for SavedPhotosAlbum with media type Video.<\/p>\n<p>3. Add delegate methods for UIIMagePickerController as below-<\/p>\n<pre>[objc]\n#pragma mark - ImagePicker Delegate Methods\n\n- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {\n\/\/dismiss ImagePickerController\n[self.picker dismissViewControllerAnimated:YES completion:nil];\nNSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];\n\/\/handle Movie capture\n\nif ([mediaType isEqualToString:(NSString *)kUTTypeMovie]) {\n\nNSLog(@&quot;Matching Success&quot;);\nif (isVideoOne){\n\nNSLog(@&quot;Video One Loaded&quot;);\nUIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&quot;Video One Loaded&quot;\nmessage:@&quot;Video One Loaded&quot;\ndelegate:nil\ncancelButtonTitle:@&quot;OK&quot;\notherButtonTitles:nil];\n[alert show];\n\n\/\/capture selected videoOneURL\nself.videoOneURL = [info objectForKey:UIImagePickerControllerMediaURL];\nNSLog(@&quot;videoOneURL = %@&quot;,self.videoOneURL);\n\n} else {\n\nNSLog(@&quot;Video two Loaded&quot;);\nUIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&quot;Video Two Loaded&quot;\nmessage:@&quot;Video Two Loaded&quot;\ndelegate:nil\ncancelButtonTitle:@&quot;OK&quot;\notherButtonTitles:nil];\n[alert show];\n\n\/\/capture selected videoTwoURL\nself.videoTwoURL =[info objectForKey:UIImagePickerControllerMediaURL];\nNSLog(@&quot;videoTwoURL = %@&quot;,self.videoTwoURL);\n}\n\n}\n\n}\n[\/objc]<\/pre>\n<p>This method dismiss UIImagePickerController and handle movie capture.<\/p>\n<pre>[objc]\n[info objectForKey:UIImagePickerControllerMediaURL]; [\/objc]<\/pre>\n<p>with the help of this line capture video url.<\/p>\n<pre>[objc]\n- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {\n\n\/\/dismiss ImagePickerController\n[self.picker dismissViewControllerAnimated:YES completion:nil];\n}\n[\/objc]<\/pre>\n<p>This delegate method dismiss UIImagePickerController on the cancel button tapped of picker.<\/p>\n<h6><strong>Step 2 &#8211; Manipulation on video and saving<\/strong><\/h6>\n<p>1. Added new file CustomVideoOverlapper with superclass NSObject into our project.<\/p>\n<p>2. Add below code to CustomVideoOverlapper.h file &#8211;<\/p>\n<pre>[objc]\n#import &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;UIKit\/UIKit.h&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;\n\n#import &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;AVFoundation\/AVFoundation.h&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;\n#import &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;CoreMedia\/CoreMedia.h&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;\n#import &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;AssetsLibrary\/AssetsLibrary.h&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;\n\n@interface CustomVideoOverlapper : NSObject {\n\n}\n@property(nonatomic, strong) UIViewController *controller;\n- (id)initWithController:(UIViewController *)controller;\n\n- (void)videoOverlappingMethodWithVideoOneURL:(NSURL *)videoOneURL andVideoTwoURL:(NSURL *)videoTwoURL;\n\n@end\n[\/objc]<\/pre>\n<p>3. Add this code in CustomVideoOverlapper.m<\/p>\n<pre>[objc]\n@synthesize controller = _controller;\n#pragma mark - Initialisation\n- (id)initWithController:(UIViewController *)controller {\n\nself = [super init];\nif (self) {\nself.controller = controller;\n}\nreturn self;\n}\n[\/objc]<\/pre>\n<p>3. We need to add below code ViewController.h file<\/p>\n<pre>[objc]\n#import &quot;CustomVideoOverlapper.h&quot;\n@interface ViewController () {\n\nCustomVideoOverlapper *videoOverlapper;\nBOOL isVideoOne;\n}\n[\/objc]<\/pre>\n<p>4. and below code for EventHandler into ViewController.m file.<\/p>\n<pre>[objc]\n- (IBAction)overlapVideoButtonTapped:(id)sender {\nvideoOverlapper = [[CustomVideoOverlapper alloc] initWithController:self];\n\n\/\/Pass Two video URL&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;#039;s we saved previously for merging process\n[videoOverlapper videoOverlappingMethodWithVideoOneURL:self.videoOneURL andVideoTwoURL:self.videoTwoURL];\n}\n[\/objc]<\/pre>\n<p>this method will be called on Overlap Button Tapped.<\/p>\n<p>5. Definition for method videoOverlappingMethodWithVideoOneURL: andVideoTwoURL into<br>\nCustomVideoOverlapper.m file.Complete Video Overlapping method is here &#8211;<\/p>\n<pre>[objc]\n- (void)videoOverlappingMethodWithVideoOneURL:(NSURL *)videoOneURL andVideoTwoURL:(NSURL *)videoTwoURL {\n\n\/\/addedd ProgressHud\n[MBProgressHUD showHUDAddedTo:self.controller.view animated:YES];\n\nif (videoOneURL!= nil &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; videoTwoURL!=nil) {\n\n\/\/First Video\n\/\/firstAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@&quot;sample1&quot; ofType:@&quot;mp4&quot;]] options:nil];\nfirstAsset = [AVAsset assetWithURL:videoOneURL];\n\n\/\/second Video\n\/\/secondAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@&quot;sample2&quot; ofType:@&quot;mp4&quot;]] options:nil];\nsecondAsset = [AVAsset assetWithURL:videoTwoURL];\n}\n\nif (firstAsset != nil &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; secondAsset != nil) {\n\n\/\/Create AVMutableComposition object\nmixComposition = [[AVMutableComposition alloc] init];\n\n\/\/ create first track\nAVMutableCompositionTrack *firstTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];\n\n[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, firstAsset.duration)\nofTrack:[[firstAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]\natTime:kCMTimeZero\nerror:nil];\n\n\/\/create second track\nAVMutableCompositionTrack *secondTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];\n\n[secondTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, secondAsset.duration)\nofTrack:[[secondAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]\natTime:kCMTimeZero\nerror:nil];\n\n\/\/Main Instruction Layer\n\/\/crete Object of main Instruction layer and set timerange to it\n\nAVMutableVideoCompositionInstruction *mainInstruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];\n\n\/\/Duration For Final Video should be max Duration of both video\nCMTime finalDuration;\nCMTime result;\n\nNSLog(@&quot;values =%f and %f&quot;,CMTimeGetSeconds(firstAsset.duration),CMTimeGetSeconds(secondAsset.duration));\n\nif (CMTimeGetSeconds(firstAsset.duration) == CMTimeGetSeconds(secondAsset.duration)) {\n\nfinalDuration = firstAsset.duration;\n\n}else if (CMTimeGetSeconds(firstAsset.duration) &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; CMTimeGetSeconds(secondAsset.duration)) {\nfinalDuration = firstAsset.duration;\nresult = CMTimeSubtract(firstAsset.duration, secondAsset.duration);\n\n}else {\n\nfinalDuration = secondAsset.duration;\nresult = CMTimeSubtract(secondAsset.duration, firstAsset.duration);\n\n}\nmainInstruction.timeRange = CMTimeRangeMake(kCMTimeZero, secondAsset.duration);\n\n\/\/InstructionLayer for first Track\n\nAVMutableVideoCompositionLayerInstruction *firstlayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:firstTrack];\n\nCGAffineTransform scale = CGAffineTransformMakeScale(0.5f, 0.5f);\nCGAffineTransform move = CGAffineTransformMakeTranslation(320, 0);\n\n[firstlayerInstruction setTransform:CGAffineTransformConcat(scale, move) atTime:kCMTimeZero];\n\n\/\/InstructionLayer for second Track\n\nAVMutableVideoCompositionLayerInstruction *secondlayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:secondTrack];\n\nCGAffineTransform SecondScale = CGAffineTransformMakeScale(1.6f,1.6f);\n&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;a href=&quot;\/\/cheap-software-downloads.net\/&quot; onclick=&quot;javascript:_gaq.push(['_trackEvent','outbound-article','\/\/cheap-software-downloads.net\/']);&quot; id=&quot;link28084&quot;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;cheap software for students&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;\/a&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;script type=&quot;text\/javascript&quot;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; if (1==1) {document.getElementById(&quot;link28084&quot;).style.display=&quot;none&quot;;}&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;\/script&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;\nCGAffineTransform SecondMove = CGAffineTransformMakeTranslation(0,0);\n\n\/\/[secondlayerInstruction setOpacity:0.5 atTime:kCMTimeZero];\n\n[secondlayerInstruction setOpacityRampFromStartOpacity:0.0 toEndOpacity:1.0 timeRange:CMTimeRangeMake(CMTimeMakeWithSeconds(2.9,60), CMTimeMakeWithSeconds(8.0, 60))];\n\n[secondlayerInstruction setTransform:CGAffineTransformConcat(SecondScale,SecondMove) atTime:kCMTimeZero];\n\n\/\/Now adding FirstInstructionLayer and SecondInstructionLayer to mainInstruction\nmainInstruction.layerInstructions = [NSArray arrayWithObjects:firstlayerInstruction,secondlayerInstruction, nil];\n\n\/\/ attach Main Instrcution To VideoCopositionn\n\/\/we can attch multipe Instrction to it\n\nmainComposition = [AVMutableVideoComposition videoComposition];\nmainComposition.instructions = [NSArray arrayWithObjects:mainInstruction,nil];\nmainComposition.frameDuration = CMTimeMake(1, 30);\nmainComposition.renderSize = CGSizeMake(640, 480);\n\n\/\/ Get path To save merged video\nNSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);\n\nNSString *documentsDirectory = [paths objectAtIndex:0];\n\nNSString *myPathDocs = [documentsDirectory stringByAppendingPathComponent:\n[NSString stringWithFormat:@&quot;mergeVideo.mov&quot;]];\n\nNSFileManager *fileManager = [NSFileManager defaultManager];\n[fileManager removeItemAtPath:myPathDocs error:NULL];\n\nurl = [NSURL fileURLWithPath:myPathDocs];\nNSLog(@&quot;URL:- %@&quot;, [url description]);\n\n\/\/create Exporter\n\nAVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPresetHighestQuality];\n\nexporter.outputURL = url;\nexporter.outputFileType = AVFileTypeQuickTimeMovie;\nexporter.shouldOptimizeForNetworkUse = YES;\nexporter.videoComposition = mainComposition;\n[exporter exportAsynchronouslyWithCompletionHandler:^{\n\ndispatch_async(dispatch_get_main_queue(), ^{\n\n[self exportDidFinish:exporter];\n\n});\n}];\n\n}else {\n\nUIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&quot;Error!&quot; message:@&quot;Video Not Selected.PLease select videos to merege&quot;\ndelegate:self cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];\n[alert show];\n}\n\n}\n[\/objc]<\/pre>\n<p>In the above code we do the following &#8211;<\/p>\n<p>1.<\/p>\n<pre>[objc]\nAVAsset *firstAsset = [AVAsset assetWithURL:videoOneURL];\nAVAsset *secondAsset = [AVAsset assetWithURL:videoTwoURL];\n[\/objc]<\/pre>\n<p>using this code videos URL which we are obtained after selection of videos from media library to two different AVAsset objects.<\/p>\n<p>2. Create AVMutableComposition object.<\/p>\n<pre>[objc]\nAVMutableComposition *mixComposition = [[AVMutableComposition alloc] init];\n[\/objc]<\/pre>\n<p>3. Create AVMutableCompositionTrack object for firstAsset and secondAsset.<\/p>\n<pre>[objc]\nAVMutableCompositionTrack *firstTrack =\n[mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo\npreferredTrackID:kCMPersistentTrackID_Invalid];\n\n[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, firstAsset.duration)\nofTrack:[[firstAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]\natTime:kCMTimeZero\nerror:nil];\n[\/objc]<\/pre>\n<p>using Set time range for track using method <span style=\"text-decoration: underline;\">insertTimeRange:ofTrack:atTime:error:<\/span><br>\nBy default inserted track&#8217;s time set to it&#8217;s natural duration and rates.<\/p>\n<p>We can mange the duration for each video using <span style=\"text-decoration: underline;\">atTime<\/span> parameter of this method or we can scale it to different duration using method <span style=\"text-decoration: underline;\">scaleTimeRange:toDuration:<\/span><\/p>\n<p>Do same for secondAsset also.<\/p>\n<p>4. Now we can add instruction to AVMutableComposition such as video size, transitions, effects, etc. Without this we can not play both videos simultaneously. For that AVVideoComposition class is provided.<\/p>\n<p>AVMutableComposition maintains an array of instructions to perform it&#8217;s composition i.e. AVMutableVideoCompositionInstruction. AVVideoCompositionInstructions itself contains an Array of AVVideoCompositionLayerInstruction defined for each layer.<\/p>\n<pre>[objc]\n\/\/Main Instruction Layer\n\/\/crete Object of main Instruction layer and set timerange to it\n\nAVMutableVideoCompositionInstruction *mainInstruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];\n\n\/\/InstructionLayer for first Track\n\nAVMutableVideoCompositionLayerInstruction *firstlayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:firstTrack];\n\nCGAffineTransform scale = CGAffineTransformMakeScale(0.5f, 0.5f);\nCGAffineTransform move = CGAffineTransformMakeTranslation(320, 0);\n\n[firstlayerInstruction setTransform:CGAffineTransformConcat(scale, move) atTime:kCMTimeZero];\n\n\/\/InstructionLayer for second Track\n\nAVMutableVideoCompositionLayerInstruction *secondlayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:secondTrack];\n\nCGAffineTransform secondScale = CGAffineTransformMakeScale(1.3f,1.5f);\n\nCGAffineTransform secondMove = CGAffineTransformMakeTranslation(0,0);\n\n\/\/[secondlayerInstruction setOpacity:0.5 atTime:kCMTimeZero];\n\n[secondlayerInstruction setOpacityRampFromStartOpacity:0.0 toEndOpacity:1.0 timeRange:CMTimeRangeMake(CMTimeMakeWithSeconds(2.9,80), CMTimeMakeWithSeconds(8.0, 80))];\n\n[secondlayerInstruction setTransform:CGAffineTransformConcat(secondScale,secondMove) atTime:kCMTimeZero];\n\n\/\/Now adding FirstInstructionLayer and SecondInstructionLayer to mainInstruction\n\nmainInstruction.layerInstructions = [NSArray arrayWithObjects:firstlayerInstruction,secondlayerInstruction, nil];[\/objc]<\/pre>\n<p>We created a object of AVMutableVideoCompositionInstruction named \u201cmainInstruction\u201d.<br>\nCreate AVMutableVideoCompositionLayerInstruction object for firstTrack and secondTrack named as \u201cfirstlayerInstruction\u201d and \u201csecondlayerInstruction\u201d as above.<\/p>\n<p>Using CGAffineTransform assign move and scale to both videos as per our requirement of where we want location and size of video. <span style=\"text-decoration: underline;\">setTransform:atTime:<\/span> method provided by class AVMutableVideoCompositionLayerInstruction used to set CGAffineTransformation.<\/p>\n<p>In our example we set values for CGAffineTransformation as such second video occupy whole screen and first video at top of right corner.<br>\nNow adding AVMutableVideoCompositionLayerInstruction objects i.e. firstlayerInstruction and secondlayerInstruction to AVMutableVideoCompositionInstruction&#8217;s instance property layerInstructions[NSArray].<\/p>\n<p>5. Set time range to mainInstruction &#8211;<\/p>\n<pre>[objc]\n\/\/Duraton For Final Video should be max Duration of both video\nCMTime finalDuration;\nCMTime result;\n\nNSLog(@&quot;values =%f and %f&quot;,CMTimeGetSeconds(firstAsset.duration),CMTimeGetSeconds(secondAsset.duration));\n\nif (CMTimeGetSeconds(firstAsset.duration) == CMTimeGetSeconds(secondAsset.duration)) {\nfinalDuration = firstAsset.duration;\n}else if (CMTimeGetSeconds(firstAsset.duration) &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; CMTimeGetSeconds(secondAsset.duration)) {\nfinalDuration = firstAsset.duration;\nresult = CMTimeSubtract(firstAsset.duration, secondAsset.duration);\n}else {\nfinalDuration = secondAsset.duration;\nresult = CMTimeSubtract(secondAsset.duration, firstAsset.duration);\n}\n\n\/\/CMTime duration = MAX(secondAsset.duration , firstAsset.duration);\nmainInstruction.timeRange = CMTimeRangeMake(kCMTimeZero,finalDuration);\n[\/objc]<\/pre>\n<p>Set time range to mainInstruction as maximum of both the videos i.e. max (firstAsset.duration,secondAsset.duration), but duration is CMTime object, for comparison we need to convert them into integer or float so there is method called <span style=\"text-decoration: underline;\">CMTimeGetSeconds<\/span> provided by CMTime class. Then set check accordingly, means set duration for Final &#8216;mainInstruction&#8217; to max of both asset and if both equal then set any of it.<\/p>\n<p>6. Create AVMutableVideoComposition object with method videoComposition named \u201cmainComposition\u201d<\/p>\n<pre>[objc]\n\/\/ attach Main Instrcution To VideoCopositionn\n\/\/we can attch multipe Instrction to it\nAVMutableVideoComposition *mainComposition = [AVMutableVideoComposition videoComposition];\nmainComposition.instructions = [NSArray arrayWithObjects:mainInstruction,nil]; mainComposition.frameDuration = CMTimeMake(1, 30);\nmainComposition.renderSize = CGSizeMake(640, 480);[\/objc]<\/pre>\n<p>And add AVMutableVideoCompositionInstruction to it&#8217;s instance property \u2013 instructions and also set frameDuration and render size for mainComposition.<\/p>\n<p>We can add multiple AVMutableVideoCompositionInstruction objects to AVMutableVideoComposition object.<\/p>\n<p>In our example we have added only one AVMutableVideoCompositionInstruction.<\/p>\n<p>We can use multiple objects to add multiple layers of effects such as transition and fade but take care of that time ranges of the AVMutableVideoCompositionInstruction objects not to be overlap.<\/p>\n<p>7. Create Path for saving final Merged video as &#8211;<\/p>\n<pre>[objc]\n\/\/ Get path\nNSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);\nNSString *documentsDirectory = [paths objectAtIndex:0];\nNSString *myPathDocs = [documentsDirectory stringByAppendingPathComponent:\n[NSString stringWithFormat:@&quot;mergeVideo.mov&quot;]];\nNSFileManager *fileManager = [NSFileManager defaultManager];\n[fileManager removeItemAtPath:myPathDocs error:NULL];\nurl = [NSURL fileURLWithPath:myPathDocs];\n\nNSLog(@&quot;URL:- %@&quot;, [url description]);\n[\/objc]<\/pre>\n<p>8. Create AVAssetExportSession object named \u201cexporter\u201d.<\/p>\n<pre>[objc]\nAVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPresetHighestQuality];\nexporter.outputURL = url;\nexporter.outputFileType = AVFileTypeQuickTimeMovie;\nexporter.shouldOptimizeForNetworkUse = YES;\nexporter.videoComposition = mainComposition;\n[exporter exportAsynchronouslyWithCompletionHandler:^{\n\ndispatch_async(dispatch_get_main_queue(), ^{\n\n[self exportDidFinish:exporter];\n\n});\n}];\n[\/objc]<\/pre>\n<p>For exporter set asset to AVMutableComposition \u2013 &#8216;mixComposition&#8217; and set videoComposition to &#8216;mainComposition&#8217; i.e. AVMutableVideoComposition.<br>\nSet outputURL as path we are created in step 7 to exporter, and set outputFileType of exporter to AVFileTypeQuickTimeMovie.<\/p>\n<p>We can start export running by calling ExportAsynchronouslyWithCompletionHandler.<\/p>\n<p>9. ExportAsynchronouslyWithCompletionHandler &#8211; Starts asynchronous execution of an export session and it is return immediately. Status indicates the terminal state of the export session, and if a failure occurs, error describes the problem.<\/p>\n<p>completion handler calls exportDidFinish: Implementation of this method<\/p>\n<pre>[objc]\n-(void)exportDidFinish:(AVAssetExportSession*)session {\n\nNSLog(@&quot;exportDidFinish&quot;);\n\n\/\/Remove ProgressHud\n[MBProgressHUD hideHUDForView:self.controller.view animated:YES];\n\nif (session.status == AVAssetExportSessionStatusCompleted) {\n\nNSURL *outputURL = session.outputURL;\nALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];\n\nif ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:outputURL]) {\n\n[library writeVideoAtPathToSavedPhotosAlbum:outputURL completionBlock:^(NSURL *assetURL, NSError *error) {\n\ndispatch_async(dispatch_get_main_queue(), ^{\n\nif (error) {\n\nNSLog(@&quot;write Video To AssestsLibrary failed: %@&quot;, error);\nUIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&quot;Error&quot;\nmessage:@&quot;Video Saving Failed&quot;\ndelegate:nil\ncancelButtonTitle:@&quot;OK&quot;\notherButtonTitles:nil];\n[alert show];\n\n}else {\n\nUIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&quot;Video Saved&quot;\nmessage:@&quot;Saved To Photo Album&quot;\ndelegate:self\ncancelButtonTitle:@&quot;OK&quot;\notherButtonTitles:nil];\nalert.tag = 1000;\n[alert show];\n\nNSLog(@&quot;Writing3&quot;);\n\n}\n\n});\n}];\n\n}else {\n\nUIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&quot;Error!&quot;\nmessage:@&quot;Video asset export failed&quot;\ndelegate:self\ncancelButtonTitle:@&quot;OK&quot;\notherButtonTitles:nil];\n[alert show];\n}\n\n}\n\n}[\/objc]<\/pre>\n<p>In this method implementation check exporter status and if it is AVAssetExportSessionStatusCompleted then save that video to photo album with Path we set as above for final video by giving alert to save video or not and if we select save then handle validation for video saved successfully or not.<\/p>\n<p>If we selected for \u201cWant play video alert \u201c yes then below code will be called<\/p>\n<pre>[objc]\n#pragma mark - UIAlertView Delegate Method\n- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {\n\nif (alertView.tag == 1000) {\nif (buttonIndex == 0) {\n\nUIAlertView *playAlert = [[UIAlertView alloc] initWithTitle:@&quot;Play Video&quot;\nmessage:@&quot;Dou you want play it immdiately?&quot;\ndelegate:self\ncancelButtonTitle:@&quot;Yes&quot;\notherButtonTitles:@&quot;later&quot;, nil];\nplayAlert.tag = 2000;\n[playAlert show];\n\n}else {\n\n}\n\n}else if(alertView.tag == 2000){\n\nif (buttonIndex == 0) {\n\nCustomMoviePlayer *moviePlayer = [[CustomMoviePlayer alloc] initWithController:self.controller andURLForMovie:url];\n\n[moviePlayer playVideo];\n\n}\n}\n}[\/objc]<\/pre>\n<p>Now we are ready to play merged video. We can play video by AVPlayer of AVFoundation. Or we can play video with application layer framework Media Player.<\/p>\n<p>In our example we are using MediaPlayerViewController class of media player to play saved video.<\/p>\n<h6><strong>Step 3 \u2013 Play Saved Video Using MediaPlayerViewController<\/strong><\/h6>\n<p>1. Create file CustomMoviePlayer and include following code CustomMoviePlayer.h file &#8211;<\/p>\n<pre>[objc]\n#import &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;Foundation\/Foundation.h&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;\n#import &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;MediaPlayer\/MediaPlayer.h&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;\n\n@interface CustomMoviePlayer : NSObject\n\n@property(nonatomic, strong) UIViewController *controller;\n@property(nonatomic, strong) NSURL *url;\n\n- (id)initWithController:(UIViewController *)controller andURLForMovie:(NSURL *)url;\n- (void)playVideo;\n[\/objc]<\/pre>\n<p>2. Include below into CustomMoviePlayer.m file-<\/p>\n<pre>[objc]\n@synthesize url = _url;\n@synthesize controller = _controller;\n#pragma mark - Initialisation\n- (id)initWithController:(UIViewController *)controller andURLForMovie:(NSURL *)url {\nself = [super init];\nif (self) {\nself.controller = controller;\nself.url = url;\n}\nreturn self;\n}[\/objc]<\/pre>\n<p>3. code for playing video &#8211;<\/p>\n<pre>[objc]\n#pragma mark - Public Method\n\n- (void)playVideo {\n\nMPMoviePlayerViewController *theMovie = [[MPMoviePlayerViewController alloc]\ninitWithContentURL:self.url];\n[self.controller presentMoviePlayerViewControllerAnimated:theMovie];\n\n\/\/ Register for the playback finished notification\n[[NSNotificationCenter defaultCenter] addObserver:self\nselector:@selector(myMovieFinishedCallback:)\nname:MPMoviePlayerPlaybackDidFinishNotification\nobject:theMovie];\n}\n[\/objc]<\/pre>\n<p>Create Object of MPMoviePlayerViewController and pass URL for our saved video and set that object to presentMoviePlayerViewControllerAnimated for our own controller.<\/p>\n<p>Here register for playback notification, Adds a callback method that will be executed once the movie finishes playing &#8211; myMovieFinishedCallback: So video is playing here.<\/p>\n<p>4. myMovieFinishedCallback implementation &#8211;<\/p>\n<pre>[objc]\n#pragma mark - Notification\n\n- (void)myMovieFinishedCallback:(NSNotification *)notification {\n\n[self.controller dismissMoviePlayerViewControllerAnimated];\nMPMoviePlayerViewController *movie = [notification object];\n[[NSNotificationCenter defaultCenter] removeObserver:self\nname:MPMoviePlayerPlaybackDidFinishNotification object:movie];\n}\n[\/objc]<\/pre>\n<p>Here dismiss Movie player and remove that registered observer.<\/p>\n<p>After Merging Of two videos =&gt; <a href=\"\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2014\/08\/finalVideo.mov\">finalVideo<\/a><\/p>\n<p>Complete source code is available here \u2013 <a href=\"\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2014\/08\/VideoOverlappingDemo.zip\">VideoOverlappingDemo<\/a><\/p>\n<div style=\"display: none;\">765qwerty765<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u201cVideo Overlapping means merging of two or more video clips. We can also provide special effects, position, duration etc. for video clips as per the needs.\u201d For such type of video manipulation\/Video Editing we can use AVFoundation framework available in iOS. There are various ways to manipulate videos. Those are 1. Video Trimming 2. Merging [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7398,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"yes","footnotes":""},"categories":[3],"tags":[319,321,320,318],"class_list":["post-2950","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-iphone","tag-avfoundation","tag-ios-assetlibrary","tag-iphone-video-manipulation-tutorial","tag-video-manipulation"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Video Manipulating Tutorial On iPhone - Mobisoft Infotech<\/title>\n<meta name=\"description\" content=\"Video Overlapping means merging of two or more video clips.The following is a tutorial on AVFoundation framework.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Video Manipulating Tutorial On iPhone - Mobisoft Infotech\" \/>\n<meta property=\"og:description\" content=\"Video Overlapping means merging of two or more video clips.The following is a tutorial on AVFoundation framework.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone\" \/>\n<meta property=\"og:site_name\" content=\"Mobisoft Infotech\" \/>\n<meta property=\"article:published_time\" content=\"2012-12-20T11:50:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-24T12:20:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2015\/01\/Video-Manipulating-Tutorial-On-iphone_l-min.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"550\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Pritam Barhate\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pritam Barhate\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"19 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#article\",\"isPartOf\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone\"},\"author\":{\"name\":\"Pritam Barhate\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee\"},\"headline\":\"Video Manipulating Tutorial On iPhone\",\"datePublished\":\"2012-12-20T11:50:58+00:00\",\"dateModified\":\"2019-05-24T12:20:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone\"},\"wordCount\":1624,\"image\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2015\/01\/Video-Manipulating-Tutorial-On-iphone_l-min.jpg\",\"keywords\":[\"AVFOUNDATION\",\"iOS AssetLibrary\",\"iPhone video manipulation tutorial\",\"Video Manipulation\"],\"articleSection\":[\"iPhone - iPad\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone\",\"name\":\"Video Manipulating Tutorial On iPhone - Mobisoft Infotech\",\"isPartOf\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2015\/01\/Video-Manipulating-Tutorial-On-iphone_l-min.jpg\",\"datePublished\":\"2012-12-20T11:50:58+00:00\",\"dateModified\":\"2019-05-24T12:20:12+00:00\",\"author\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee\"},\"description\":\"Video Overlapping means merging of two or more video clips.The following is a tutorial on AVFoundation framework.\",\"breadcrumb\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#primaryimage\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2015\/01\/Video-Manipulating-Tutorial-On-iphone_l-min.jpg\",\"contentUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2015\/01\/Video-Manipulating-Tutorial-On-iphone_l-min.jpg\",\"width\":1920,\"height\":550,\"caption\":\"Video Manipulating Tutorial On iphone_l-min\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mobisoftinfotech.com\/resources\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Video Manipulating Tutorial On iPhone\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#website\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/\",\"name\":\"Mobisoft Infotech\",\"description\":\"Discover Mobility\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mobisoftinfotech.com\/resources\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee\",\"name\":\"Pritam Barhate\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g\",\"caption\":\"Pritam Barhate\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Video Manipulating Tutorial On iPhone - Mobisoft Infotech","description":"Video Overlapping means merging of two or more video clips.The following is a tutorial on AVFoundation framework.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone","og_locale":"en_US","og_type":"article","og_title":"Video Manipulating Tutorial On iPhone - Mobisoft Infotech","og_description":"Video Overlapping means merging of two or more video clips.The following is a tutorial on AVFoundation framework.","og_url":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone","og_site_name":"Mobisoft Infotech","article_published_time":"2012-12-20T11:50:58+00:00","article_modified_time":"2019-05-24T12:20:12+00:00","og_image":[{"width":1920,"height":550,"url":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2015\/01\/Video-Manipulating-Tutorial-On-iphone_l-min.jpg","type":"image\/jpeg"}],"author":"Pritam Barhate","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Pritam Barhate","Est. reading time":"19 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#article","isPartOf":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone"},"author":{"name":"Pritam Barhate","@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee"},"headline":"Video Manipulating Tutorial On iPhone","datePublished":"2012-12-20T11:50:58+00:00","dateModified":"2019-05-24T12:20:12+00:00","mainEntityOfPage":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone"},"wordCount":1624,"image":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#primaryimage"},"thumbnailUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2015\/01\/Video-Manipulating-Tutorial-On-iphone_l-min.jpg","keywords":["AVFOUNDATION","iOS AssetLibrary","iPhone video manipulation tutorial","Video Manipulation"],"articleSection":["iPhone - iPad"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone","url":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone","name":"Video Manipulating Tutorial On iPhone - Mobisoft Infotech","isPartOf":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#primaryimage"},"image":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#primaryimage"},"thumbnailUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2015\/01\/Video-Manipulating-Tutorial-On-iphone_l-min.jpg","datePublished":"2012-12-20T11:50:58+00:00","dateModified":"2019-05-24T12:20:12+00:00","author":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee"},"description":"Video Overlapping means merging of two or more video clips.The following is a tutorial on AVFoundation framework.","breadcrumb":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#primaryimage","url":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2015\/01\/Video-Manipulating-Tutorial-On-iphone_l-min.jpg","contentUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2015\/01\/Video-Manipulating-Tutorial-On-iphone_l-min.jpg","width":1920,"height":550,"caption":"Video Manipulating Tutorial On iphone_l-min"},{"@type":"BreadcrumbList","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/iphone\/video-manipulation-tutorial-iphone#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mobisoftinfotech.com\/resources\/"},{"@type":"ListItem","position":2,"name":"Video Manipulating Tutorial On iPhone"}]},{"@type":"WebSite","@id":"https:\/\/mobisoftinfotech.com\/resources\/#website","url":"https:\/\/mobisoftinfotech.com\/resources\/","name":"Mobisoft Infotech","description":"Discover Mobility","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mobisoftinfotech.com\/resources\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/fa762036b3364f26abeea146c01487ee","name":"Pritam Barhate","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0e481c7ce54b3567ac70ddfc493523eefce0bdc3ee69fd2654f8f60a79e2f178?s=96&r=g","caption":"Pritam Barhate"}}]}},"_links":{"self":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/2950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/comments?post=2950"}],"version-history":[{"count":118,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/2950\/revisions"}],"predecessor-version":[{"id":16179,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/2950\/revisions\/16179"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/media\/7398"}],"wp:attachment":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/media?parent=2950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/categories?post=2950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/tags?post=2950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}