使用VideoToolBox进行编码和解码

时间:2017-10-20 09:57:01

标签: cocoa encoding decoding video-toolbox

我正在使用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中显示吗?

0 个答案:

没有答案