How to Create DASH Video Streams Using FFmpeg

This guide provides a straightforward tutorial on how to use the FFmpeg command-line tool to generate Dynamic Adaptive Streaming over HTTP (DASH) manifests and video segments. You will learn how to package a single video file or encode multiple adaptive bitrates, configure segment durations, and output the required .mpd playlist file alongside its corresponding media fragments for seamless web playback.


Basic Single-Bitrate DASH Creation

To quickly convert a standard video file into a DASH-compliant stream, you can use FFmpeg’s built-in dash muxer. The basic command takes an input video, transcodes it (or copies the codecs), and outputs the media segments along with the XML-based Media Presentation Description (.mpd) manifest.

Run the following command in your terminal:

ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f dash output.mpd

Key Parameters Explained:


Multi-Bitrate Adaptive DASH Encoding

For true adaptive streaming, you must provide multiple resolutions and bitrates (representations). This allows the video player to dynamically switch streams depending on the user’s internet speed.

To ensure seamless transitions between qualities, you must enforce a strict keyframe interval (GOP size) that aligns with your segment duration.

ffmpeg -i input.mp4 \
  -map 0:v -map 0:a -map 0:v -map 0:a \
  -b:v:0 800k -s:v:0 640x360 -profile:v:0 baseline \
  -b:v:1 2400k -s:v:1 1280x720 -profile:v:1 main \
  -b:a:0 96k -b:a:1 128k \
  -keyint_min 48 -g 48 -sc_threshold 0 \
  -f dash \
  -seg_duration 4 \
  -use_template 1 \
  -use_timeline 1 \
  -init_seg_name 'init-stream$RepresentationID$.m4s' \
  -media_seg_name 'chunk-stream$RepresentationID$-$Number%05d$.m4s' \
  manifest.mpd

Critical Flags for Multi-Bitrate Encoding:


Deploying Your DASH Stream

Once the FFmpeg process completes, you will have a directory containing: 1. manifest.mpd: The master XML manifest file. 2. init-stream...m4s: Header initialization files for each quality representation. 3. chunk-stream...m4s: Hundreds or thousands of small, sequential media segments.

To stream this content to users, upload all of these generated files to any standard web server or Cloud storage bucket (such as Apache, Nginx, or AWS S3). Ensure that your web server is configured to allow Cross-Origin Resource Sharing (CORS) so that players like Dash.js or Shaka Player can fetch the assets from your domain.