我使用下面的代碼使用AVAsset類生成縮略圖的失敗,錯誤代碼AVFoundationErrorDomain = -11800
func generateThumnail(url :URL, fromTime:Float64) -> UIImage? {
let asset :AVAsset = AVAsset(url:url)
let assetImgGenerate : AVAssetImageGenerator = AVAssetImageGenerator(asset: asset)
assetImgGenerate.appliesPreferredTrackTransform = true
assetImgGenerate.requestedTimeToleranceAfter = kCMTimeZero;
assetImgGenerate.requestedTimeToleranceBefore = kCMTimeZero;
let time : CMTime = CMTimeMakeWithSeconds(1,30)
do {
let img = try assetImgGenerate.copyCGImage(at: time, actualTime: nil)
return UIImage(cgImage: img)
} catch let error as NSError {
print("Image generation failed with error \(error)")
return nil
}
return nil
}
如果失敗,有時與相同的視頻網址
以下錯誤往往礦石生成遠程視頻的網址AVFoundationErrorDomain代碼= -11800
不知道什麼是錯與上面的代碼我是新來AVAsset一個ND相關框架 任何幫助表示讚賞
這些碰撞是隨機 –
要生成遠程資產縮略圖,在這裏看到:http://stackoverflow.com/a/29432405/22147 –