How to Set DASH Update Period and Buffer Depth in FFmpeg
This article provides a straightforward guide on how to configure the
minimum update period (@minimumUpdatePeriod) and the time
shift buffer depth (@timeShiftBufferDepth) in a DASH
(Dynamic Adaptive Streaming over HTTP) manifest using FFmpeg. You will
learn the specific command-line options required to control these
parameters, which are essential for optimizing live streaming latency
and enabling DVR-like playback controls for your viewers.
When packaging a live stream using FFmpeg’s DASH muxer
(-f dash), you can control how players interact with your
live manifest (MPD) by modifying the update frequency and the size of
the sliding playback window.
To configure these settings, FFmpeg provides two specific private
muxer options: -min_update_period and
-time_shift_buffer_depth. Both of these options expect
values defined in microseconds (where 1 second =
1,000,000 microseconds).
Key Parameters Explained
-min_update_period <microseconds>
This maps to the@minimumUpdatePeriodattribute in the MPD file. It tells the media player how often (at a minimum) it should fetch the updated manifest file to discover new segments.- Example: To set an update period of 5 seconds, use
5000000.
- Example: To set an update period of 5 seconds, use
-time_shift_buffer_depth <microseconds>
This maps to the@timeShiftBufferDepthattribute. It defines the duration of the sliding window of media segments that remain available for playback. This allows viewers to seek backward (DVR functionality) during a live stream.- Example: To allow viewers to rewind up to 60 seconds, use
60000000.
- Example: To allow viewers to rewind up to 60 seconds, use
FFmpeg Command Example
Below is a practical FFmpeg command demonstrating how to apply these settings during a live DASH encoding process:
ffmpeg -re -i input.mp4 \
-c:v libx264 -b:v 3000k -g 60 -keyint_min 60 -sc_threshold 0 \
-c:a aac -b:a 128k \
-f dash \
-seg_duration 2 \
-min_update_period 5000000 \
-time_shift_buffer_depth 60000000 \
-use_timeline 1 \
-use_template 1 \
-window_size 30 \
manifest.mpdCommand Breakdown
-f dash: Specifies the output format as DASH.-seg_duration 2: Sets the target segment duration to 2 seconds.-min_update_period 5000000: Configures the player to refresh the manifest every 5 seconds.-time_shift_buffer_depth 60000000: Keeps 60 seconds of past segments playable in the player’s buffer.-window_size 30: Keeps a maximum of 30 segments in the manifest file itself. Combined with 2-second segments, this matches the 60-second time shift buffer depth.-use_timeline 1: Enables segment timelines to ensure accurate synchronization.