Render failed because a pixel format YCC420f is not supported

604 Views Asked by At

I'm trying to convert a CVPixelBufferRef into a UIImage using the following snippet:

UIImage *image = nil; 
CMSampleBufferRef sampleBuffer = (CMSampleBufferRef)CMBufferQueueDequeueAndRetain(_queue);
if (sampleBuffer)
{
    CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
    NSUInteger width = CVPixelBufferGetWidth(pixelBuffer);
    NSUInteger height = CVPixelBufferGetHeight(pixelBuffer);

    CIImage *coreImage = [[CIImage alloc] initWithCVPixelBuffer:pixelBuffer options:nil];
    CGImageRef imageRef = [_context createCGImage:coreImage fromRect:CGRectMake(0, 0, width, height)];

    image = [UIImage imageWithCGImage:imageRef];

    CFRelease(sampleBuffer);
    CFRelease(imageRef);
}

My problem is that it works fine when I run the code on a device but fails to render when run on simulator, the console outputs the following:

Render failed because a pixel format YCC420f is not supported

Any Ideas?

0

There are 0 best solutions below