从CMSampleBufferRef获取sps和pps

Igo*_*pov 2 video-processing video-encoding video-streaming ios8

我使用新API将图像从相机推送到videoToolBox编码器,并从编码器回调中获取编码的CMSampleBufferRef

我需要这些sps和pts用于CMVideoFormatDescriptionCreateFromH264ParameterSets来配置解码器

任何人都可以帮助/指导我吗?) 谢谢

jgh*_*jgh 5

反过来相当容易,相关的功能是CMVideoFormatDescriptionGetH264ParameterSetAtIndex,并将使用类似的东西

CMFormatDescriptionRef format = CMSampleBufferGetFormatDescription(sampleBuffer);
size_t spsSize, ppsSize;
size_t parmCount;
const uint8_t* sps, *pps;

CMVideoFormatDescriptionGetH264ParameterSetAtIndex(format, 0, &sps, &spsSize, &parmCount, nullptr );
CMVideoFormatDescriptionGetH264ParameterSetAtIndex(format, 1, &pps, &ppsSize, &parmCount, nullptr );
Run Code Online (Sandbox Code Playgroud)