CMVideoFormatDescriptionCreateFromH264ParameterSets 问题
题
我尝试过创建 CMVideoFormatDescriptionRef
和 CMVideoFormatDescriptionCreateFromH264ParameterSets
但它失败并出现 -12712 错误(似乎没有在任何标头中定义)
我已从以下机构获取了 SPS 和 PPS: avcC
mov 文件的原子(由 iPhone 相机应用程序创建):
61 76 63 43 01 64 00 29 FF E1 00 10 67 64 00 29 AC 56 80 78 02 27 E5 9A 80
80 80 81 01 00 05 28 EE 04 F2 C0
SPS 似乎是: 67 64 00 29 AC 56 80 78 02 27 E5 9A 80 80 80 81
...以及 PPS: 28 EE 04 F2 C0
我已经在 SPS 和 PPS 之前使用了 4 字节长度(也尝试了 1 字节和 2 字节长度,结果相同),并发出如下调用:
uint8_t sps[] = {0x00, 0x00, 0x00, 0x10, 0x67, 0x64, 0x00, 0x29, 0xAC, 0x56, 0x80, 0x78, 0x02, 0x27, 0xE5, 0x9A, 0x80, 0x80, 0x80, 0x81};
uint8_t pps[] = {0x00, 0x00, 0x00, 0x05, 0x28, 0xEE, 0x04, 0xF2, 0xC0};
uint8_t* props[] = {sps, pps};
size_t sizes[] = {0x14, 0x09}; // sizes include the 4-byte length
CMVideoFormatDescriptionRef formatDesc;
OSStatus formatCreateResult = CMVideoFormatDescriptionCreateFromH264ParameterSets(NULL, 2, props, sizes, 4, &formatDesc);
我每次都会得到 -12712 作为结果(尝试了来自多个文件和流的 SPS / PPS)。
你知道我做错了什么吗?(代码在模拟器上的Xcode6-Beta4上检查)。我宁愿避免自己解析 SPS 和 PPS 并使用普通的 CMVideoFormatDescriptionCreate :-)
解决方案
不包括 4 字节大小。无论是在 sps/pps 有效负载中,还是在大小值中。
其他提示
我用谷歌搜索了你;-)
检查这个 Chromium 代码
https://src.chromium.org/svn/trunk/src/content/common/gpu/media/vt_video_decode_accelerator.cc
这个关于 H.264 SPS/PPS NALU 的答案
不隶属于 StackOverflow