如何使用AVAssetExportSession导出具有远程URL的资产?

时间:2018-01-25 06:55:50

标签: ios swift avfoundation avasset avassetexportsession

我想保存AVAsset中使用远程URL初始化的视频。我尝试使用this解决方案,但我仍然收到错误:

  

错误Domain = AVFoundationErrorDomain   代码= -11838“操作已停止”   UserInfo = {NSLocalizedFailureReason =不支持该操作   这个媒体。,NSLocalizedDescription =操作已停止,   NSUnderlyingError = 0x1c424d3b0 {错误域= NSOSStatusErrorDomain   代码= -12109“(null)”}}

这就是我出口资产的方式:

let exporter = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetHighestQuality)
let filename = UUID().uuidString
let documentDirectory = documentDirectory()
let outputURL = documentDirectory.appendingPathComponent(filename)

exporter?.outputURL = outputURL
exporter?.outputFileType = .mp4
exporter?.exportAsynchronously {
    print(exporter?.error)
}

AVAsset加载了值时,我正在这样做(根据上面提到的帖子):

asset.loadValuesAsynchronously(forKeys: ["tracks"]) {
    // export here
}

0 个答案:

没有答案