0
, когда я совмещаю два аудиофайла m4a и экспортирую этот файл, тогда это всегда даст мне сбой. Я получил тот же вопрос здесь, и я пробовал отвечать всем, но не работал для меня.AVAssetExportSession всегда сбой
NSString* documentsDirectory= [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* myDocumentPath= [documentsDirectory stringByAppendingPathComponent:@"merge_audio.mp4"];
NSURL *url = [NSURL fileURLWithPath:myDocumentPath];//[[NSURL alloc] initFileURLWithPath: myDocumentPath];
NSLog(@"%@",url);
//Check if the file exists then delete the old file to save the merged video file.
if([[NSFileManager defaultManager]fileExistsAtPath:myDocumentPath])
{
[[NSFileManager defaultManager]removeItemAtPath:myDocumentPath error:nil];
}
AVAssetExportSession *exporter=[[AVAssetExportSession alloc] initWithAsset:composition presetName:AVAssetExportPresetAppleM4A];
exporter.outputURL=url;
exporter.outputFileType=AVFileTypeAppleM4A;
[exporter exportAsynchronouslyWithCompletionHandler:^{
switch([exporter status])
{
case AVAssetExportSessionStatusFailed:
NSLog(@"Failed to export audio");
break;
case AVAssetExportSessionStatusCancelled:
NSLog(@"export cancelled");
break;
case AVAssetExportSessionStatusCompleted:
//Here you go you have got the merged video :)
NSLog(@"Merging completed");
break;
default:
break;
}
}];