我正在编写一个使用 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 警告:初始化,跳过尾随零 pps 大小 = 34 GVA 警告:AVF_Get_Standalone_PPS,跳过尾随零 pps 大小 = 35
谁能建议一种更好的解码方法以在 AVSampleBufferdisplayLayer 中显示?