Segmenting MPEG-2 transport streams

Perform transport stream segmentation based on the presentation time stamps (PTSs) in the transport stream. Ensure that the difference between the first (earliest) PTS in segment n and segment n + 1 is less than or equal to the segment duration indicated by the #EXT-X-TARGETDURATION attribute.

Do not split PES packet data between segments. Because A/V streams consist of interleaved PES packet data in most cases, reorganizing transport stream packet data may be required.[1]

Because random access is limited in HTTP Live Streaming to segment boundaries, a single Program Association Table (PAT) and Program Map Table (PMT) table is sufficient in the beginning of each segment. A PAT followed by a PMT is required for media decoding. Table repetition inside the segment is not required and may be omitted to save bandwidth.

For optimal bandwidth efficiency, we recommend the use of variable bit-rate transport stream segments over a constant bit rate. Convert constant bit-rate transport stream segments to variable bit rate by removing any null packets present in the transport stream segment.

[1] In a variable bit-rate transport stream, this can be achieved relatively easily by moving the transport stream packets of the corresponding PES packet from segment n + 1 to the end of the segment n.