不支持的像素格式类型xcode

时间:2015-04-08 08:07:28

标签: xcode

大家好我想从我的相机中提取帧,我正在使用AVCaptureVideoDataOutput,这是我的设置,我尝试将pixelformatTyoe设置为kCVPixelFormatType_24BGR

    AVCaptureVideoDataOutput *videoDataOutput = [[AVCaptureVideoDataOutput alloc] init];
[videoDataOutput setVideoSettings:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_24BGR], (id)kCVPixelBufferPixelFormatTypeKey, nil]];
[videoDataOutput setAlwaysDiscardsLateVideoFrames:YES];
[videoDataOutput setSampleBufferDelegate:self queue:sessionQueue];

但是,当我运行代码时,我收到以下错误。

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureVideoDataOutput setVideoSettings:] - 24BG (842285639) is not a supported pixel format type.  See AVCaptureOutput.h for a list of supported formats.  Available pixel format types on this platform are (
420v,
420f,
BGRA

)。“

这是否意味着我只能使用kCVPixelFormatType_32BGRA?对我来说,我必须创建一个alpha通道。

任何建议将不胜感激。提前谢谢!

1 个答案:

答案 0 :(得分:0)

您可以从 AVCaptureVideoDataOutput

检查 availableVideoCVPixelFormatTypes
availableVideoCVPixelFormatTypes
Indicates the supported video pixel formats that can be specified in videoSettings

Please, go through apple documentation