Closed Ludotrico closed 3 years ago
You can use this function to get thumbnail from the video.
func thumbnailFromVideoPath(_ path: URL) -> UIImage {
let asset = AVURLAsset(url: path, options: nil)
let gen = AVAssetImageGenerator(asset: asset)
gen.appliesPreferredTrackTransform = true
let time = CMTimeMakeWithSeconds(0.0, preferredTimescale: 600)
var actualTime = CMTimeMake(value: 0, timescale: 0)
let image: CGImage
do {
image = try gen.copyCGImage(at: time, actualTime: &actualTime)
let thumbnail = UIImage(cgImage: image)
return thumbnail
} catch { }
return UIImage()
}
Any chance we can get thumbnail generation from a video?