Multiplex SRT to TS as DVB Subtitles with FFmpeg
This guide explains how to convert an external SubRip (SRT) subtitle
file into broadcast-standard DVB subtitles (dvbsub) and
multiplex it into an MPEG Transport Stream (MPEG-TS) container using
FFmpeg. Because SRT is text-based and DVB subtitles are graphical
(bitmap-based), FFmpeg must rasterize the text during the multiplexing
process. Below are the exact commands and parameters required to execute
this conversion reliably.
The Basic Conversion Command
To combine an existing video file, its audio, and an external
.srt file into a .ts stream with DVB
subtitles, use the following command:
ffmpeg -i video_input.mp4 -i subtitle_input.srt \
-map 0:v -map 0:a -map 1:s \
-c:v copy \
-c:a copy \
-c:s dvbsub \
-f mpegts output.tsParameter Breakdown
-i video_input.mp4&-i subtitle_input.srt: Defines the source media files. Input0is the multimedia container; input1is the external subtitle file.-map 0:v -map 0:a -map 1:s: Explicitly maps the video and audio streams from the first input and the subtitle stream from the second input. This prevents FFmpeg from dropping the subtitles or selecting undesired tracks.-c:v copy&-c:a copy: Stream-copies both video and audio without re-encoding, preserving original quality and keeping processing time minimal.-c:s dvbsub: Directs FFmpeg to encode the incoming text-based SRT stream into the graphical DVB subtitle format.-f mpegts: Forces the output format to MPEG Transport Stream.
Setting Language and Broadcast Metadata
Broadcast decoders and digital televisions typically require ISO
639-2 three-letter language codes to identify the subtitle stream
properly. You can assign this metadata to the subtitle stream using the
-metadata:s:s flag:
ffmpeg -i video_input.mp4 -i subtitle_input.srt \
-map 0:v:0 -map 0:a:0 -map 1:s:0 \
-c:v copy -c:a copy \
-c:s dvbsub \
-metadata:s:s:0 language=eng \
-f mpegts output.tsIn this example, -metadata:s:s:0 language=eng flags the
first subtitle stream as English.
Advanced Adjustments for DVB Subtitles
Because DVB subtitles are rendered as images, FFmpeg overlays them into a specific canvas size. If the source video has non-standard dimensions, or if you need to control the subtitle appearance, consider the following parameters:
Canvas Size (
-dvb_substream/-canvas_size): If your hardware receiver requires specific frame dimensions for rendering (such as 1920x1080 for HD broadcasts), define the canvas resolution explicitly:-canvas_size 1920x1080Multiple Languages: If you have multiple SRT tracks, map each one and assign unique language tags:
ffmpeg -i input.mp4 -i sub_en.srt -i sub_es.srt \ -map 0:v -map 0:a -map 1:s -map 2:s \ -c:v copy -c:a copy \ -c:s dvbsub -metadata:s:s:0 language=eng \ -c:s dvbsub -metadata:s:s:1 language=spa \ -f mpegts output.ts