【问题标题】:AVAssetExportSession failed with unknown error -12780 for specific videoAVAssetExportSession 失败,特定视频出现未知错误 -12780
【发布时间】:2016-07-08 19:34:03
【问题描述】:

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

视频轨道用 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;
    }
}];

问题应该出在资产导出会话中;将轨道插入 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}

【问题讨论】:

  • 这个问题解决了吗?
  • 你找到解决这个问题的方法了吗?
  • 即使已经有一段时间了,我还是建议您接受 Fistman 的解决方案。至少,它对我有用。
  • @PayalManiyar 你有没有得到任何解决方案。我遇到了同样的问题。我的代码运行良好,但一段时间后它停止工作。我的代码没有改变。伙计们帮助

标签: ios objective-c avfoundation avassetexportsession avasset


【解决方案1】:

我花了大约两天时间来解决这个问题...... 我没有找出根本原因,但是,我发现将 audioMix 设置为 AVAssetExportSession 有效。

AVMutableAudioMix *videoAudioMixTools = [AVMutableAudioMix audioMix];
AVMutableAudioMixInputParameters *firstAudioParam = [AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:assetAudioTrack];
[firstAudioParam setVolumeRampFromStartVolume:1.0 toEndVolume:1.0 timeRange:CMTimeRangeMake(kCMTimeZero, CMTimeSubtract(endCropTime, startCropTime))];
[firstAudioParam setTrackID:compositionAudioTrack.trackID];
videoAudioMixTools.inputParameters = [NSArray arrayWithObject:firstAudioParam];

exportSession.audioMix = videoAudioMixTools;

似乎这会强制解码和重新编码音轨。

【讨论】:

  • 现在是 2019 年,我终于解决了这个问题!另请注意,要使此解决方案正常工作,presetName 需要是 exportPresetsCompatibleWithAsset 中的可用预设(如AVAssetExportPresetHighestQuality),而不是AVAssetExportPresetPassthrough
【解决方案2】:

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

大多数情况下,问题在于输出 URL。 确保 URL 是这样创建的:

URL(fileURLWithPath: "")

例如:

let temp_output = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("temp_exported.mov")

【讨论】:

  • 就是这样!我正在使用URL(string: "")。谢谢!
  • 这是真正的答案。应该使用 URL(fileURLWithPath:) 而不是 URL(string:)。谢谢!
【解决方案3】:

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

【讨论】:

  • 天哪……浪费了 5 个小时,这就是答案。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多