usage of start code for H264 video

后端 未结 1 2000
庸人自扰
庸人自扰 2021-02-04 21:58

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

1条回答
  •  执念已碎
    2021-02-04 22:28

    There are two H.264 stream formats and they are sometimes called

    1. Annex B (as found in raw H.264 stream)
    2. AVCC (as found in containers like MP4)

    An H.264 stream is made of NALs (a unit of packaging)

    (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 : is size prefixed (meaning each NALU begins with byte size of this NALU)

    [SIZE (4 bytes)]--[NAL]--[SIZE (4 bytes)]--[NAL] etc
    

    Some notes :

    • 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.

    • The Annex B format you'll find in MPEG-2 TS, RTP and some encoders default output.

    • 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.

    Annex B to MP4 : Remove start codes, insert length of NAL, filter out SPS, PPS and AU delimiter.

    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.

    0 讨论(0)
提交回复
热议问题