开始做的是一般的vod视频截屏,用AVAssetImageGenerator对象就可以实现,而且可以截取任意时间点的视频图像
片段代码:
open func generateThumbnails(times: [TimeInterval],maximumSize: CGSize, completionHandler: @escaping (([EZPlayerThumbnail]) -> Swift.Void )){
guard let imageGenerator = self.imageGenerator else {
return;
}
var values = [NSValue]()
for time in times {
values.append(NSValue(time: CMTimeMakeWithSeconds(time,CMTimeScale(NSEC_PER_SEC))))
}
var thumbnailCount = values.count
var thumbnails = [EZPlayerThumbnail]()
imageGenerator.cancelAllCGImageGeneration()
imageGenerator.appliesPrefe