问题描述
对于H264视频的起始代码(0x00 0x00 0x00 0x01)的用法,我有一个普遍的疑问.我不清楚此起始代码的用法,因为在RTP RFC中没有与H264视频相关的参考.但是我确实在网络中看到了很多参考,尤其是在stackoverflow中.
I have general question about the usage of start code (0x00 0x00 0x00 0x01) for the H264 video. I am not clear about the usage of this start code as there is no reference in the RTP RFCs that are related to H264 video. But I do see lot of reference in the net and particularly in the stackoverflow.
我很困惑,因为我看到一个客户端没有此起始代码,而另一个客户端正在使用此起始代码.因此,我正在寻找一个具体的答案,在哪里应该使用此起始代码,而在不应该使用的地方.
I am confused as I see one client doesn't have this start code and another client is using this start code. So, I am looking for a specific answer where this start code should be used and where I shouldn't.
KMurali
推荐答案
H.264流格式有两种,有时被称为
There are two H.264 stream formats and they are sometimes called
- 附件B(在原始H.264流中找到)
- AVCC(在MP4等容器中找到)
H.264流由NAL(打包单位)组成
An H.264 stream is made of NALs (a unit of packaging)
(1)附件B :每个NAL单元的字节[x00][x00][x00][x01]
之前都有4字节的起始代码.
(1) Annex B : has 4-byte start code before each NAL unit's bytes [x00][x00][x00][x01]
.
[start code]--[NAL]--[start code]--[NAL] etc
(2)AVCC :带有大小前缀(意味着每个NALU都以该NALU的字节大小开头)
(2) AVCC : is size prefixed (meaning each NALU begins with byte size of this NALU)
[SIZE (4 bytes)]--[NAL]--[SIZE (4 bytes)]--[NAL] etc
一些注意事项:
-
AVCC(MP4)流格式不包含任何类型为SPS,PPS或AU delimter的NAL.由于该特定信息现在位于MP4元数据中.
The AVCC (MP4) stream format doesn't contain any NALs of type SPS, PPS or AU delimter. Since that specific information is now placed within MP4 metadata.
您将在MPEG-2 TS,RTP和某些编码器默认输出中找到的Annex B格式.
The Annex B format you'll find in MPEG-2 TS, RTP and some encoders default output.
您将在MP4,FLV,MKV,AVI和类似的A/V容器格式中找到AVCC格式.
The AVCC format you'll find in MP4, FLV, MKV, AVI and such A/V container formats.
两种格式都可以相互转换.
Both formats can be converted into each other.
附件B到MP4 :删除起始代码,插入NAL的长度,过滤出SPS,PPS和AU分隔符.
Annex B to MP4 : Remove start codes, insert length of NAL, filter out SPS, PPS and AU delimiter.
附件B的MP4 :删除长度,插入起始代码,为每个I帧插入SPS,为每个帧插入PPS,为每个GOP插入AU分隔符.
MP4 to Annex B : Remove length, insert start code, insert SPS for each I-frame, insert PPS for each frame, insert AU delimiter for each GOP.
这篇关于H264视频的起始代码的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!