Kannan Murali
Kannan Murali

Reputation: 59

usage of start code for H264 video

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

Upvotes: 5

Views: 8196

Answers (1)

Markus Schumann
Markus Schumann

Reputation: 8244

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.

Upvotes: 20

Related Questions