diff --git a/lib/membrane/hls/sink_bin.ex b/lib/membrane/hls/sink_bin.ex index cec14ea..3b99c82 100644 --- a/lib/membrane/hls/sink_bin.ex +++ b/lib/membrane/hls/sink_bin.ex @@ -319,10 +319,13 @@ defmodule Membrane.HLS.SinkBin do {:live, safety_delay} = state.opts.mode now = :erlang.monotonic_time(:millisecond) + # We wait until we have at least 3 segments before starting the initial sync process. + # This ensures a stable, interruption free playback for the clients. + minimum_segment_time = + Membrane.Time.as_milliseconds(state.opts.target_segment_duration, :round) * 3 + # Tells when we should do it. - deadline = - now + Membrane.Time.as_milliseconds(state.opts.target_segment_duration, :round) + - Membrane.Time.as_milliseconds(safety_delay, :round) + deadline = now + minimum_segment_time + Membrane.Time.as_milliseconds(safety_delay, :round) live_state = %{ next_sync_point: next_sync_point,