Configure FFmpeg DASH Muxer for WebVTT Subtitles

This guide explains how to configure FFmpeg's DASH muxer to output WebVTT subtitles alongside your video and audio streams. You will learn the exact command-line arguments needed to map your subtitle files, convert them to the WebVTT format, and package them into a Dynamic Adaptive Streaming over HTTP (DASH) presentation with a properly formatted Media Presentation Description (MPD) manifest.

The Basic Command Structure

To output WebVTT subtitles in a DASH stream, you must input your video, audio, and subtitle files, map the streams, and set the subtitle codec to webvtt while targeting the dash format.

Here is the standard command:

ffmpeg -i video.mp4 -i subtitles.srt \
  -map 0:v:0 -map 0:a:0 -map 1:s:0 \
  -c:v copy -c:a copy \
  -c:s webvtt \
  -f dash output.mpd

Parameter Breakdown

  • -i video.mp4 & -i subtitles.srt: These flag your inputs. The video is stream 0 and the subtitle file is stream 1.
  • -map 0:v:0 -map 0:a:0: Maps the first video and audio streams from the first input.
  • -map 1:s:0: Maps the first subtitle stream from the second input.
  • -c:v copy -c:a copy: Copies the video and audio streams without re-encoding them, saving processing time.
  • -c:s webvtt: This is the critical option. It converts the input subtitle (even if it is SRT or ASS) into the WebVTT format required for DASH.
  • -f dash: Forces the output format to be DASH, which generates the .mpd manifest and the corresponding media segments.

Configuring Subtitle Metadata (Language and Roles)

To ensure video players recognize the language of your subtitles and display them correctly, you should configure metadata. You can define the language and the role of the subtitle track using metadata flags.

ffmpeg -i video.mp4 -i subtitles_en.srt \
  -map 0:v:0 -map 0:a:0 -map 1:s:0 \
  -c:v copy -c:a copy -c:s webvtt \
  -metadata:s:s:0 language=eng \
  -metadata:s:s:0 role=subtitle \
  -f dash output.mpd
  • -metadata:s:s:0 language=eng: Sets the language code (ISO 639-2) for the first subtitle stream to English. This is written into the <AdaptationSet> tag of the MPD file.
  • -metadata:s:s:0 role=subtitle: Defines the role of the track (e.g., subtitle, caption, description).

Handling Multiple Subtitle Languages

If you need to package multiple subtitle languages into your DASH stream, map each subtitle input and assign the appropriate codec and metadata sequentially.

ffmpeg -i video.mp4 -i subtitles_en.srt -i subtitles_es.srt \
  -map 0:v:0 -map 0:a:0 -map 1:s:0 -map 2:s:0 \
  -c:v copy -c:a copy \
  -c:s webvtt \
  -metadata:s:s:0 language=eng \
  -metadata:s:s:1 language=spa \
  -f dash output.mpd

In this command:

  • -map 1:s:0 targets the English file and is assigned index s:s:0 (first subtitle stream).
  • -map 2:s:0 targets the Spanish file and is assigned index s:s:1 (second subtitle stream).
  • -c:s webvtt applies the WebVTT encoder to all mapped subtitle streams.