AVAssetExportSession 在 iPhone 3G 上失败 - 但在 iPhone 4 上则不然

发布于 2024-12-03 11:59:27 字数 1379 浏览 0 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦初启 2024-12-10 11:59:27

文件已存在时出现 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);
        }
    }
}

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);
        }
    }
}
一生独一 2024-12-10 11:59:27

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文