IOS How to keep audio of video with VideoComposition

/* 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];
                }

Comments

Popular posts from this blog

LINUX Move and copy files using SSH

PHP Predefined Variables

Java : Variables Declaring