需要将 h264 流从附件 b 格式转换为 AVCC 格式 [英] Need to convert h264 stream from annex-b format to AVCC format
问题描述
我需要将 h264 流从附件 b 格式转换为 AVCC 格式.
I need to convert h264 stream from annex-b format to AVCC format.
我尝试将其从 h264 附件-b 转换为 AVCC:我从附件流中提取了 SPS 和 PPS 并创建了 Extra 数据.然后我在流中查找 0x00 0x00 0x00 0x01 (这应该是每个 Nal 的开头)并继续寻找另一个 0x00 0x00 0x00 0x01 (这将是 Nal 的结尾)然后减去以获得 Nal 长度,然后将第一个 0x00 0x00 0x00 0x01 替换为 0x00 0x00 0x00 [NulSize] 但似乎这不会产生有效的流.然后我发现 NUL 可以以 0x00 0x00 0x01 开始/结束,所以我有点困惑.
I tried this to convert from h264 annex-b to AVCC: I extracted the SPS and PPS from the annex stream and created the Extra data. I then looked in the stream for 0x00 0x00 0x00 0x01 (which should be the start of each Nal) and continue looking for another 0x00 0x00 0x00 0x01 (which will be the end of the Nal) then did minus to get the Nal length, then replace the first 0x00 0x00 0x00 0x01 to 0x00 0x00 0x00 [NulSize] but seems that this does not produce valid stream. I then found out that NUL can starts/ends with 0x00 0x00 0x01 so i am little confused.
无论如何,我希望有人能够为我编写从附件-b 转换为 AVCC 的函数.
anyway, I hope someone will be able to write me function that convert from annex-b to AVCC.
谢谢.
推荐答案
NALU
是基本单元.
那么,
附件格式:
([起始码] NALU) |( [起始码] NALU) |
avcc 格式:
<代码>([额外数据]) |([长度] NALU) |([长度] NALU) |
在附件b中,[起始码]
可以是0x000001
或0x00000001
.
In annexb, [start code]
may be 0x000001
or 0x00000001
.
在avcc中,[length]
的字节数取决于avcc extradata
中的NALULengthSizeMinusOne
,[length]<的值/code> 取决于后面
NALU
的大小,在 annexb 和 avcc
格式中,NALUs
没有什么不同.
In avcc, the bytes of [length]
depends on NALULengthSizeMinusOne
in avcc extradata
, the value of [length]
depends on the size of following NALU
and in both annexb and avcc
format, the NALUs
are no different.
这篇关于需要将 h264 流从附件 b 格式转换为 AVCC 格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!