AVC (also known as H.264 and MPEG-4 Part 10) is a successor of MPEG-2 Video coding format. AVC was published in 2003. After 19 years in 2022 it is still one of the most widely used codec. At the high level the AVC video is the sequence of NAL Units (Network Abstraction Layer Units). There are two main ways of storing NAL Units sequence into byte-stream:
- Annex B part of specification describes the way of storing NAL Units with startcode prefix (0x00000001). This startcode is added to every NAL Unit. All byte sequences 0x000000 which is located in the middle of NAL Unit are replaced by 0x00000300 to escape startcodes;
- avc1/avc3 byte-stream formats where every NAL Unit is prefixed by size of this Unit. SPS and PPS are stored separately in decoder configuration record (also known as decoder config or codec config). In avc1 bitstream SPS and PPS are stored separately only, avc3 allows to store them in band with main AVC content as well.
Annex B is used for live formats like MPEG-TS when there is no way to send metadata separately. For file formats like MP4 and MKV the second approach is used.
AVC decoder configuration record contains SPS and PPS NAL Units with extra metadata which describes parameters of elementary bitstream. Format of AVC decoder configuration record is specified in ISO/IEC 14496-15. Field LengthSizeMinusOne describes length of size block inserted before every NAL Unit. On screenshot LengthSizeMinusOne = 3 which means length of size block is 4 bytes.
Conclusion
We have described AVC bitstream formats. AVC video files can be analyzed with Virinext Bitstream Analyzer. It is a GUI tool for both in-depth and high-level analysis for many encoding standards including AVC video.