Function is declared as
func copyCGImageAtTime(requestedTime: CMTime, actualTime: UnsafeMutablePointer<CMTime>, error outError: NSErrorPointer) -> CGImage!
and you have to pass (initialized) CMTime and NSError? variables as "in-out expression" with & :
let assetUrl = NSURL(string: ...) let asset: AVAsset = AVAsset.assetWithURL(assetUrl) as AVAsset let imageGenerator = AVAssetImageGenerator(asset: asset); let time = CMTimeMakeWithSeconds(1.0, 1) var actualTime : CMTime = CMTimeMake(0, 0) var error : NSError? let myImage = imageGenerator.copyCGImageAtTime(time, actualTime: &actualTime, error: &error)
Please note that your first line
let assetUrl = NSURL.URLWithString(self.targetVideoString)
no longer compiles with current Xcode 6.1.
source share