视频缩略图需要10-15秒才能快速显示

时间:2019-06-15 13:10:23

标签: swift4.1

func getThumbnailFrom(路径:URL)-> UIImage? {

    do {
        let asset = AVURLAsset(url: path , options: nil)
        let imgGenerator = AVAssetImageGenerator(asset: asset)
        imgGenerator.appliesPreferredTrackTransform = true
        let timestamp = asset.duration
        print("Timestemp:   \(timestamp)")
        let cgImage = try imgGenerator.copyCGImage(at: CMTimeMake(value: 0, timescale: 1), actualTime: nil)
        let thumbnail = UIImage(cgImage: cgImage)
        return thumbnail

    } catch let error {

        print("*** Error generating thumbnail: \(error.localizedDescription)")
        return nil
    }

如何显示缩略图10至30秒。目前我正在获取静态图片。

0 个答案:

没有答案