[](https://travis-ci.org/Mesfin Bekele Mekonnen/AVStitch)
AVStitch is built using the AVFoundation framework and allows you to easily stitch or merge individual videos.
To run the example project, clone the repo, and run pod install
from the Example directory first.
ARC
AVStitch is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "AVStitch"
##Documentation
###Implementation
To use AVStitch you just need to import the AVExportHandler.h
file into the view controller where you will have AVAssets.
For example if you use a camera, you would use the delegate method:
imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
to store your video asset files in an array.
Then when you are ready to merge the collection of videos, you would use the AVExportHandler
convenience method playerItemFromVideosArray: completion:
to merge the videos.
This methods returns an AVPlayerItem
which you can then use to playback the merged videos or use as you see fit.
The example below illustrates how to do this:
- (void)mergeVideosInArray:(NSArray<AVAsset *>*)videosAssestsArray {
AVExportHandler *exportHandler = [AVExportHandler new];
[exportHandler playerItemFromVideosArray:videosAssestsArray completion:^(AVPlayerItem *playerItem, NSError *error) {
if (!error) {
AVPlayerItem * pi = playerItem;
AVPlayer *player = [AVPlayer playerWithPlayerItem:pi];
AVVideoViewController *videoVC = [AVVideoViewController new];
videoVC.avPlayer = player;
[self presentViewController:videoVC animated:YES completion:nil];
}
else {
NSLog(@"Error - %@",error.localizedDescription);
}
}];
}
Mesfin Bekele Mekonnen, [email protected]
AVStitch is available under the MIT license. See the LICENSE file for more info.