问题
I don't know which value to use to fetch raw YUV420p data. code below first:
AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
output.alwaysDiscardsLateVideoFrames = YES;
output.videoSettings = @{(id)kCVPixelBufferPixelFormatTypeKey: [NSNumber numberWithUnsignedInt:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange]};
//output.videoSettings = @{(id)kCVPixelBufferPixelFormatTypeKey: [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA]};
dispatch_queue_t queue;
queue = dispatch_queue_create("CameraQueue", NULL);
[output setSampleBufferDelegate:self queue:queue];
[session addOutput:output];
I noticed that kCVPixelFormatType has some values, does somebody know which value is right to fetch raw YUV420p data?
kCVPixelFormatType_420YpCbCr8Planar
kCVPixelFormatType_420YpCbCr8PlanarFullRange
kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
can be one of them?
回答1:
It depends on which particular YUV420 you want to get:
Planar
/Biplanar
refers to the arrangement of the luma and chroma components in memory, Planar
meaning that each component comes in a buffer, contiguous or not, and Biplanar
pointing to two buffers, one for luma and another for chroma, usually interleaved. An example of Planar
is YUV420 format and an example of Biplanar
is NV21 or NV12
VideoRange
and FullRange
refers to the values of the luma component, Video
referring to [16,235] accepted levels and FullRange
to [0,255]. This confusing agreement comes from the MPEG standard (see here)...
来源:https://stackoverflow.com/questions/24113392/how-to-fetch-raw-yuv420p-camera-data