我无法追踪 Assets 导出 session 失败背后的潜在问题。问题仅针对一个视频,我认为问题出在它的音轨上,因为我成功导出了没有音轨(只有视频轨)的 Assets 。
视频轨道使用 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;
}
}];
问题应该出在 Assets 导出环节;轨道插入到 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}
最佳答案
我知道这是一个老问题,但由于没有解决,我将给出错误代码12780
的解决方案。
大多数时候问题出在输出 URL 上。
确保 URL
是这样创建的:
URL(fileURLWithPath: "")
例如:
let temp_output = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("temp_exported.mov")
关于ios - AVAssetExportSession 因特定视频的未知错误 -12780 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36145497/