Create DASH Audio Manifest and Segments with FFmpeg
This article provides a practical guide on using FFmpeg to encode and
package audio files for Dynamic Adaptive Streaming over HTTP (DASH). You
will learn how to generate an XML-based Media Presentation Description
(.mpd) manifest alongside fragmented audio segments,
covering both single-bitrate packaging and multi-bitrate adaptive audio
configurations for video-on-demand (VOD) streaming.
Basic Single-Bitrate DASH Audio Generation
To convert an audio file into DASH segments with a manifest, use
FFmpeg's native dash muxer. The following command encodes
an input audio file to AAC at 128 kbps and packages it into DASH:
ffmpeg -i input.wav -c:a aac -b:a 128k -f dash manifest.mpdBy default, this command generates:
manifest.mpd: The XML manifest file consumed by DASH players (such as Shaka Player or dash.js).init-stream0.m4s: The initialization segment containing codec and track headers.chunk-stream0-00001.m4s,chunk-stream0-00002.m4s, etc.: The individual media segments.
Multi-Bitrate Adaptive Audio Packaging
For true adaptive streaming, you should provide multiple quality levels so the client player can switch bitrates based on available network bandwidth. You can map the same audio stream multiple times to different bitrates within a single FFmpeg execution:
ffmpeg -i input.wav \
-map 0:a -c:a:0 aac -b:a:0 64k \
-map 0:a -c:a:1 aac -b:a:1 128k \
-map 0:a -c:a:2 aac -b:a:2 192k \
-adaptation_sets "id=0,streams=a" \
-f dash manifest.mpdKey Parameters Explained:
-map 0:a: Selects the audio stream from the first input file. Repeating this creates multiple output streams.-b:a:X: Specifies the bitrate for stream indexX.-adaptation_sets "id=0,streams=a": Groups all audio streams into a single DASHAdaptationSet, signaling to players that these streams represent the same content at different qualities.
Customizing Segment Duration and File Templates
For production environments, configuring segment naming patterns and durations is standard practice.
ffmpeg -i input.wav \
-c:a aac -b:a 128k \
-seg_duration 4 \
-use_template 1 \
-use_timeline 1 \
-init_seg_name 'audio_init_$RepresentationID$.m4s' \
-media_seg_name 'audio_chunk_$RepresentationID$_$Number%05d$.m4s' \
-f dash manifest.mpdEssential DASH Flags:
-seg_duration 4: Sets the target duration for each segment to 4 seconds.-use_template 1: Utilizes aSegmentTemplateinside the manifest instead of listing every segment individually, keeping the.mpdfile size small.-use_timeline 1: Adds aSegmentTimelineinside the template to ensure precise segment durations and timestamps, preventing playback drift.-init_seg_name: Defines the pattern for initialization segments.$RepresentationID$dynamically inserts the stream index or bandwidth identifier.-media_seg_name: Defines the pattern for chunk files.$Number%05d$formats the segment number with zero-padding (e.g.,00001).