生成缩略图失败,错误AVFoundationErrorDomain Code = -11800

时间:2017-01-30 09:14:37

标签: ios iphone swift3 avfoundation

我使用以下代码使用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和相关框架的新手 任何帮助表示赞赏

1 个答案:

答案 0 :(得分:0)

$HOME/.m2/settings.xml