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

爷,独闯天下 提交于 2019-11-29 07:19:46

问题


I have the h264 stream inAnnex B format and follow this link here to implements h264 decoding with iOS8 videoToolBox.

I check the OSStatus in every step.

  1. use CMVideoFormatDescriptionCreateFromH264ParameterSets with the SPS and PPS data to create a CMFormatDescription.(status == noErr)

  2. create a VTDecompressionSession using VTDecompressionSessionCreate. (status == noErr)

  3. capture the NALUnit payload into a CMBlockBuffer making sure to replace the start code with
    a byte length code. (status == noErr)

  4. create a CMSampleBuffer. (status == noErr)

  5. use VTDecompressionSessionDecodeFrame and get error code -8969(simulator), -12909(device) in callback function.

I doubt I did something wrong in step3, I am not pretty sure what the length code means. I just follow the WWDC session video replace every NALUnit start code 00 00 00 01 to 00 00 80 00. Is it right or not ? or I should check something else ?? thanks


回答1:


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.



来源:https://stackoverflow.com/questions/26601776/error-code-8969-12909-while-decoding-h264-in-ios-8-with-video-tool-box

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