Recursive AI

HLS vs DASH: manifests, segments, and live video

Use HTTP Live Streaming (HLS) for native Apple playback or Dynamic Adaptive Streaming over HTTP (DASH) for players that expect a Media Presentation Description (MPD); both can share Common Media Application Format (CMAF) segments.

OneMedia is a free, open-source .NET library from Recursive AI, licensed under MIT or Apache-2.0. NuGet · GitHub

Install for .NET 10: dotnet add package RecursiveAI.OneMedia --version 1.0.2

Both protocols can share the same fragmented MP4 (fMP4) files in CMAF format; only the manifests differ.

Program.cs.NET 10
using RecursiveAI.OneMedia;
using RecursiveAI.OneMedia.Streaming;
 
var report = Packager.Package("clip.mp4", "out", new PackagingOptions
{
    Formats = PackagingFormats.Both,
    SegmentDuration = new MediaTime(2, 1)
});
foreach (string manifest in report.Manifests)
    Console.WriteLine(manifest);
foreach (var track in report.Tracks)
    Console.WriteLine($"{track.Name}: {track.Segments} segments");
OutputTerminal
video0/index.m3u8
audio0/index.m3u8
master.m3u8
manifest.mpd
video0: 3 segments
audio0: 3 segments

Both manifests reference the same three video and three audio fragments. For example, video0/index.m3u8 lists seg-00001.m4s relative to its directory; manifest.mpd uses a SegmentTemplate (a pattern for video file names) that resolves to the same video0/seg-00001.m4s. Both refer to video0/init.mp4 for video initialization.

Run the program with an H.264/AAC clip.mp4 and a fresh out directory path. The 5-second fixture used here is reproducible with this command.

Generate the test inputShell
ffmpeg -hide_banner -loglevel error -y -f lavfi -i 'testsrc2=size=320x180:rate=25' \
  -f lavfi -i 'sine=frequency=440:sample_rate=48000' -t 5 \
  -c:v libx264 -pix_fmt yuv420p -g 50 -sc_threshold 0 -c:a aac clip.mp4

FFmpeg writes clip.mp4 without terminal output on success. OneMedia doesn’t invoke FFmpeg, change codecs, or create additional encodes. The example has one video rendition; to offer bitrate switching, supply pre-encoded renditions with matching keyframe boundaries and check the packaging report before serving them.

What changes between HLS and DASH?

Where the player starts

FormatEntry point
HLSA text .m3u8 playlist lists the available versions. Each version’s media playlist lists segment URLs. RFC 8216
DASHAn XML .mpd lists the available tracks and quality levels. OneMedia writes a file name pattern and timing for the segments. MPD layout

Which segments to write

FormatSegment choice
HLSUse fragmented MP4 to share files with DASH, or MPEG-TS if your HLS clients require it. HLS segment formats
DASHUse CMAF with OneMedia. Its MPEG-TS mode writes HLS only and reports DASH as dropped if you request both. OneMedia segment formats

Which players to test

FormatPlayback check
HLSTest native playback on Safari or AVPlayer if those are targets. Apple HLS documentation
DASHTest the codecs in your target player. On the web, one option is dash.js.

Both protocols let the player request segments over HTTP and switch between available quality levels. For shared CMAF files, choose codecs, profiles, and a track layout that both sets of clients support, then test both manifests in those clients.

Live vs. on-demand packaging in OneMedia 1.0.2

Video on demand (VOD): The example writes the complete presentation. The HLS media playlists end with EXT-X-ENDLIST, and the MPD has type="static". If you want fewer files, OneMedia’s CMAF single-file mode writes one media.mp4 per track: HLS uses byte ranges and DASH uses SegmentBase with an index range. OneMedia also packages text subtitles in VOD mode. See the packaging mode reference.

Live: Set PackagingOptions.Live to publish completed segments and refresh the manifests as the window advances. The packager accepts one input in live mode, including a forward-only stream. On end of input, it adds HLS’s end marker and makes the DASH MPD static. Single-file mode and subtitle packaging are VOD-only in this release. Live output isn’t the same as live input support: when OneMedia reads a dynamic MPD, it reads the current snapshot without polling for updates. See streaming source limits.

The segment duration is a target, not a timer that can cut anywhere. OneMedia cuts video at the next eligible keyframe at or after the target. If the encoder produces widely spaced keyframes, expect longer segments than requested. For live publishing, check that the new segment is reachable before clients receive the updated playlist or MPD, and test the window and retention with your player. Publishing completed segments does not by itself implement a low-latency mode.

For deployment, test the exact playlist, segments, and target player together. The pinned packaging verification documents playback and packet comparisons, not a completed conformance-validator pass. If you’re deciding whether to re-encode inputs before packaging, see transmuxing versus transcoding.