(Incomplete) MPEG1 System Stream Format
As far as I can tell, and I am not the only person under this impression, the only way to see the MPEG1 specification is to pay ISO a sizable sum of money in exchange for copies of the official standards documents. (ISO 11172 and friends)
This is not how standards should be published.
This is not cool.
What follows is an unofficial and incomplete description of the MPEG1 "System Stream" - mostly for my own notes. The wording is my own, and my reference is an MPEG-mangling program I wrote.
A "System Stream" is a stream that contains both MPEG audio and MPEG
video, multiplexed together.
It consists of:
- One or more packs
- The end code, 0x00 0x00 0x01 0xB9
A pack consists of:
- The pack start code, 0x00 0x00 0x01 0xBA
- A system clock reference, encoded in binary as:
0010 xxx1 (bits 32 through 30)
xxxx xxxx xxxx xxx1 (bits 29 through 15)
xxxx xxxx xxxx xxx1 (bits 14 through 0)
The system clock reference is a big-endian 33 bit integer.
The 1s are "marker" bits.
It specifies a time index related to the current pack.
90,000 units = 1 second.
Between packs, it should not go backwards.
It should not advance by more than 0.7 seconds. (63000 units)
- A mux rate, encoded as three bytes:
binary 1 (marker bit)
(22-bit big-endian unsigned integer)
binary 1 (marker bit)
- Either a system header or a packet
A system header consists of:
- The system header start code, 0x00 0x00 0x01 0xBB
- The header length, encoded as a 16-bit big-endian unsigned integer.
- n more bytes, where n equals the
(i.e. the header length is what remains after the header length field)
A packet consists of:
- A packet start code, 0x00 0x00 0x01 0xnn
Where nn is the stream ID:
- 0xBC - reserved stream
- 0xBD - private stream 1
- 0xBE - padding stream
- 0xBF - private stream 2
- 0xC0 through 0xDF - audio stream
- 0xE0 through 0xEF - video stream
- 0xF0 through 0xFF - reserved data stream
- The packet length, encoded as a 16-bit big-endian unsigned integer.
- That many bytes of packet data (like in the system header above)
Yes, this is incomplete.
However, it's enough information to make an effort at joining, splitting, and reindexing MPEG1 streams.