Iphone AVAssetExportSession在ios5中不工作
在我的应用程序中,我使用AVAssetExportSession组合了两个音频文件,它在早期的ios版本中运行良好。但在ios5设备中它不工作。我得到的是一个错误Iphone AVAssetExportSession在ios5中不工作,iphone,objective-c,ios5,avfoundation,avassetexportsession,Iphone,Objective C,Ios5,Avfoundation,Avassetexportsession,在我的应用程序中,我使用AVAssetExportSession组合了两个音频文件,它在早期的ios版本中运行良好。但在ios5设备中它不工作。我得到的是一个错误 AVAssetExportSessionStatusFailed: Error Domain=AVFoundationErrorDomain Code=-11820 "Cannot Complete Export" UserInfo=0x1df1c0 {NSLocalizedRecoverySuggestion=Try exporti
AVAssetExportSessionStatusFailed: Error Domain=AVFoundationErrorDomain Code=-11820 "Cannot Complete Export" UserInfo=0x1df1c0 {NSLocalizedRecoverySuggestion=Try exporting again., NSLocalizedDescription=Cannot Complete Export}
下面给出了我用于导出的代码
有没有人经历过同样的问题?请提供您宝贵的建议。
我急需解决这个问题
//Export function to export the combined audios as one.
-(void)exportAudioFile:(AVComposition*)combinedComposition
{
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:combinedComposition
presetName:AVAssetExportPresetPassthrough];
NSArray *presets =[AVAssetExportSession exportPresetsCompatibleWithAsset:combinedComposition];
NSLog(@"presets======%@",presets);
NSLog (@"can export: %@", exportSession.supportedFileTypes);
NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [dirs objectAtIndex:0];
exportPath = [documentsDirectoryPath stringByAppendingPathComponent:@"CombinedNew.m4a"];
[[NSFileManager defaultManager] removeItemAtPath:exportPath error:nil];
exportURL = [NSURL fileURLWithPath:exportPath];
exportSession.outputURL = exportURL;
exportSession.outputFileType = @"com.apple.m4a-audio";
exportSession.shouldOptimizeForNetworkUse = YES;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
NSLog (@"i is in your block, exportin. status is %d",
exportSession.status);
switch (exportSession.status)
{
case AVAssetExportSessionStatusFailed:
{
// log error to text view
NSError *exportError = exportSession.error;
DEBUG_LOG(@"AVAssetExportSessionStatusFailed: %@", exportError);
[self enableUI];
break;
}
case AVAssetExportSessionStatusCompleted:
{
DEBUG_LOG(@"AVAssetExportSessionStatusCompleted");
DEBUG_LOG(@"Completed export");
exportSuccess = YES;
if (recorderFilePath)
{
NSError *finalurlError;
[[NSFileManager defaultManager]removeItemAtPath:recorderFilePath error:&finalurlError];
finalurlError = nil;
[[NSFileManager defaultManager]copyItemAtPath:[exportURL path] toPath:recorderFilePath error:&finalurlError];
}
isExported = YES;
fileUrl = [NSURL fileURLWithPath:recorderFilePath];
[self performSelectorInBackground:@selector(updatePlayerForUrl:) withObject:fileUrl];
break;
}
case AVAssetExportSessionStatusUnknown:
{
DEBUG_LOG(@"AVAssetExportSessionStatusUnknown");
break;
}
case AVAssetExportSessionStatusExporting:
{
DEBUG_LOG(@"AVAssetExportSessionStatusExporting");
break;
}
case AVAssetExportSessionStatusCancelled:
{
DEBUG_LOG(@"AVAssetExportSessionStatusCancelled");
break;
}
case AVAssetExportSessionStatusWaiting:
{
DEBUG_LOG(@"AVAssetExportSessionStatusWaiting");
break;
}
default:
{
DEBUG_LOG(@"didn't get export status");
break;
}
};
}];
[exportSession release];
}
我为自己整理了答案,并想与经历过同样问题的其他人分享 问题在于,出于某种原因,AVAssetExportPresetPassthrough在ios5中无法正常工作。用AVAssetExportPresetAppleM4A替换它解决了这个问题。
但是现在导出需要更长的时间。我为自己找到了答案,并希望与遇到相同问题的其他人分享 问题在于,出于某种原因,AVAssetExportPresetPassthrough在ios5中无法正常工作。用AVAssetExportPresetAppleM4A替换它解决了这个问题。
但是现在导出需要更长的时间。也许解决方法是直接使用AVAssetWriter,而不是使用AVAssetExportSession。请在上提交一个bug,以便在iOS5的下一版本中修复它。我自己提交了一份,但提交的越多越好。也许解决办法是直接使用AVAssetWriter,而不是使用AVAssetExportSession。请在上提交一个bug,以便在iOS5的下一版本中修复它。我自己归档了一个,但归档的文件越多越好。作为一种解决方法,我发现使用.mov作为文件扩展名,然后将其重新命名为mp3似乎可行。我不需要对m4a文件执行此操作。作为一种解决方法,我发现使用.mov作为文件扩展名,然后将其重新命名为mp3似乎可行。我不需要对m4a文件执行此操作。有人知道AVAssetExportPresetPassthrough为什么不工作吗?使用AVAssetExportPresetAppleM4A导出时会导致大量时间延迟。有人知道AVAssetExportPresetPassthrough为什么不工作吗?在使用AVAssetExportPresetAppleM4A导出时,它会导致很多时间延迟。我还提交了一份错误报告。我想知道需要这个的应用程序是如何应对iOS5.1I的,例如:DJ应用程序也提交了一份bug报告。我想知道需要这个的应用程序是如何应对iOS5.1的