How to Enable DASH Segment Timeline in FFmpeg

This article provides a straightforward guide on how to enable segment timeline generation in a DASH (Dynamic Adaptive Streaming over HTTP) manifest using FFmpeg. You will learn the specific command-line flags required to output a Media Presentation Description (.mpd) file containing the <SegmentTimeline> element, which ensures precise playback synchronization and better handling of variable frame rates or non-uniform segment durations.

To enable the segment timeline in your DASH manifest, you must use the -use_timeline option set to 1 (true) in your FFmpeg command. This tells the FFmpeg DASH muxer to generate a <SegmentTimeline> tag inside the <SegmentTemplate> of the output .mpd file.

Example FFmpeg Command

Here is a standard command to transcode an input video and package it into a DASH stream with a segment timeline enabled:

ffmpeg -i input.mp4 \
  -c:v libx264 -b:v 2000k -g 60 -keyint_min 60 -sc_threshold 0 \
  -c:a aac -b:a 128k \
  -f dash \
  -seg_duration 4 \
  -use_template 1 \
  -use_timeline 1 \
  output.mpd

Parameter Breakdown

Why Use Segment Timelines?

By default, FFmpeg may generate a template-based manifest that assumes every segment is of identical duration. However, in real-world encoding, keyframe placement can vary slightly, causing drift between the audio and video streams.

Enabling -use_timeline 1 solves this by: 1. Preventing AV Sync Drift: It provides the player with the exact duration of each segment, allowing for seamless synchronization. 2. Supporting Variable Frame Rates: It handles source files with irregular frame rates where segment boundaries cannot be perfectly uniform. 3. Improving Player Compatibility: Many modern HTML5 players (like Shaka Player and dash.js) perform better and experience fewer buffering issues when a segment timeline is present.