2.0 Details

2.1 Overview

Metadata is carried in MPEG-2 transport streams as described in section 2.12 of reference “[1].” HTTP Live Streaming metadata is carried in an elementary stream (PES) instead of, for example, in a carousel. The metadata stream must be in the same program as the main program material (i.e. the audio/video content).

ID3 metadata is self-describing and needs no configuration information, so the provisions for metadata decoder configuration data are not used.

The remainder of section 2 of this specification describes the details of the syntax and field values from section 2 of reference “[1]” for ID3 format metadata used with HTTP Live Streaming.

In the syntax tables in section 2.3.2 of this specification, the syntax structure (left column) is shown with only the names of fields and the part of the outline that is in effect for ID3 metadata as described in this specification. Conditional blocks for which a condition is false are omitted. The right column in the syntax tables indicates the value needed for each field in this context, or contains an explanation of that field.

The MPEG-2 specification “[1]” should be consulted for the complete syntax, field sizes, and acceptable values.

2.2 Summary of the Code Points Used

ID3 defines both a format and a semantic, and so the same registered format_identifier is used for both metadata_format_identifier and metadata_application_format_identifier.

The registered value for these, at the registration authority (reference “[4]”), is the four-character string ‘ID3 ’ (the characters I D 3 space, or 0x49 0x44 0x33 0x20).

To indicate that a registered value is used, the metadata_format and metadata_application_format fields take the values 0xff and 0xffff respectively.

The ID3 metadata is carried in a private stream, not a stream formatted as metadata Access Units (MAUs) as defined in 12.4 of “[1].” The stream_id value used for the stream is therefore private_stream_id_1, 0xbd, as specified in 2.12.3 of “[1].” The stream_type is set to 0x15, indicating carriage of metadata in a PES stream, as specified in 2.12.9.1 of “[1].”

Since only one metadata stream is normally carried, the metadata_service_id is normally set to 0; however, any suitable value can be used to distinguish this metadata stream from other metadata streams, if present.

2.3 Descriptors Used

2.3.1 Introduction

The format and content of the metadata descriptors is documented in sections 2.6.58 to 2.6.61 of “[1].”

2.3.2 Descriptor Loop of the PMT for the Program

To declare the presence of the metadata stream, a metadata_pointer_descriptor (2.6.58 of “[1]”) is placed in the PMT, in the program_info loop for the program. The metadata must be in the same program as the main program (audio/video) content; the use of this descriptor to refer to another program is not supported.

Syntax

Value

Metadata_pointer_descriptor () {

    descriptor_tag

37 (decimal) – Metadata_pointer_descriptor tag

    descriptor_length

– the length of the descriptor

    metadata_application_format

0xFFFF

    if (metadata_application_format==0xFFFF)

    {

        metadata_format_identifier

‘ID3 ’ (0x49 0x44 0x33 0x20)

    }

    metadata_format

0xFF

    if (metadata_format==0xFF) {

        metadata_format_identifier

‘ID3 ’ (0x49 0x44 0x33 0x20)

    }

    metadata_service_id

– any ID, typically 0

    metadata_locator_record_flag

0

    MPEG_carriage_flags

0

    reserved

0x1f

    if (MPEG_carriage_flags == 0|1|2)    {

        program_number

– program number of the program whose es descriptor loop contains the metadata_descriptor

    }

}

The elementary stream carrying the metadata needs to be declared in the loop of elementary streams, in the program map (section 2.4.4.8 of “[1]”):

Field

Value

stream_type

0x15

reserved

0x7

elementary_PID

– pid of the elementary stream carrying the metadata

reserved

0xf

ES_info_length

– length of the elementary stream info descriptor loop, including the metadata_descriptor

2.3.3 Descriptor Loop of the PMT for the Elementary Stream

To declare the format of the metadata stream, a metadata_descriptor (2.6.60 of “[1]”) is placed in the PMT, in the es_info loop for the elementary stream.

Syntax

Value

Metadata_descriptor () {

    descriptor_tag

38 (decimal) – Metadata_descriptor tag

    descriptor_length

– the length of the descriptor

    metadata_application_format

0xFFFF

    if (metadata_application_format==0xFFFF)

    {

        metadata_application_format_identifier

‘ID3 ’ (0x49 0x44 0x33 0x20)

    }

    metadata_format

0xFF

    if (metadata_format==0xFF) {

        metadata_format_identifier

'ID3 ' (0x49 0x44 0x33 0x20)

    }

    metadata_service_id

– any ID, typically 0

    decoder_config_flags

0

    DSM-CC_flag

0

    reserved

0xf

2.4 PES Stream Format

ID3 metadata is stored as a complete ID3v4 frame in a PES packet, including a complete ID3 header.

The ID3 tag must start immediately after the PES header; this PES header must contain a PTS (PTS_DTS_flags set to '10'). The PTS must be on the same timeline as the audio and video frames. The data_alignment bit must be set to 1. The PES header must contain a PES_packet_length that is non-zero.

If an ID3 tag is longer than 65535 bytes, it must have more than one PES header. The second and following PES headers must have data_alignment set to 0, and should have the PTS_DTS_flags set to ‘00’ (and hence no PTS).

The PES header is formatted as documented in 2.4.3.7 of “[1].”

PES Syntax

Value

PES_Packet () {

    packet_start_code_prefix

0x00 0x00 0x01

    stream_id

0xbd – private_stream_id_1

    PES_packet_length

– length of the packet, which must not be 0

    if (…) {

– a large test which is true in this case

        '10'

'10'

        PES_scrambling_control

0

        PES_priority

0

        data_alignment_indicator

1 for the packet containing start of the ID3 header, else 0

        copyright

0

        original_or_copy

0

        PTS_DTS_flags

if (data_alignment==1) ‘10’

else ‘00’

        ESCR_flag

0

        ES_rate_flag

0

        DSM_trick_mode_flag

0

        additional_copy_info_flag

0

        PES_CRC_flag

0

        PES_extension_flag

0

        PES_header_data_length

– the length of the data; padding may be used

    }

}

The metadata stream is incorporated into a transport stream in the same way as audio or video is. For example, in a transport_packet() (see 2.4.3.2 of “[1]”) the payload_unit_start_indicator is set to 1 only when a PES header follows. (The PES header, in turn, indicates whether the start of the ID3 data follows, or whether that has been divided into multiple PES packets).