Getting the actual NSString for AvCaptureVideoDataOutput availableVideoCVPixelFormatTypes

I am trying to find the accepted formats in the output of AVFoundation:

self.theOutput=[[AVCaptureVideoDataOutput alloc]init]; if ([self.theSession canAddOutput:self.theOutput]) [self.theSession addOutput:self.theOutput]; 

Then I insert a breakpoint right after and:

 po [self.theOutput availableVideoCVPixelFormatTypes] 

and I get the following:

 (NSArray *) $5 = 0x2087ad00 <__NSArrayM 0x2087ad00>( 875704438, 875704422, 1111970369 ) 

How to get string values โ€‹โ€‹of these types of formats?

thanks

+6
source share
3 answers

On iPhone5 running iOS6, here is AVCaptureVideoDataOuput availableVideoCVPixelFormatTypes:

kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange

kCVPixelFormatType_420YpCbCr8BiPlanarFullRange

kCVPixelFormatType_32BGRA

Credit, which should be a loan, I found a way to get the value supported here. https://gist.github.com/2327666

+8
source

Debug Category Category

As a category in NSNumber

 #import <CoreVideo/CoreVideo.h> @implementation NSNumber (CVPixelFormatType) - (NSString *)descriptivePixelFormat { return @{ @(kCVPixelFormatType_1Monochrome): @"kCVPixelFormatType_1Monochrome", @(kCVPixelFormatType_2Indexed): @"kCVPixelFormatType_2Indexed", @(kCVPixelFormatType_4Indexed): @"kCVPixelFormatType_4Indexed", @(kCVPixelFormatType_8Indexed): @"kCVPixelFormatType_8Indexed", @(kCVPixelFormatType_1IndexedGray_WhiteIsZero): @"kCVPixelFormatType_1IndexedGray_WhiteIsZero", @(kCVPixelFormatType_2IndexedGray_WhiteIsZero): @"kCVPixelFormatType_2IndexedGray_WhiteIsZero", @(kCVPixelFormatType_4IndexedGray_WhiteIsZero): @"kCVPixelFormatType_4IndexedGray_WhiteIsZero", @(kCVPixelFormatType_8IndexedGray_WhiteIsZero): @"kCVPixelFormatType_8IndexedGray_WhiteIsZero", @(kCVPixelFormatType_16BE555): @"kCVPixelFormatType_16BE555", @(kCVPixelFormatType_16LE555): @"kCVPixelFormatType_16LE555", @(kCVPixelFormatType_16LE5551): @"kCVPixelFormatType_16LE5551", @(kCVPixelFormatType_16BE565): @"kCVPixelFormatType_16BE565", @(kCVPixelFormatType_16LE565): @"kCVPixelFormatType_16LE565", @(kCVPixelFormatType_24RGB): @"kCVPixelFormatType_24RGB", @(kCVPixelFormatType_24BGR): @"kCVPixelFormatType_24BGR", @(kCVPixelFormatType_32ARGB): @"kCVPixelFormatType_32ARGB", @(kCVPixelFormatType_32BGRA): @"kCVPixelFormatType_32BGRA", @(kCVPixelFormatType_32ABGR): @"kCVPixelFormatType_32ABGR", @(kCVPixelFormatType_32RGBA): @"kCVPixelFormatType_32RGBA", @(kCVPixelFormatType_64ARGB): @"kCVPixelFormatType_64ARGB", @(kCVPixelFormatType_48RGB): @"kCVPixelFormatType_48RGB", @(kCVPixelFormatType_32AlphaGray): @"kCVPixelFormatType_32AlphaGray", @(kCVPixelFormatType_16Gray): @"kCVPixelFormatType_16Gray", @(kCVPixelFormatType_422YpCbCr8): @"kCVPixelFormatType_422YpCbCr8", @(kCVPixelFormatType_4444YpCbCrA8): @"kCVPixelFormatType_4444YpCbCrA8", @(kCVPixelFormatType_4444YpCbCrA8R): @"kCVPixelFormatType_4444YpCbCrA8R", @(kCVPixelFormatType_444YpCbCr8): @"kCVPixelFormatType_444YpCbCr8", @(kCVPixelFormatType_422YpCbCr16): @"kCVPixelFormatType_422YpCbCr16", @(kCVPixelFormatType_422YpCbCr10): @"kCVPixelFormatType_422YpCbCr10", @(kCVPixelFormatType_444YpCbCr10): @"kCVPixelFormatType_444YpCbCr10", @(kCVPixelFormatType_420YpCbCr8Planar): @"kCVPixelFormatType_420YpCbCr8Planar", @(kCVPixelFormatType_420YpCbCr8PlanarFullRange): @"kCVPixelFormatType_420YpCbCr8PlanarFullRange", @(kCVPixelFormatType_422YpCbCr_4A_8BiPlanar): @"kCVPixelFormatType_422YpCbCr_4A_8BiPlanar", @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange): @"kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange", @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange): @"kCVPixelFormatType_420YpCbCr8BiPlanarFullRange", @(kCVPixelFormatType_422YpCbCr8_yuvs): @"kCVPixelFormatType_422YpCbCr8_yuvs", @(kCVPixelFormatType_422YpCbCr8FullRange): @"kCVPixelFormatType_422YpCbCr8FullRange" }[self]; } @end 

Diagnostic Output Example

 NSMutableArray *mutablePixelFormatTypes = [NSMutableArray array]; [captureOutput.availableVideoCVPixelFormatTypes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [mutablePixelFormatTypes addObject:[obj descriptivePixelFormat]]; }]; NSString *pixelFormats = [mutablePixelFormatTypes componentsJoinedByString:@",\n"]; NSLog(@"Available pixel formats:\n%@\n", pixelFormats); 
+5
source

When you call the available VideoCVPixelFormatTypes, you get a decimal representation of all the labels like pixel format. If you convert them to hex, you can match some of them with the captions specified in the Apple Documentation . For the rest, you need to convert the hexadecimal value that you received into ASCII characters to finally match the label.

For instance:

(decimal) ------> (Hex) ---> (ASCII)

875704438 โ†’ 34323076 โ†’ 420v

875704422 โ†’ 34323066 โ†’ 420f

1111970369 โ†’ 42475241 โ†’ BGRA

I found this ASCII to Hex site to be useful.

+2
source

All Articles