我*.caf使用AVAssetExportSession它转换文件在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);
}
}];
Run Code Online (Sandbox Code Playgroud)
每次都会抛出以下错误.
Error Domain=AVFoundationErrorDomain Code=-11823 "Cannot Save" UserInfo=0x16fb20 {NSLocalizedRecoverySuggestion=Try saving again., NSLocalizedDescription=Cannot Save}
这可能是什么原因?
shi*_*zhi 47
当您尝试保存文件的路径上已存在文件时,会出现11823错误
所以你应该删除该文件.
- (void) removeFile:(NSURL *)fileURL
{
NSString *filePath = [fileURL path];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:filePath]) {
NSError *error;
if ([fileManager removeItemAtPath:filePath error:&error] == NO) {
NSLog(@"removeItemAtPath %@ error:%@", filePath, error);
}
}
}
Run Code Online (Sandbox Code Playgroud)
3G 设备很可能缺乏进行相关转换的硬件编解码器。您可以在 3G 上播放 caf 文件来测试它是否可以解码它,并且您是否尝试过转换一些简单的东西(例如 wav)来证明它可以进行编码?
| 归档时间: |
|
| 查看次数: |
6460 次 |
| 最近记录: |