iOS Swift : Error Domain=NSOSStatusErrorDomain Code=-12792?

╄→гoц情女王★ 提交于 2019-12-06 05:29:54

I was able to solve this issue by the following approach.

Swift 4.1

func createThumbnailForVideo(atURL videoURL: URL , completion : @escaping (UIImage?)->Void) {
    let asset = AVAsset(url: videoURL)
    let assetImgGenerate = AVAssetImageGenerator(asset: asset)
    assetImgGenerate.appliesPreferredTrackTransform = true
    let time = CMTimeMakeWithSeconds(1, preferredTimescale: 60)
    let times = [NSValue(time: time)]
    assetImgGenerate.generateCGImagesAsynchronously(forTimes: times, completionHandler: {  _, image, _, _, _ in
        if let image = image {
            let uiImage = UIImage(cgImage: image)
            completion(uiImage)
        } else {
            completion(nil)
        }
    })
}

Hope this will help.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!