3

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

Kannan Murali
  • 39
  • 1
  • 2
  • You will find your answer here http://stackoverflow.com/questions/24884827/possible-locations-for-sequence-picture-parameter-sets-for-h-264-stream/24890903#24890903 – szatmary Feb 10 '15 at 01:37
  • I am trying to stream H.264 over RTP (hence UDP) so does the start code still apply? From this [RFC](https://tools.ietf.org/html/rfc6184) it does not mention a start code and I thought the start code would not be present since UDP is packetized (not a byte stream). Am I wrong in assuming this? I am having problems implementing this so I thought maybe I might be wrong. – ddelnano Feb 16 '15 at 17:47

1 Answers1

19

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.

VC.One
  • 14,790
  • 4
  • 25
  • 57
Markus Schumann
  • 7,636
  • 1
  • 21
  • 27