我正在使用videotoolbox框架编写一个使用H264编码AVCaptureVideoDataOutput的Mac应用。
VTCompressionSessionRef session;
OSStatus ret = VTCompressionSessionCreate(NULL, (int)width, (int)height, kCMVideoCodecType_H264, NULL, NULL, NULL, OutputCallback, NULL, &session);
回调实现如下:
void OutputCallback(void *outputCallbackRefCon,
void *sourceFrameRefCon,
OSStatus status,
VTEncodeInfoFlags infoFlags,
CMSampleBufferRef sampleBuffer)
{
CMBlockBufferRef block = CMSampleBufferGetDataBuffer(sampleBuffer);
char* bufferData;
size_t size;
CMBlockBufferGetDataPointer(block, 0, NULL, &size, &bufferData);
NSData *data = [NSData dataWithBytes:bufferData length:size];
//and i use this data
}
在日志
中有这些警告GVA warning: init, skip trailing zeros pps size = 35
GVA警告:init,跳过尾随零pps size = 34 GVA警告:AVF_Get_Standalone_PPS,跳过尾随零pps大小= 35
有人可以建议更好的解码方式在AVSampleBufferdisplayLayer中显示吗?