AVAssetReader初始化失败?



我试图通过AVAssetReader和avassetwwriter导出iCloud资产,但AVAssetReader无法初始化使用该资产。所有其他视频都工作正常。只有iCloud共享的相册视频会造成麻烦。AVAssetReader给我的错误是:

错误域=AVFoundationErrorDomain Code=-11800 "操作无法完成"UserInfo={NSLocalizedFailureReason=未知错误发生(-17507),NSLocalizedDescription=操作无法完成,NSUnderlyingError=0x2812d8ae0{错误域=NSOSStatusErrorDomain Code=-17507 "(null)"}}

为什么要修复它或者有其他的选择吗?

当使用PHImageManager请求资产时,将PHVideoRequestOptions实例的deliveryMode属性设置为mediumQualityFormatfastFormat可能是您遇到问题的原因。尝试使用auto或high quality,因为根据文档,这是导出时唯一支持的模式。

let videoRequestOptions = PHVideoRequestOptions()
videoRequestOptions.deliveryMode = .highQualityFormat
videoRequestOptions.isNetworkAccessAllowed = true
PHImageManager.default().requestAVAsset(forVideo: asset, options: videoRequestOptions) { (asset, audioMix, info) in
// Use the returned asset 
}

相关内容