Created
January 20, 2016 10:33
-
-
Save ericdke/537617c2e4be51b98a62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import AVFoundation | |
| func getImageFromVideo(videoURL: String) -> UIImage? { | |
| do { | |
| let asset = AVURLAsset(URL: NSURL(fileURLWithPath: videoURL), options: nil) | |
| let imgGenerator = AVAssetImageGenerator(asset: asset) | |
| imgGenerator.appliesPreferredTrackTransform = true | |
| let cgImage = try imgGenerator.copyCGImageAtTime(CMTimeMake(0, 1), actualTime: nil) | |
| let image = UIImage(CGImage: cgImage) | |
| return image | |
| } catch { | |
| print(error) | |
| return nil | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment