AVAssetExportSession 在 iPhone 3G 上失败 - 但在 iPhone 4 上则不然
我使用 AVAssetExportSession
转换 *.caf
文件,它在 4.0 模拟器和我的 iPhone 4 测试设备上运行得很好。
遗憾的是,它在具有以下功能的 iPhone 3G 上总是失败:
AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:avAsset presetName:AVAssetExportPresetAppleM4A];
if (exportSession == nil) {
NSLog(@"no export session");
return NO;
}
exportSession.outputURL = [NSURL fileURLWithPath:self.tempDir];
exportSession.outputFileType = AVFileTypeAppleM4A;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
if (AVAssetExportSessionStatusCompleted == exportSession.status) {
NSLog(@"AVAssetExportSessionStatusCompleted");
} else if (AVAssetExportSessionStatusFailed == exportSession.status) {
// a failure may happen because of an event out of your control
// for example, an interruption like a phone call comming in
// make sure and handle this case appropriately
NSLog(@"AVAssetExportSessionStatusFailed");
NSLog(@"%@", [exportSession.error description]);
} else {
NSLog(@"Export Session Status: %d", exportSession.status);
}
}];
每次都会抛出以下错误。
Error Domain=AVFoundationErrorDomain Code=-11823“无法保存”UserInfo=0x16fb20 {NSLocalizedRecoverySuggestion=再次尝试保存。, NSLocalizedDescription=无法保存}
这可能是什么原因?
Im converting a *.caf
file using AVAssetExportSession
it works pretty well on the 4.0 Simulator and on my iPhone 4 testdevice.
Sadly it always fails on an iPhone 3G with following function:
AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:avAsset presetName:AVAssetExportPresetAppleM4A];
if (exportSession == nil) {
NSLog(@"no export session");
return NO;
}
exportSession.outputURL = [NSURL fileURLWithPath:self.tempDir];
exportSession.outputFileType = AVFileTypeAppleM4A;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
if (AVAssetExportSessionStatusCompleted == exportSession.status) {
NSLog(@"AVAssetExportSessionStatusCompleted");
} else if (AVAssetExportSessionStatusFailed == exportSession.status) {
// a failure may happen because of an event out of your control
// for example, an interruption like a phone call comming in
// make sure and handle this case appropriately
NSLog(@"AVAssetExportSessionStatusFailed");
NSLog(@"%@", [exportSession.error description]);
} else {
NSLog(@"Export Session Status: %d", exportSession.status);
}
}];
The following error is thrown every time.
Error Domain=AVFoundationErrorDomain Code=-11823 "Cannot Save" UserInfo=0x16fb20 {NSLocalizedRecoverySuggestion=Try saving again., NSLocalizedDescription=Cannot Save}
What could be the reason for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文件已存在时出现 11823 错误 在您尝试保存文件的路径上,
因此您应该删除该文件。
11823 error comes when file already exist on the path where you are trying to save the file
So you should remove the file.
3G 设备很可能缺乏进行相关转换的硬件编解码器。您可以在 3G 上播放 caf 文件来测试它是否可以解码它,并且您是否尝试过转换一些简单的东西(例如 wav)来证明它可以进行编码?
Most likely the 3G device lacks the hardware codecs to do the relevant transform. Can you play the caf file on the 3G to test it can decode it, and have you tried converting something simple like a wav to prove it can do encode?