到目前为止,我有以下几点
let assetUrl = NSURL.URLWithString(self.targetVideoString) let asset: AVAsset = AVAsset.assetWithURL(assetUrl) as AVAsset let imageGenerator = AVAssetImageGenerator(asset: asset); let time : CMTime = CMTimeMakeWithSeconds(1.0,1) let actualTime : CMTime let myImage: CGImage =imageGenerator.copyCGImageAtTime(requestedTime: time,actualTime:actualTime,error: <#NSErrorPointer#>)
最后一行是我迷路的地方……我只是想在1.0秒时抓到一张图片
该函数声明为
func copyCGImageAtTime(requestedTime: CMTime,actualTime: UnsafeMutablePointer<CMTime>,error outError: NSErrorPointer) -> CGImage!
你必须传递(初始化)CMTime和NSError?变量为“in-out expression”与& ;:
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)
还要注意你的第一行
let assetUrl = NSURL.URLWithString(self.targetVideoString)
使用当前的Xcode 6.1不再编译.