我尝试使用 CMVideoFormatDescriptionCreateFromH264ParameterSets 创建 CMVideoFormatDescriptionRef 但它失败并出现 -12712 错误(似乎没有在任何 header 中定义)
我从一个 mov 文件(由 iPhone 相机应用程序创建)的 avcC 原子中获取了我的 SPS 和 PPS:
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 有效载荷中,还是在大小值中。
关于ios - CMVideoFormatDescriptionCreateFromH264ParameterSets 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25078364/