AVAssetExportSession因特定视频的未知错误-12780而失败

sta*_*ung 14 objective-c avfoundation ios avassetexportsession avasset

我在追踪资产导出会话失败背后的根本问题时遇到了问题.问题仅针对一个视频,我认为问题出在其音频轨道上,因为我成功导出了没有音轨的资产(只有视频轨道).

使用AVAssetReader对视频轨道进行解码,并在重写为新视频轨道之前处理采样缓冲区; 音频轨道没有解码也没有任何中间处理.但是,即使不处理视频样本缓冲区,也会发生相同的故障.

我也试过反过来做 - 只有音频而没有视频轨道 - 还有其他视频工作正常,这个特定的视频失败了.我认为视频的音轨有一个固有的问题,但我无法推断出问题是什么,因此我无法解决它.这是我的代码:

AVAssetExportSession* assetExport = [[AVAssetExportSession alloc] initWithAsset:composition
                                                                      presetName:AVAssetExportPresetHighestQuality];

assetExport.outputFileType = @"com.apple.quicktime-movie";
assetExport.outputURL = [NSURL fileURLWithPath:path];

__weak typeof(self) weakSelf = self;
[assetExport exportAsynchronouslyWithCompletionHandler:^{

    switch (assetExport.status) {
        case AVAssetExportSessionStatusCompleted: NSLog(@"Asset combined");
            break;
        case AVAssetExportSessionStatusFailed: NSLog(@"Asset combination failed");
            break;
        default: NSLog(@"Asset combination completed with unknown status: %@", @(assetExport.status));
            break;
    }
}];
Run Code Online (Sandbox Code Playgroud)

这个问题应该出现在资产出口会议上; 跟踪AVMutableComposition的插入工作得很好.这是AVAssetExportSession的错误消息:

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed"
UserInfo={NSUnderlyingError=0x6040001338d0 {Error Domain=NSOSStatusErrorDomain Code=-12780 "(null)"}, 
NSLocalizedFailureReason=An unknown error occurred (-12780), NSLocalizedDescription=The operation could not be completed}
Run Code Online (Sandbox Code Playgroud)

Mar*_*coc 8

我知道这是一个老问题,但由于它还没有解决,我将给出错误代码的解决方案12780

大多数时候问题出在输出 URL 上。确保URL像这样创建:

URL(fileURLWithPath: "")
Run Code Online (Sandbox Code Playgroud)

例如:

let temp_output = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("temp_exported.mov")
Run Code Online (Sandbox Code Playgroud)


Rhy*_*man 4

疯狂猜测:音轨与其所属的 分离AVAsset,然后超出了范围。尝试保留对音轨的引用,AVAsset直到您致电exportAsynchronouslyWithCompletionHandler