AVCaptureVideoDataOutput和设置kCVPixelBufferWidthKey& kCVPixelBufferHeightKey

时间:2011-11-01 14:25:44

标签: iphone ios video-capture avcapturesession

我正在尝试通过设置AVCaptureVideoDataOutput&来捕获kCVPixelBufferWidthKey中特定尺寸的帧。 kCVPixelBufferHeightKey
问题是缓冲区宽度和高度永远不会改变,它们总是会回来 852x640

这是我的代码:

// Add the video frame output   
    self.videoOutput = [[AVCaptureVideoDataOutput alloc] init];
    [videoOutput setAlwaysDiscardsLateVideoFrames:YES];
// Use RGB frames instead of YUV to ease color processing
[videoOutput setVideoSettings:[NSDictionary dictionaryWithObjectsAndKeys:
                               [NSNumber numberWithFloat:320.0], (id)kCVPixelBufferWidthKey,
                               [NSNumber numberWithFloat:320.0], (id)kCVPixelBufferHeightKey,
                               [NSNumber numberWithInt:kCVPixelFormatType_32BGRA],(id)kCVPixelBufferPixelFormatTypeKey,
                                                              nil]];
 [videoOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];   

编辑:来自iOS AVCaptureOutput.h:目前,唯一支持的密钥是kCVPixelBufferPixelFormatTypeKey。

有谁知道设置输出缓冲区宽度/高度的工作方法?

1 个答案:

答案 0 :(得分:4)

来自iOS AVCaptureOutput.h的

Currently, the only supported key is kCVPixelBufferPixelFormatTypeKey.

总结了这一点。