我試圖從https://github.com/Lockerios/VideoFromImage重現一些功能,並在這個職位討論:ASSETWriterInput for making Video from UIImages on Iphone IssuesCVPixelBufferCreate在RubyMotion
在pixelBufferFromCGImage:大小的方法,我迄今以下內容:
options = {KCVPixelBufferCGImageCompatibilityKey => 1, KCVPixelBufferCGBitmapContextCompatibilityKey => 1}
pxbuffer = nil
status = CVPixelBufferCreate(KCFAllocatorDefault, imageSize.width, imageSize.height, KCVPixelFormatType_32ARGB, options, pxbuffer)
其中imageSize.width == 640.0 和imageSize.height == 1136.0
但是,狀態總是返回-6661。我有點困惑,爲什麼這可能會發生。這種方法被用在其他地方被稱爲以下:
buffer = pixelBufferFromCGImage(array.objectAtIndex(0).CGImage, size:CGSizeMake(640, 1136))
當我從pixelBufferFromCGImage函數內檢查圖像,這似乎是類型「#< __NSCFType:0x9ba7fa0>」我不知道,如果可能對這個問題有所貢獻。
看來我可能會傳遞一個錯誤的參數給CVPixelBufferCreate函數根據https://developer.apple.com/library/ios/documentation/QuartzCore/Reference/CVConstantsRef/Reference/reference.html#//apple_ref/doc/uid/TP40010164-CH4g-BABIIDJJ,其中最有可能的是最後的'pixelBufferOut'參數。
任何對這個問題的深入瞭解將不勝感激。我有以下的要點到目前爲止我的代碼全部在https://gist.github.com/naderhen/8407730
謝謝!
這很好地工作。真棒! –