Introduction
Blu-ray discs store subtitles as pictures, not text, in a format called PGS
(Presentation Graphic Stream). When the subtitle track is extracted from a disc or an
MKV file, it is saved as a .sup file. Each subtitle is a run-length
encoded bitmap with a colour palette, placed at a position on screen.
Because the subtitles are images, they cannot be edited or restyled as text. Tools such as Subtitle Edit use optical character recognition to turn them into SRT.
Structure
A SUP file is a series of segments. Each starts with a 13-byte header: the magic bytes
PG (50 47), a 32-bit presentation timestamp and a 32-bit
decoding timestamp on a 90 kHz clock, a segment type byte and a 16-bit size. All
numbers are big-endian.
The segment types, in hexadecimal, are 16, the presentation composition, which says what to
show and when; 17, the window definition; 14, a palette;
15, an object holding the run-length encoded bitmap; and
80, the end of a display set. A display set, from a composition segment to
an end segment, puts one subtitle on screen or clears it.
0MagicPG2 bytes2Presentation timestamp4 bytes6Decoding timestamp4 bytes10Segment type14to17or801 byte11Segment size2 bytes13Segment datavaries
Links
Software
- Subtitle Edit, which converts PGS to text by OCR (Windows, Linux)
- MKVToolNix, which adds and extracts PGS tracks (Windows, macOS, Linux)
- VLC media player (Windows, macOS, Linux, mobile)
- mpv (Windows, macOS, Linux)
- FFmpeg (Windows, macOS, Linux)
- BDSup2Sub, which converts and resizes PGS and VobSub subtitles
Developers
- libavcodec, C, FFmpeg’s codec library, which decodes PGS