-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Problem
When a Membrane pipeline is restarted (e.g. after a server crash or planned restart), Manifest.Track always initialises current_seq_num and next_segment_id to 0. If the HLS output directory still contains segments from the previous run, the new playlist will emit a #EXT-X-MEDIA-SEQUENCE value lower than what active players last saw. Per RFC 8216 §4.3.3.2 the media sequence number must never decrease between playlist reloads, so this causes players to stall or error out.
Steps to reproduce
- Start a live HLS pipeline writing to a directory.
- Let it run long enough to produce several segments (e.g.
#EXT-X-MEDIA-SEQUENCE:10). - Restart the server / pipeline without clearing the output directory.
- Observe the new playlist starts at
#EXT-X-MEDIA-SEQUENCE:0while the directory still contains segments namedaudio_segment_10_*.m4setc. - An active HLS player (e.g. hls.js) will treat the sequence regression as a fatal error.
Expected behaviour
Track.Config (or Sink.TrackConfig) should expose initial_seq_num and initial_segment_id fields so that a recovered pipeline can seed the track state from values parsed out of the pre-existing playlist, producing a continuously-increasing sequence without a #EXT-X-DISCONTINUITY marker.
Suggested API
# Track.Config addition
defstruct @enforce_keys ++ [
...
initial_seq_num: 0,
initial_segment_id: 0
]
# Track.new/1 honours them
%__MODULE__{
current_seq_num: config.initial_seq_num,
next_segment_id: config.initial_segment_id,
segment_sequencer: {config.initial_seq_num, 0},
...
}SinkBin would expose matching options and thread them through to Sink.TrackConfig.
Workaround
Until this is addressed upstream we are maintaining local copies of Sink and SinkBin that apply the initial values via Map.merge after Manifest.add_track/2 creates the track, and parsing the existing playlist ourselves with a small regex-based parser.
Environment
membrane_http_adaptive_stream_pluginv0.20.2- Elixir 1.x / OTP 26