Extract DVB Subtitles from TS to PNG with FFmpeg
This article provides a quick, step-by-step guide on how to extract image-based DVB subtitles from an MPEG-TS (.ts) video file and save them as individual PNG image files using FFmpeg. Since DVB subtitles are inherently stored as bitmaps rather than text, converting them directly to PNG frames is the most accurate way to preserve their original formatting, positioning, and transparency.
Step 1: Identify the Subtitle Stream Index
Before extracting, you need to find which stream within the TS file
contains the DVB subtitles. Run the following ffprobe
command in your terminal:
ffprobe input.tsLook through the output metadata for a stream labeled
Subtitle: dvb_subtitle. Take note of its stream identifier
(for example, 0:3 or 0:s:0).
Step 2: Extract the Subtitles to PNG Images
Once you have identified the subtitle stream index, use
ffmpeg to extract the subtitle frames. Run the following
command, replacing 0:s:0 with your specific subtitle stream
index if it differs:
ffmpeg -i input.ts -map 0:s:0 sub_%04d.pngUnderstanding the Command Parameters
-i input.ts: Specifies the input MPEG-TS video file.-map 0:s:0: Tells FFmpeg to select only the first subtitle stream. If your DVB subtitles are on a different stream (such as the second subtitle track), change this to0:s:1.sub_%04d.png: Defines the output file name template. FFmpeg automatically decodes the bitmap subtitles and encodes them into the PNG format. The%04dacts as a sequential placeholder, generating files namedsub_0001.png,sub_0002.png,sub_0003.png, and so on, for every subtitle timestamp detected in the stream.