方法只有视频合成,多个视频合成等,至于视频后面加音频那些,各位还是去谷歌吧,话不多说,上代码:
- (void)combineVideos{
NSString *firstVideo = _currentMovieURL.path;
NSString *secondVideo = [[NSBundle mainBundle] pathForResource:@"trailVideo" ofType:@"mp4"];
NSDictionary *optDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVAsset *firstAsset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:firstVideo] options:optDict];
AVAsset *secondAsset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:secondVideo] options:optDict];
AVMutableComposition *composition = [AVMutableComposition composition];
//为视频类型的的Track
AVMutableCompositionTrack *compositionTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]