我使用以下代码使用AVAsset类生成远程视频的URL
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 Code = -11800
不确定上述代码有什么问题我是AVAsset和相关框架的新手 任何帮助表示赞赏
答案 0 :(得分:0)
$HOME/.m2/settings.xml