I have a recorded video with sound. When adding that to an AVMutableComposition and then export it, the video will freeze when the sound is playing. What am I missing?
I have my two tracks:
_compositionVideoTrack = [self.composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
_compositionAudioTrack = [self.composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
Then create the tracks:
AVAssetTrack *clipVideoTrack = [[sourceAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
AVAssetTrack *clipAudioTrack = [[sourceAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
Then I insert the tracks:
[_compositionVideoTrack insertTimeRange:editRange ofTrack:clipVideoTrack atTime:self.composition.duration error:&editError];
[_compositionAudioTrack insertTimeRange:editRange ofTrack:clipAudioTrack atTime:self.composition.duration error:&editError];
Finally I export it:
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:urlAsset presetName:AVAssetExportPresetPassthrough];
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
And the file is .mp4. Could it be the file format?