我使用了以下方式,但视频没有合并,并且在输出中添加到 AVMutableCompositionTrack 的最后一个视频存储在库中。
NSArray *arrVideoUrl=[objApp.dictSelectedVideos allKeys];
AVURLAsset *video1=[[AVURLAsset alloc]initWithURL:[arrVideoUrl objectAtIndex:0] options:nil];
AVURLAsset *video2=[[AVURLAsset alloc]initWithURL:[arrVideoUrl objectAtIndex:1] options:nil];
AVURLAsset *audioAsset=[[AVURLAsset alloc]initWithURL:songUrl options:nil];
AVMutableComposition *mixcomposition=[AVMutableComposition composition];
AVMutableCompositionTrack *track1=[mixcomposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
[track1 insertTimeRange:CMTimeRangeMake(kCMTimeZero, video1.duration) ofTrack:[[video1 tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
atTime:kCMTimeZero error:nil];
AVMutableCompositionTrack *track2=[mixcomposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
[track2 insertTimeRange:CMTimeRangeMake(kCMTimeZero, video2.duration) ofTrack:[[video2 tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
atTime:kCMTimeZero error:nil];
谁能帮帮我?