Configure FFmpeg dash_segment_type for fMP4
This article explains how to configure the
dash_segment_type parameter in FFmpeg to output fragmented
MP4 (fMP4) segments for MPEG-DASH streaming. You will learn the exact
command-line syntax, the supported values for this parameter, and a
practical configuration example to ensure your DASH packaging workflow
outputs modern, compatible fMP4 segments.
Understanding the dash_segment_type Parameter
In FFmpeg, the dash muxer is used to package video and
audio into the MPEG-DASH format. By default, FFmpeg determines the
segment container based on the target codecs or default settings, but
you can explicitly control this behavior using the
-dash_segment_type option.
The -dash_segment_type parameter accepts two primary
values: * mp4: Outputs fragmented MP4
(fMP4) segments. This is the industry standard for modern DASH streaming
and offers cross-compatibility with HLS (Common Media Application Format
or CMAF). * webm: Outputs WebM segments,
typically used with VP9 or AV1 video and Opus audio.
To force FFmpeg to output fMP4 segments, you must explicitly set this
parameter to mp4.
FFmpeg Command Example
Below is a standard FFmpeg command that transcodes an input file and
uses the -dash_segment_type parameter to generate fMP4
segments:
ffmpeg -i input.mp4 \
-c:v libx264 -b:v 2000k -g 48 -keyint_min 48 -sc_threshold 0 \
-c:a aac -b:a 128k \
-f dash \
-dash_segment_type mp4 \
-seg_duration 4 \
-init_seg_name 'init-$RepresentationID$.mp4' \
-media_seg_name 'chunk-$RepresentationID$-$Number%05d$.m4s' \
manifest.mpdParameter Breakdown
-f dash: Directs FFmpeg to use the DASH muxer.-dash_segment_type mp4: Explicitly instructs the muxer to package the audio and video tracks into fMP4 segments.-g 48 -keyint_min 48 -sc_threshold 0: Ensures a closed Group of Pictures (GOP) with a constant keyframe interval (every 48 frames). This is crucial for seamless switching between DASH representations.-seg_duration 4: Sets the target duration for each fMP4 segment to 4 seconds.-init_seg_name&-media_seg_name: Defines the naming template for the initialization segments (using the.mp4extension) and the media segments (using the.m4sextension, which is standard for fMP4 media chunks).
By applying -dash_segment_type mp4, FFmpeg will generate
a .mpd (Media Presentation Description) manifest file
alongside .mp4 initialization files and .m4s
data segments, making your content ready for deployment on standard web
servers and CDN delivery.