可以在AVAssetExportSession的输出设置中手动指定要导出的轨道,并使用trackID作为索引。 示例代码:
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetMediumQuality]; exportSession.outputURL = outputURL; exportSession.outputFileType = AVFileTypeQuickTimeMovie;
//手动指定需要导出的轨道 AVAssetTrack *videoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; exportSession.videoComposition = [AVMutableVideoComposition videoCompositionWithPropertiesOfAsset:asset]; exportSession.videoComposition.trackIDForFrameTiming = videoTrack.trackID;
//开始导出 [exportSession exportAsynchronouslyWithCompletionHandler:^{ //导出完成后的处理 }];