当我尝试在表格视图中cellForAtIndex
生成缩略图时出现此错误:
错误域= AVFoundationErrorDomain代码= -11800"操作可以 没完成" UserInfo = {NSUnderlyingError = 0x170843ae0 {错误 Domain = NSOSStatusErrorDomain Code = -308"(null)"}, NSLocalizedFailureReason =发生未知错误(-308), NSLocalizedDescription =操作无法完成}:
ThumbUrl for thumbnail:https://google.com/abc.mp4
但如果我尝试上面给出的静态网址,它可以正常运行而没有任何错误。
这是缩略图生成器代码:
/*=========================================================================
Generate Image from Video Frame
=========================================================================*/
func fetchFirstFrameOf(urlString: String,completion:@escaping (_ image:UIImage?)->()) {
var filePath = URL(string: urlString)
print(" FETCH FRAME urlString:-",urlString )
if urlString.hasPrefix("VID-") {
let path = NIDbUtility.getPath(fileName:urlString, forVideo_ImageFromMainApp: true)
print("dbPath video FETCH FRAME path:-",path )
filePath = URL(fileURLWithPath: path)
}
let asset = AVURLAsset(url: filePath!)
let imgGenerator = AVAssetImageGenerator(asset: asset)
imgGenerator.appliesPreferredTrackTransform = true
imgGenerator.requestedTimeToleranceAfter = kCMTimeZero
imgGenerator.requestedTimeToleranceBefore = kCMTimeZero
do {
let cgImage = try imgGenerator.copyCGImage(at: CMTimeMake(0, 1), actualTime: nil)
let thumbnail = UIImage(cgImage: cgImage)
completion(thumbnail)
} catch let error {
print("*** Error generating thumbnail: \(error): \(urlString)")
completion(nil)
}
}
由于