IOS Swift: thumbnail video error

I create video thumbnails with the following code, and it works in most cases. However, sometimes it throws an error and a thumbnail is not created. I cannot understand why this does not work sometimes.

This is how I create a video thumbnail:

let asset = AVAsset(URL: url) let imageGenerator = AVAssetImageGenerator(asset: asset) imageGenerator.appliesPreferredTrackTransform = true do { let cgImage = try imgGenerator.copyCGImageAtTime(CMTimeMake(1, 30), actualTime: nil) let uiImage = UIImage(CGImage: cgImage) imageview.image = uiImage } catch let error as NSError { print("Image generation failed with error \(error)") } 

It works in most cases, when it does not work, it causes this error:

 Error generating thumbnail: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x17658520 {Error Domain=NSOSStatusErrorDomain Code=-12792 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-12792)} 

I do not know why he throws this error and did not find a solution to stack overflow, although other people faced the same problem.

+4
swift error-handling avplayer video-thumbnails
May 22 '16 at 11:54
source share

No one has answered this question yet.

See similar questions:

59
Retrieving a thumbnail from a video or data URL in iOS
3
Extract thumbnail from video in streams

or similar:

eleven
m3u8 file AVAssetImageGenerator error
2
iOS Swift: Error Domain = NSOSStatusErrorDomain Code = -12792?
one
How to create a thumbnail of a video stream?
one
I'm trying to combine audio and video and save to ios swift photo library
one
AvPlayer cannot play video from user path
0
Screenshot of Swift4.2 from the video
0
combine audio and video and save to photo library, and avplayer gives an error
0
AVAsset copyCGImageAtTime weird behavior
0
Take a Swift Scanned Barcode
0
iOS Swift AVPlayer: NSOSStatusErrorDomain Code = -12643?



All Articles