需要将h264流从附件b格式转换为AVCC格式

需要将h264流从附件b格式转换为AVCC格式

本文介绍了需要将h264流从附件b格式转换为AVCC格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将h264流从附件b格式转换为AVCC格式.

I need to convert h264 stream from annex-b format to AVCC format.

我试图将h264 annex-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是基本单位.

然后

附件格式:

([start code] NALU) | ( [start code] NALU) |

avcc格式:

([extradata]) | ([length] NALU) | ([length] NALU) |

在附件b中,[start code]可能是0x0000010x00000001.

In annexb, [start code] may be 0x000001 or 0x00000001.

在avcc中,[length]的字节取决于avcc extradata中的NALULengthSizeMinusOne[length]的值取决于后面的NALU的大小,并且在两个annexb and 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格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 02:48