Question

I'm attempting to recreate some of the functionality from https://github.com/Lockerios/VideoFromImage and discussed in this post: ASSETWriterInput for making Video from UIImages on Iphone Issues

In the pixelBufferFromCGImage:size method, I have the following so far:

options = {KCVPixelBufferCGImageCompatibilityKey => 1, KCVPixelBufferCGBitmapContextCompatibilityKey => 1}

pxbuffer = nil
status = CVPixelBufferCreate(KCFAllocatorDefault, imageSize.width, imageSize.height, KCVPixelFormatType_32ARGB, options, pxbuffer)

where imageSize.width == 640.0 and imageSize.height == 1136.0

However, status always returns -6661. I'm a little confused as to why this might be happening. This method is being called elsewhere with the following:

buffer = pixelBufferFromCGImage(array.objectAtIndex(0).CGImage, size:CGSizeMake(640, 1136))

When I inspect the image from within the pixelBufferFromCGImage function, it appears to be of type "#<__NSCFType:0x9ba7fa0>" I'm not sure if that might be contributing to the issue at all.

It seems like I might be passing an incorrect parameter to the CVPixelBufferCreate function according to https://developer.apple.com/library/ios/documentation/QuartzCore/Reference/CVConstantsRef/Reference/reference.html#//apple_ref/doc/uid/TP40010164-CH4g-BABIIDJJ, the most likely of which being the last 'pixelBufferOut' argument.

Any insight into this problem would be greatly appreciated. I have the following gist with the entirety of my code thus far at https://gist.github.com/naderhen/8407730

Thanks!

Was it helpful?

Solution

It looks like the last parameter is supposed to be a pointer to a CVPixelBufferRef object. You could try this:

pxbuffer = Pointer.new(:object)

Doing that, I get a status of 0 instead of -6661.

Then, to access the buffer, use pxbuffer[0]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top