Membrane.HLS.SinkBin (Membrane HLS Plugin v2.1.7)
View SourceBin 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
packagerpid()Required
PID of aHLS.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_durationMembrane.Time.t()Required
Target duration for each HLS segment.mode{:live, Membrane.Time.t()} | :vodDefault 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_endboolean()Default value:
true
Automatically flush the packager when all streams ended. Set tofalseif flushing manually (via:flushnotification).
Pads
:input
Accepted formats:
Membrane.H264Membrane.AACMembrane.TextMembrane.RemoteStream| Direction: | :input |
| Availability: | :on_request |
Pad options:
container:CMAF | :TS | :PACKED_AACDefault value:
:CMAF
How A/V tracks are packaged.encoding:AAC | :H264 | :TEXTRequired
Encoding type determining which parser will be used for the given stream.omit_subtitle_repetitionboolean()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_durationMembrane.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_timestampsboolean()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 aHLS.VariantStreamor aHLS.AlternativeRendition.segment_durationMembrane.Time.t()Required
Duration for a HLS segment.
Summary
Types
@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
@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
@type track() :: Membrane.CMAF.Track.t() | map()
Functions
@spec options() :: keyword()
Returns description of options available for this module