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?
11823 error comes when file already exist on the path where you are trying to save the file
So you should remove the file.
- (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);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With