은 내가 편집하고 변경 가능한 조성물에 추가 한 4 개 비디오 파일이 있습니다. 나는 trackID = 1 수출됩니다와여러 트랙을 내보내기 : AVMutableComposition 및 AVAssetExportSession
<AVAssetExportSession: 0x60800001da50, asset = <AVMutableComposition: 0x6080002240a0 tracks = (
"<AVMutableCompositionTrack: 0x600000224ca0 trackID = 1, mediaType = vide, editCount = 8>",
"<AVMutableCompositionTrack: 0x600000226da0 trackID = 2, mediaType = vide, editCount = 10>",
"<AVMutableCompositionTrack: 0x60000023e180 trackID = 3, mediaType = vide, editCount = 3>",
"<AVMutableCompositionTrack: 0x60000023e500 trackID = 4, mediaType = vide, editCount = 7>"
)>, presetName = AVAssetExportPreset1280x720, outputFileType = (null)
에게 첫 번째 트랙을 수출됩니다 아래 트랙의 목록에서 첫 번째 트랙을 수출하고 때, 그러나, 파일을 내보내려면 수출 세션을 사용하려합니다. 내보내기 세션 소스는 다음과 같습니다.
// Create path to output file
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *myPathDocs = [documentsDirectory stringByAppendingPathComponent:
[NSString stringWithFormat:@"ProcessedVideo-%d.mov", arc4random() % 1000]];
NSURL *url = [NSURL fileURLWithPath:myPathDocs];
AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:batchComposition presetName:AVAssetExportPreset1280x720];
NSLog(@"%@", exporter);
exporter.outputURL = url;
exporter.outputFileType = AVFileTypeQuickTimeMovie;
[exporter exportAsynchronouslyWithCompletionHandler:^(void) {
switch (exporter.status) {
case AVAssetExportSessionStatusCompleted:
NSLog(@"Completed");
break;
case AVAssetExportSessionStatusFailed:
NSLog(@"Failed:%@",exporter.error);
break;
case AVAssetExportSessionStatusCancelled:
NSLog(@"Canceled:%@",exporter.error);
break;
default:
break;
}
}];
내보내기 세션을 사용하여 4 개의 트랙을 하나의 .mov 파일로 내보내려면 어떻게해야합니까?
이상적으로 4 개의 트랙을 하나의 비디오 출력으로 내보내고 4 개의 개별 비디오 파일로 내보내는 것이 좋습니다. – Edwin
4 개의 트랙을 하나의 컴포지션에 넣고 하나의 파일로 내보낼 수 있지만, 재생하는 데 사용하는 플레이어가 둘 이상의 비디오 트랙이있는 비디오 파일을 해석 할 수 있어야합니다. iOS의 사진 앱은 하나의 트랙 만 재생할 수 있으며 트랙간에 전환 할 수는 없습니다. – jlw
Mac에서 QuickTime 플레이어를 사용하고 있습니다. 나는 그것이 최고의 트랙을 여러 트랙으로 재생할 수있을 것이라고 생각한다. – Edwin