首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AVAssetExportSession总是失败

AVAssetExportSession总是失败
EN

Stack Overflow用户
提问于 2015-12-11 18:54:47
回答 1查看 856关注 0票数 0

当我组合两个m4a音频文件并导出这个文件时,这总是会给我失败。我在这里得到了同样的问题,我尝试了每个人的答案,但没有一个对我有效。

代码语言:javascript
复制
NSString* documentsDirectory= [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

    NSString* myDocumentPath= [documentsDirectory stringByAppendingPathComponent:@"merge_audio.mp4"];

    NSURL *url = [NSURL fileURLWithPath:myDocumentPath];//[[NSURL alloc] initFileURLWithPath: myDocumentPath];
    NSLog(@"%@",url);
    //Check if the file exists then delete the old file to save the merged video file.
    if([[NSFileManager defaultManager]fileExistsAtPath:myDocumentPath])
    {
        [[NSFileManager defaultManager]removeItemAtPath:myDocumentPath error:nil];
    }

AVAssetExportSession *exporter=[[AVAssetExportSession alloc] initWithAsset:composition presetName:AVAssetExportPresetAppleM4A];
    exporter.outputURL=url;
    exporter.outputFileType=AVFileTypeAppleM4A;
    [exporter exportAsynchronouslyWithCompletionHandler:^{
        switch([exporter status])
        {
            case AVAssetExportSessionStatusFailed:
                NSLog(@"Failed to export audio");
                break;
            case AVAssetExportSessionStatusCancelled:
                NSLog(@"export cancelled");
                break;
            case AVAssetExportSessionStatusCompleted:
                //Here you go you have got the merged video :)
                NSLog(@"Merging completed");

                break;
            default:
                break;
        }
}];
EN

回答 1

Stack Overflow用户

发布于 2015-12-11 20:03:46

您可以在AVAssetExportSessionerror property中找到所需的解释,只需记录下来即可。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34221833

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档