HLS Inline Custom Tags

You can activate this plugin with the string manifest_edit.plugins.m3u8_main.hls_inline_custom_tags.

Custom Timed Metadata signalling on HLS is today possible with Remix as described in our doc.

In a nutshell, the payload of an Event provided in the SMIL playlists

<?xml version="1.0" encoding="UTF-8"?>
<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
  <body>
    <seq>
      <par>
        <video
          src="input.mp4"
          clipBegin="wallclock(1970-01-01T00:00:00.000Z)"
          clipEnd="wallclock(1970-01-01T00:00:16.000Z)" />
        <EventStream xmlns="urn:mpeg:dash:schema:mpd:2011"
          schemeIdUri="my:scheme">
          <Event
            duration="0"
            id="1234">
            <CustomMetadata xmlns="http://xmlns/2019">
              <Title>Title</Title>
              <YearPublished>2019</YearPublished>
            </CustomMetadata>
          </Event>
        </EventStream>
      </par>
    </seq>
  </body>
</smil>

is always signalled in an HLS playlist using the EXT-X-DATERANGE tag

#EXT-X-DATERANGE:ID="1",CLASS="my:scheme",START-DATE="1970-01-01T00:00:00Z",PLANNED-DURATION=0,X-MESSAGE-DATA="CjxDdXN0b21NZXRhZGF0YQogIHhtbG5zPSJodHRwOi8veG1sbnMvMjAxOSI+CiAgPFRpdGxlPlRpdGxlPC9UaXRsZT4KICA8WWVhclB1Ymxpc2hlZD4yMDE5PC9ZZWFyUHVibGlzaGVkPgo8L0N1c3RvbU1ldGFkYXRhPg=="

based on the following, unmodifiable mapping:

  • The @id is copied to the ID field.

  • The @schemeIdUri copied to the CLASS field.

  • The @presentationTime is copied to the START-DATE field.

  • The payload of the event is base64 encoded in the X-MESSAGE-DATA field.

Market research, competitive analysis and user requests have identified the need for Unified Streaming to make signalling of Custom Timed Metadata more flexible to maximize compatibility with third-party Ad Insertion platforms that expect to find custom metadata in different tags and/or in different formats.

In order to provide a flexible and future-proof way forward, we have designed a Manifest Edit-based solution that, using the default Origin EXT-X-DATERANGE tag content, can apply a configurable transformation to achieve any possible Timed Metadata signalling.

The solution involves the following steps:

  1. Users craft a signalling string they would like to appear in the HLS playlist (i.e. #EXT-X-ASSET:GENRE-CV, ...)

  2. The string is base64-encoded and used as payload of an Event to be included in the SMIL playlist. A distinctive value for schemeIdUri is used for such events (schemeIdUri="http://unified-streaming.com/hls/inline")

  3. This generates a standard #EXT-X-DATERANGE tag in the HLS stream.

  4. A Manifest Edit plugin can then be activated to detect EXT-X-DATERANGE tags that need to be transformed in custom HLS signalling (based on attribute values; several selection options are available, e.g. schemedIdUri='http://unified-streaming/hls/inline', id='1234')

  5. The plugin decodes the X-MESSAGE-DATA payload and transparently adds it to the playlist. The original EXT-X-DATERANGE can be kept or removed based on plugin configuration

The solution is based on simply translating a user-provided string into a string that appears in the HLS playlist. This provides maximum flexibility and future-proofs the solution, allowing the use of any possible HLS signalling.

Warning

Inlining is performed without any check of the string. This means that it is the user's responsibility to provide a string that starts with a valid HLS tag and has a valid syntax.

Plugin configuration

The plugin acts by inlining the X-MESSAGE-DATA payload from selected #EXT-X-DATERANGE` tags present in the manifest. The selection can be performed either by ID and/or by CLASS values:

m3u8_media:
  - manifest_edit.plugins.m3u8_media.hls_inline_custom_tags:
    - id: '.*'
      class: 'http://unified-streaming.com/hls/inline'
      remove-EXT-X-DATERANGE: false
  • id can be any regular expression that will be used to match the content of the ID attribute of EXT-X-DATERANGE tags.

  • class must always be set to http://unified-streaming.com/hls/inline and its purpose is to support future expansion of functionalities.

  • remove-EXT-X-DATERANGE can be used to choose whether the original EXT-X-DATERANGE tag that has been inlined should be removed from the edited manifest or not.

Example

This example is based on the most immediate use case, that is adding content metadata using the EXT-X-ASSET tag, as required by AWS Mediatailor:

#EXT-X-ASSET:GENRE=CV,CAID=12345678,EPISODE="Episode%20Name%20Date",SEASON="Season%20Name%20and%20Number",SERIES="Series%2520Name"

Users should add this information to the SMIL playlist by first applying a base64 encoding to this string

I0VYVC1YLUFTU0VUOkdFTlJFPUNWLENBSUQ9MTIzNDU2NzgsRVBJU09ERT0iRXBpc29kZSUyME5hbWUlMjBEYXRlIixTRUFTT049IlNlYXNvbiUyME5hbWUlMjBhbmQlMjBOdW1iZXIiLFNFUklFUz0iU2VyaWVzJTI1MjBOYW1lIg==

and then crafting an Event by choosing schemeIdUri, duration and id values, providing then the encoded string as the base64 Event payload.

<?xml version='1.0' encoding='UTF-8'?>
<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
  <head/>
  <body>
    <seq>
      <par>
      <video
      src="input.mp4"/>
      <EventStream xmlns="urn:mpeg:dash:schema:mpd:2011"
          schemeIdUri="http://unified-streaming.com/hls/inline">
          <Event
            duration="0"
            id="1234"
            contentEncoding="base64">I0VYVC1YLUFTU0VUOkdFTlJFPUNWLENBSUQ9MTIzNDU2NzgsRVBJU09ERT0iRXBpc29kZSUyME5hbWUlMjBEYXRlIixTRUFTT049IlNlYXNvbiUyME5hbWUlMjBhbmQlMjBOdW1iZXIiLFNFUklFUz0iU2VyaWVzJTI1MjBOYW1lIg==</Event>
        </EventStream>
      </par>
  </seq>
  </body>
</smil>

This results in the default Origin signalling that makes use of the EXT-X-DATERANGE tag, resulting in a playlist with the following content:

#EXT-X-DATERANGE:ID="1234-0",CLASS="http://unified-streaming.com/hls/inline",START-DATE="1970-01-01T00:00:00Z",PLANNED-DURATION=0,X-MESSAGE-DATA="I0VYVC1YLUFTU0VUOkdFTlJFPUNWLENBSUQ9MTIzNDU2NzgsRVBJU09ERT0iRXBpc29kZSUyME5hbWUlMjBEYXRlIixTRUFTT049IlNlYXNvbiUyME5hbWUlMjBhbmQlMjBOdW1iZXIiLFNFUklFUz0iU2VyaWVzJTI1MjBOYW1lIg=="

By configuring and enabling the hls_inline_custom_tags Manifest Edit plugin, the user-generated signalling string can be extracted and decoded from the selected EXT-X-DATERANGE tags payload:

m3u8_media:
  - manifest_edit.plugins.m3u8_media.hls_inline_custom_tags:
    - id: '.*'
      class: 'http://unified-streaming.com/hls/inline'
      remove-EXT-X-DATERANGE: false

With such a configuration, that includes keeping the original EXT-X-DATERANGE tag, the edited playlist would contain the following lines.

#EXTM3U
#EXT-X-VERSION:4
## Created with Unified Streaming Platform (version=1.11.23-28141)
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:2
#USP-X-TIMESTAMP-MAP:MPEGTS=900000,LOCAL=1970-01-01T00:00:00Z
#EXT-X-DATERANGE:ID="1234-0",CLASS="http://unified-streaming.com/hls/inline",START-DATE="1970-01-01T00:00:00Z",PLANNED-DURATION=0,X-MESSAGE-DATA="I0VYVC1YLUFTU0VUOkdFTlJFPUNWLENBSUQ9MTIzNDU2NzgsRVBJU09ERT0iRXBpc29kZSUyME5hbWUlMjBEYXRlIixTRUFTT049IlNlYXNvbiUyME5hbWUlMjBhbmQlMjBOdW1iZXIiLFNFUklFUz0iU2VyaWVzJTI1MjBOYW1lIg=="
#EXT-X-ASSET:GENRE=CV,CAID=12345678,EPISODE="Episode%20Name%20Date",SEASON="Season%20Name%20and%20Number",SERIES="Series%2520Name"
#EXT-X-PROGRAM-DATE-TIME:1970-01-01T00:00:00Z
#EXTINF:1.92, no desc
test-video=2191000-1.ts
#EXTINF:1.92, no desc
test-video=2191000-2.ts
#EXTINF:1.92, no desc
test-video=2191000-3.ts
#EXTINF:1.92, no desc
test-video=2191000-4.ts
#EXTINF:1.92, no desc
test-video=2191000-5.ts
#EXTINF:1.92, no desc
test-video=2191000-6.ts
#EXTINF:1.92, no desc
test-video=2191000-7.ts
#EXTINF:1.6, no desc
test-video=2191000-8.ts
#EXT-X-ENDLIST

Since the additional line with a custom tag is just obtained by inlining the content of the X-MESSAGE-DATA payload in the playlist, it is possible inline of principle to obtain any desired result in terms of custom signalling.