EXT-X-MEDIA Remove

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

This plugin allows to remove selected EXT-X-MEDIA entries from a m3u8 Main Playlist.

When adding alternate media to a playlist, EXT-X-MEDIA entries identify an element of a media selection group. By default, Unified Origin generates a main m3u8 playlist that includes all the possible variants of the streams. More details on this are available at the Definition of HLS variant stream page.

Sometimes, it is desirable to obtain one or more main playlists that instead only include some of the variants (i.e. only a particular codec, or only a particular audio group). For dynamic packaging, Playout Control can achieve that by performing dynamic track selection.

In case you can't use or achieve your goals with Playout Control, this plugin gives you a flexible way to selectively remove tracks from a main m3u8 Playlist in order to create playlist that only contains a subset of all possible "variants".

Plugin configuration

The "ext_x_media_remove" plugin allows you to select one or more EXT-X-MEDIA tags in a manifest by TYPE, GROUP-ID, LANGUAGE, NAME and URI, and then remove them.

This is an example of pipeline configuration including the ext_x_media_remove plugin.

m3u8_main:
  - manifest_edit.plugins.m3u8_main.ext_x_media_remove:
    - type: 'SUBTITLES'
      group-id: 'textstream'
      language: 'de'

The above example will select all EXT-X-MEDIA tags in a Main Playlist having TYPE=SUBTITLES, GROUP-ID="textstream" and LANGUAGE="de" attributes. These tags will all be removed, if present.

Fields type, group-id, language, name and uri are used to perform selection of specific EXT-X-MEDIA tags, e.g. to select the track(s) you need to remove. The following rules apply:

  • the supported values for the type field are 'AUDIO', 'VIDEO', 'SUBTITLES' and 'CLOSED_CAPTIONS'. This is a mandatory item and must always be included in your configuration

  • the value for fields group-id, language, name and uri can be any regular expression

  • fields group-id, language, name and uri are optional and can each be omitted, which is functionally equivalent to specifying a '.*' "match-all" regular expression

  • specifying an empty string '' for any of the fields group-id, language, name and uri can be used to perform "negative selection" on EXT-X-MEDIA tags, i.e. to select tracks that do not have one or more of such optional fields

After removing tracks, the plugin will check if one or more previously defined media group of a given type has been removed entirely. If that is the case, the plugin will also remove all stream descriptor EXT-INF-STREAM-INF entries that reference the removed group.

It is possible with this plugin to entirely remove all tracks and thus obtain an empty manifest. This is probably never the intended goal and may be just the outcome of using too permissive regular expressions. Be aware that this is possible and always double-check the outcome of your configuration.

Warning

The DEFAULT and AUTOSELECT attributes are normally assigned to EXT-X-MEDIA to signal players what rendition they SHOULD/MAY play in absence of an explicit user choice. After removing one or more tracks with this plugin, you may also need to reassign DEFAULT and AUTOSELECT values based on the new track set. You can do so by means of the Default language plugin.

Examples

Removing any track(s) with name "German" and type "AUDIO":

m3u8_main:
  - manifest_edit.plugins.m3u8_main.ext_x_media_remove:
    - type: 'AUDIO'
      name: 'German'

Removing the same track(s) by using the "LANGUAGE=" value:

m3u8_main:
  - manifest_edit.plugins.m3u8_main.ext_x_media_remove:
    - type: 'AUDIO'
      language: 'de'

Removing specific audio tracks (German) from a certain group:

m3u8_main:
  - manifest_edit.plugins.m3u8_main.ext_x_media_remove:
    - type: 'AUDIO'
      group-id: '.*aacl.*'
      language: 'de'

Removing all audio tracks belonging to a certain group:

m3u8_main:
  - manifest_edit.plugins.m3u8_main.ext_x_media_remove:
    - type: 'AUDIO'
      group-id: '.*aacl.*'

You can find additional examples of configuration in the Included Use Cases chapter.