I am trying to grab a frame from video.
But copyCGImageAtTime (in AVAssetImageGenerator) fails with this error:
The operation could not be completed
When I specify invalid path, it throws different error, so it looks like it's not path problem.
I am trying with a MP4 file. Maybe that is a problem?
import Cocoa
import AVFoundation
var asset = AVAsset.init(URL: NSURL.init(fileURLWithPath: "/Users/gippeumi/test.mp4"))
var assetGen = AVAssetImageGenerator(asset: asset)
assetGen.appliesPreferredTrackTransform = true
var tim = CMTimeMakeWithSeconds(0.0, 1)
do {
var img = try assetGen.copyCGImageAtTime(tim, actualTime: nil)
} catch let error as NSError {
// (Printing error here...)
}