18

I have a file that only contains the mdat atom in a MP4 container. The data in the mdat contains AVC data. I know the encoding parameters for the data. The format does not appear to be in the Annex B byte stream format. I am wondering how I would go about parsing this. I have tried searching for the slice header, but have not had much luck.

Is it possible to parse the slices without the NAL's?

Steve McFarlin
  • 3,576
  • 1
  • 25
  • 24

3 Answers3

19

Be careful! The NAL Length is not required to be 4! The AvcConfigurationBox ('moov/trak/mdia/minf/stbl/stsd/avc1/avcC') contains a field 'lengthSizeMinusOne' specifying the length. But the default is 4.

Sebastian Annies
  • 2,438
  • 1
  • 20
  • 38
  • I know this is a old discussion but can someone give me some idea how can i fetch the aac and h264 data from mdat element. – Dinesh Aug 26 '15 at 06:30
18

AVC NAL units are in the following format in MDAT section: [4 bytes] = NAL length, network order; [NAL bytes] Shortly, start codes are simply replaced by lengths.

michael
  • 216
  • 2
  • 2
14

I found what michael was talking about defined in section 5.2.3 of ISO 14496-15.

Sebastian's answer refers to section 5.2.4.1.1 and 5.3.4.1.2.

You will not be able to parse the slices in the 'mdat' box without copies of the SPS and PPS from the 'avcC' box (defined in section 5.2.4.1.1)

Mutant Bob
  • 3,121
  • 2
  • 27
  • 52
  • 1
    Time flies. The 14496-15:2014 changed the section numbering, this reply refers to at least 14496-15:2004 standard. – FredG Oct 26 '18 at 20:20