Request for optimal pixel format when capturing video on iOS?

AVFoundation Programming Guide states that the preferred pixel formats for video capture are:

  • for iPhone 4: kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange or kCVPixelFormatType_32BGRA
  • for iPhone 3G: kCVPixelFormatType_422YpCbCr8 or kCVPixelFormatType_32BGRA

(There are no recommendations for the iPhone 5 or iPad for devices with cameras.)

However, there is no help as to how I should go, and to determine which device is currently working. And what if the preferred pixel format will be different in the future, and therefore to my unknown device application?

What is the correct and future proof, a way to determine the preferred YpCbCr pixel format for any device?

0
source share
1 answer

I believe that you can just set the video settings to zero, and AVFoundation will use the most efficient format. For example, instead of executing

 NSDictionary *videoSettings = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange] forKey:(id)kCVPixelBufferPixelFormatTypeKey]; videoOutput.videoSettings = videoSettings; 

Do it instead

 videoOutput.videoSettings = nil; 

You can also try not to install it at all. I know that in the past I would just set it to zero if I didn't need to record images in a specific format.

change

To get the AVFoundation format, you decide to use.

 CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(source); CGColorSpaceRef cref = CVImageBufferGetColorSpace(imageBuffer); 
0
source

All Articles