Render failed because YCC420f pixel format is not supported

I am trying to convert CVPixelBufferRef to 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 running the code on the device, but does not appear when running on the simulator, the console displays the following:

Render failed because YCC420f pixel format is not supported

Any ideas?

+5
source share

All Articles