10

我正在尝试在 AVFoundation 输出中找到可接受的格式:

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

然后我在之后插入一个断点:

po [self.theOutput availableVideoCVPixelFormatTypes]

我明白了:

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

如何获取这些格式类型的字符串值?

谢谢

4

3 回答 3

10

在运行 iOS6 的 iPhone5 上,这里是可用的 AVCaptureVideoDataOuputVideoCVPixelFormatTypes:

kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange

kCVPixelFormatType_420YpCbCr8BiPlanarFullRange

kCVPixelFormatType_32BGRA

信用到期的信用,我找到了一种方法来获得这里支持的价值。 https://gist.github.com/2327666

于 2013-01-27T12:24:53.483 回答
5

用于调试的类别版本

作为 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

诊断输出示例

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);
于 2015-01-08T11:49:15.400 回答
5

当您调用 availableVideoCVPixelFormatTypes 时,您将获得所有像素格式类型标签的十进制表示。如果将它们转换为十六进制,则可以将其中一些与Apple 文档中列出的标签匹配。其余的你必须将你得到的十六进制值转换为 ASCII 字符以最终匹配标签。

例如:

(十进制) ------> (十六进制) ---> (ASCII)

875704438 -> 34323076 -> 420v

875704422 -> 34323066 -> 420f

1111970369 -> 42475241 -> BGRA

我发现这个网站“ ASCII to Hex ”很有用。

于 2016-06-29T02:54:58.780 回答