Membrane.HLS.SinkBin (Membrane HLS Plugin v2.1.7)

View Source

Bin responsible for receiving audio and video streams, performing payloading and CMAF/TS/AAC muxing to eventually store them using provided storage configuration.

As soon as a spec-compliant HLS stream which segments of the same index:

  • start roughly at the same time (AAC and H264 cannot be cut at the same exact time)
  • have the same duration

The following measures have been implemented:

  • audio+subtitles fillers: if video starts earlier, we add the missing silence
  • audio+subtitles trimmers: if video starts later, we trim leading content

Special cases for our companies internal requirements (might change in the future):

  • when in a sliding window setup, we use discontinuities when the stream restarts
  • when in a non-sliding window setup, playlists will contain a best-effort strictly monotonically increasing PTS/DTS timeline. Best effort because right after a restart audio and video will contain a small offset hole. This is not spec complaint and we're planning on using the discontinuity pattern there as well.

Bin options

Passed via struct Membrane.HLS.SinkBin.t/0

  • packager

    pid()

    Required
    PID of a HLS.Packager. If the packager is configured with max_segments, the playlist will be offered with sliding windows. In case of restarts, a discontinuity indicator is added.

    In the other case, when the playlist does not have sliding windows, the sink will shift the timing of each segment in case of restarts to ensure PTS strictly increasing monotonicity.

  • target_segment_duration

    Membrane.Time.t()

    Required
    Target duration for each HLS segment.

  • mode

    {:live, Membrane.Time.t()} | :vod

    Default value: :vod

    • -> This element will include the provided segments in the media playlist each target_segment_duration. You're responsible for providing data for the segments in time.
    • :vod -> At the end of the segment production, playlists are written down.
  • flush_on_end

    boolean()

    Default value: true
    Automatically flush the packager when all streams ended. Set to false if flushing manually (via :flush notification).

Pads

:input

Accepted formats:

Membrane.H264
Membrane.AAC
Membrane.Text
Membrane.RemoteStream
Direction::input
Availability::on_request

Pad options:

  • container

    :CMAF | :TS | :PACKED_AAC

    Default value: :CMAF
    How A/V tracks are packaged.

  • encoding

    :AAC | :H264 | :TEXT

    Required
    Encoding type determining which parser will be used for the given stream.

  • omit_subtitle_repetition

    boolean()

    Default value: false
    When writing subtitle playlists, subtitles that span over multiple segments are repeated in both segments. When this flag is turned on, subtitles appear only in the segment in which they start.

  • subtitle_min_duration

    Membrane.Time.t()

    Default value: 1500000000
    Forces subtitles to last at list the specified amount of time. If omitted, subtitles will last the duration of their content.

  • relative_mpeg_ts_timestamps

    boolean()

    Default value: false
    If true, each subtitle segment will have a X-TIMESTAMP-MAP header and its contents will be relative to that timing.

  • build_stream

    (track() -> HLS.VariantStream.t() | HLS.AlternativeRendition.t())

    Required
    Build either a HLS.VariantStream or a HLS.AlternativeRendition.

  • segment_duration

    Membrane.Time.t()

    Required
    Duration for a HLS segment.

Summary

Types

Options for pad :input

t()

Struct containing options for Membrane.HLS.SinkBin

Functions

Returns description of options available for this module

Types

input_pad_opts()

@type input_pad_opts() :: [
  container: :CMAF | :TS | :PACKED_AAC,
  encoding: :AAC | :H264 | :TEXT,
  omit_subtitle_repetition: boolean(),
  subtitle_min_duration: Membrane.Time.t(),
  relative_mpeg_ts_timestamps: boolean(),
  build_stream: (track() ->
                   HLS.VariantStream.t() | HLS.AlternativeRendition.t()),
  segment_duration: Membrane.Time.t()
]

Options for pad :input

t()

@type t() :: %Membrane.HLS.SinkBin{
  flush_on_end: boolean(),
  mode: {:live, Membrane.Time.t()} | :vod,
  packager: pid(),
  target_segment_duration: Membrane.Time.t()
}

Struct containing options for Membrane.HLS.SinkBin

track()

@type track() :: Membrane.CMAF.Track.t() | map()

Functions

options()

@spec options() :: keyword()

Returns description of options available for this module