Error code -8969, -12909 while decoding h264 in iOS 8 with video tool box

徘徊边缘 提交于 2019-11-30 06:50:44
Alex Cheng

Finally, got it working now. So, I share the details on how to use the VideoToolbox to decode h.264 stream data:

  1. Get SPS & PPS NALUs from H.264 stream data (or SDP)
  2. Create CMFormatDescription by using CMVideoFormatDescriptionCreateFromH264ParameterSets.
  3. Create VTDecompressionSession by using VTDecompressionSessionCreate.
  4. Get NALUnit payload into a CMBlockBuffer.
  5. Replace the start code with a 4 byte length code. (ps: length = NALUnit length - start code length)
  6. Create a CMSampleBuffer by using CMSampleBufferCreate.
  7. Use VTDecompressionSessionDecodeFrame and get the result from callback.

then, you have to use dispatch_semaphore_t to control frame decoding and showing. I upload the sample project on my git. hope to help someone else.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!