How does #EXT-X-DISCONTINUITY-SEQUENCE tag work in HLS m3u8 file

http-live-streamingm3u8

I'm inspecting about #EXT-X-DISCONTINUITY-SEQUENCE tag in m3u8 file of HLS.
(https://datatracker.ietf.org/doc/html/draft-pantos-http-live-streaming-23#section-4.3.3.3)
Does somebody can explain the working way of it?

For example, let's suppose that m3u8 file is made for live streaming like below,
After 2 seconds segment1.060.ts, file.000.ts will be gone from list and #EXT-X-DISCONTINUITY tag too.
after all file.001.ts is going to be first media segment in the list.

At this state, what sequence number should be in #EXT-X-MEDIA-SEQUENCE, #EXT-X-DISCONTINUITY-SEQUENCE?
#EXT-X-DISCONTINUITY should be put in front of file.001.ts line again?

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-MEDIA-SEQUENCE:60
#EXT-X-DISCONTINUITY-SEQUENCE:0
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:2

#EXTINF:0.933600,
segment1.060.ts

#EXT-X-DISCONTINUITY
#EXTINF:0.966911,
file.000.ts

#EXTINF:1.000489,
file.001.ts

Best Answer

The reason why EXT-X-DISCONTINUITY-SEQUENCE must be used for synchronization across variants is explained in the standard:

A client MUST NOT assume that segments with the same Media Sequence Number in different Media Playlists contain matching content

and

A client MUST NOT assume that segments with the same Media Sequence Number in different Variant Streams or Renditions have the same position in the presentation; Playlists MAY have independent Media Sequence Numbers. Instead, a client MUST use the relative position of each segment on the Playlist timeline and its Discontinuity Sequence Number to locate corresponding segments.

Back to your question:

  • EXT-X-DISCONTINUITY marks a discontinuity between two consecutive segments. Your discontinuity is between segment1.060.ts and file.000.ts. There is no discontinuity between file.000.ts and file.001.ts so no need to re-insert the tag
  • each time you remove a EXT-X-DISCONTINUITY from the playlist you must increment the EXT-X-DISCONTINUITY-SEQUENCE
  • each time you remove a segment from the playlist you must increment the EXT-X-MEDIA-SEQUENCE
Related Topic