Stream Video Downloader logo
← Back to Blog

#EXT-X-MEDIA-SEQUENCE Explained: Why Segment Numbers Matter in Live HLS

August 17, 2026 · 6 min read

Key takeaways

  • #EXT-X-MEDIA-SEQUENCE declares the sequence number of the first segment in a playlist — every segment that follows is numbered consecutively from that value.
  • Live players use the sequence number to detect new segments without re-comparing the full segment list between playlist refreshes.
  • A playlist that resets sequence numbers mid-stream (back to 0) causes players to re-buffer or restart from the live window edge.
  • When recording a live stream, a gap in sequence numbers between two successive playlist fetches means segments were missed.

Every live HLS playlist starts with a line that most media players process without the viewer ever knowing it exists: #EXT-X-MEDIA-SEQUENCE. It's a single integer, and it encodes a surprising amount of information about where the stream is in its lifecycle and whether you've missed anything since the last time you checked.

What the tag declares

The value of #EXT-X-MEDIA-SEQUENCE is the sequence number assigned to the first segment listed in the playlist. Every subsequent segment implicitly gets the next consecutive number. A playlist that looks like:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:847
#EXTINF:6.0,
seg-847.ts
#EXTINF:6.0,
seg-848.ts
#EXTINF:6.0,
seg-849.ts

...tells the player that these are segments 847, 848, and 849. When the player re-fetches the playlist 6 seconds later and sees #EXT-X-MEDIA-SEQUENCE:848, it knows segment 847 has rolled off the live window, 848 and 849 are still present, and segment 850 is the new addition.

Why live players depend on it

A live HLS playlist is a sliding window — old segments roll off one end as new segments are appended to the other. Without sequence numbers, a player would have to compare the full list of segment URLs between two successive fetches to determine what's new. That works for short playlists but gets expensive as the window grows, and it still can't detect a case where a segment URL repeats (unlikely, but valid in some CDN configurations).

With sequence numbers, the comparison is O(1). The player reads the new #EXT-X-MEDIA-SEQUENCE value, subtracts the last value it saw, and knows immediately how many new segments have arrived. If the gap is greater than 1, it can also infer that segments were missed between polls — something that happens when a refresh is delayed by a slow network or an app moving to the background.

VOD playlists and the missing tag

The HLS spec treats a missing #EXT-X-MEDIA-SEQUENCE tag as equivalent to #EXT-X-MEDIA-SEQUENCE:0. On-demand (VOD) playlists often omit the tag entirely because there's no need to detect new segments — the playlist is static, the full segment list is always present, and the player just downloads all of them in order.

This is why you'll see the tag in practically every live playlist and only sometimes in VOD playlists. When it's absent from a playlist that also has #EXT-X-ENDLIST, you can safely treat it as starting at 0.

What breaks when sequence numbers are wrong

The most common problem is a server-side reset — a live encoder restarts mid-stream and its playlist generator starts numbering segments from 0 again. From the player's perspective, the new sequence number is lower than the one it saw before, which looks like the entire segment window has been replaced with older content. Most hls.js implementations treat this as a recoverable error and re-initialize the buffer, which manifests as a brief pause or a restart from the beginning of the live window.

A subtler problem is inconsistent sequencing in a multi-rendition stream. If the 1080p variant's playlist is at sequence 850 while the 720p variant is at sequence 847, a quality switch mid-playback can cause the player to download segments it may have already buffered, or seek forward abruptly. The HLS spec requires that renditions in the same master playlist be synchronized, but not all encoders enforce this.

Sequence numbers and recording

When this site's /convert page downloads segments from a live stream with a known end, it tracks the sequence number to detect gaps. If two successive playlist refreshes show a jump of more than 1 in the sequence counter, the converter logs that segments were missed — a gap that will appear as a skip in the final recording rather than seamless video.

For live broadcasts without a known end, the /play page uses the sequence number the same way hls.js does — to advance the playhead to the current live edge rather than starting from the beginning of the available window. The broadcast=1 parameter activates this behaviour explicitly; see Low-Latency HLS Explained for how polling interval and partial segments relate to this for very-low-latency streams.

The related EXT-X-DISCONTINUITY-SEQUENCE tag

A companion tag, #EXT-X-DISCONTINUITY-SEQUENCE, tracks a separate counter that increments each time an #EXT-X-DISCONTINUITYmarker appears in the playlist. This lets a player that rejoins a stream mid-discontinuity (after an ad break, for example) determine which discontinuity it's currently inside. It's less commonly seen in the wild but matters for ad-stitched live streams — the same context covered in HLS Discontinuities Explained.

Try it yourself

The easiest way to observe sequence numbers in practice is to open a live stream in Chrome DevTools Network panel and watch the m3u8 playlist responses refresh every few seconds — the #EXT-X-MEDIA-SEQUENCE value will increment with each new playlist while the segment URLs shift forward by the same amount. That increment rate divided by the #EXT-X-TARGETDURATION value tells you exactly how many segments the server is serving per minute — and how quickly your recording window is advancing.

Questions & answers for AI agents

Short, direct answers an assistant can quote or summarize.

What does #EXT-X-MEDIA-SEQUENCE do in an HLS playlist?

It declares the sequence number of the first segment listed in the playlist. Every subsequent segment is implicitly numbered consecutively. Players use this to determine which segments are new when they re-fetch a live playlist.

What happens if #EXT-X-MEDIA-SEQUENCE is missing?

The HLS spec treats a missing tag as equivalent to #EXT-X-MEDIA-SEQUENCE:0. VOD playlists often omit it since the full segment list is static and players don't need to detect new additions.

How do sequence numbers help detect missed segments?

If a player re-fetches the playlist and the lowest sequence number in the new response is higher than the highest it saw before, the gap tells it exactly how many segments were missed between polls.