/* Recreate audio */
NSArray *allAudio = [videoAsset tracksWithMediaType:AVMediaTypeAudio];
for (int i=0; i < [allAudio count]; i++) {
NSError* error = NULL;
AVAssetTrack *audioAsset = (AVAssetTrack*)[allAudio objectAtIndex:i];
AVMutableCompositionTrack *compositionAudioTrack = [videoComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero,videoAsset.duration)
ofTrack:audioAsset
atTime:kCMTimeZero
error:&error];
}
NSArray *allAudio = [videoAsset tracksWithMediaType:AVMediaTypeAudio];
for (int i=0; i < [allAudio count]; i++) {
NSError* error = NULL;
AVAssetTrack *audioAsset = (AVAssetTrack*)[allAudio objectAtIndex:i];
AVMutableCompositionTrack *compositionAudioTrack = [videoComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero,videoAsset.duration)
ofTrack:audioAsset
atTime:kCMTimeZero
error:&error];
}
Comments
Post a Comment