Live Streaming Basics - devrath/MediaAlchemySuite GitHub Wiki
How HLS (.m3u8) and DASH (.mpd) segment and deliver live video content:
Core Concept: Segmented Streaming
π - Both HLS(Http Live Streaming) and DASH(Dynamic Adaptive Streaming over Http) deliver live(on demand) content.
- They do this by,
- Splitting the Live segment into small chunks(segments) of a few segments.
- Using the manifest to list these segments
- Using the player to adapt the bit-rate dynamically based on network conditions.
HLS (HTTP Live Streaming)
πΊ - Manifest File: .m3u8
- Segment duration is 2-6 seconds.
- Live streaming uses a sliding window playlist by continuously removing old segments & updating new segments available.
- Adaptive bit rate uses the master playlist pointing to multiple variant playlists (different resolution).
#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:123
#EXTINF:6.0,
file123.ts
#EXTINF:6.0,
file124.ts
DASH (MPEG-DASH)
π¦ - Manifest file: .mpd
- XML-based manifest file.
- Live Streaming: Also supports sliding window for live edge control.
- AdaptationSet: Defines tracks for different qualities (bitrate/resolution/codec)
<AdaptationSet mimeType="video/mp4" codecs="avc1.42E01E" bandwidth="500000">
<SegmentTemplate media="video_$Number$.m4s" startNumber="100" duration="2000"/>
</AdaptationSet>
Differences in HLS and DASH
Feature | HLS | DASH |
---|---|---|
Manifest File Extension | .m3u8 | .mpd |
Segment Format | .ts, .aac, .m4s | .m4s |
Live Window Support | β Sliding playlist | β Sliding or timeline-based |
Bitrate Adaptation | Master playlist w/ variants | AdaptationSet in MPD |
DRM Support | FairPlay | Widevine, PlayReady |
Compatibility | Best on Apple devices | Broad cross-platform support |
Segments
What are Segments (Chunks)?
π¦ A live stream is not sent as a single continuous file; instead, they are sent as smaller segments/chunks, usually 2 to 10 seconds long.
Why Use Segments?
π§ - β Efficient delivery: Players can buffer small chunks quickly
- π Adaptive bitrate: Player can switch between lower/higher quality between segments based on network speed.
- π Seek & Rewind: Enables seeking within the live window.
- π§© Caching & CDN: Makes it easier to cache content via CDNs.
Live Streaming with Segment Fetching
ββββββββββββββββββββββββββββββββ
β Live Video Source β
β (e.g., Camera, Encoder) β
ββββββββββββββ¬ββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Segmenter creates small chunks β
β (e.g., 6s .ts/.m4s segments) β
ββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββ
β 2. Manifest (.m3u8 or .mpd) updated β
β β Lists segment URLs β
ββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββ
β 3. Player downloads the manifest β
ββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββ
β 4. Player fetches the latest segment(s) β
β β Chooses bitrate based on bandwidth β
ββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββ
β 5. Buffer + Decode + Display β
ββββββββββββββββββββββββββββββββββββββββββββββ
Example Timeline (Live Window)
π Time ββββββββββββββββββββββββββββββββββββββββββΆ
[Segment 100] [Segment 101] [Segment 102] ...
| 6 sec | 6 sec | 6 sec |
β
Player is here (Live Edge)
- The player continuously polls the manifest to check for new segments.
- The manifest "slides" as new segments are added and old ones expire (live window behavior).
- Adaptive Bitrate is handled by selecting the segment URL from a variant list.
HLS Playlist Types
π¬ Playlist Type | Description | Seekable? | Grows Over Time? | Ends? |
---|---|---|---|---|
VOD | Static, pre-recorded content | β Yes | β No | β Yes |
EVENT | Like a live event with a defined beginning, but no end yet | β Yes (from start) | β Yes | β Eventually |
LIVE | Truly live stream; shows only a sliding window of recent segments | π Only recent | β Yes | β No |
Live vs VOD - Timelines & Seekability
π Feature | VOD (Video on Demand) | Live Streaming |
---|---|---|
Timeline | Fixed, known from start to end | Dynamic, grows as time passes |
Seekability | Full seeking allowed (start β end) | Limited seeking (within live window only) |
Live Window | Not applicable | Sliding window (e.g., last 3β5 mins) |
Start Position | User can start at any point | Usually starts at the live edge or behind by offset |
Duration | Known and static | Unknown, increases continuously |
Use Case | Movies, shows, recorded content | News, sports, events, webinars |
VOD
: Like watching a downloaded movie β you control everything.
Live
: Like tuning into a TV channel β youβre limited to what's being broadcast now, with some ability to rewind if a live window exists.