1

I'd like to know if there is any method to split a PGS format subtitle pulled from a bluray as a .sup file.

2
  • 1
    it's not clear what is your goal. what do u mean by "split subtitles"
    – altarvic
    Aug 26, 2015 at 13:41
  • The sup file I have contains multiple episodes. I wish to split it into multiple sup files, each of which would contain a single episode.
    – pball
    Aug 27, 2015 at 16:41

1 Answer 1

3

Here is the structure of a .sup subtitle file and a link to the splitter I created. Information is either from linked reference or my own research.

The .sup subtitle splitter I created. http://forum.doom9.org/showthread.php?p=1737122

SupRip github page with sup related code. You can read more specifics about each section here that I don't discuss. https://github.com/peterdk/SupRip/blob/master/Bluray%20Sup.txt

The hex 0x50 0x47 are headers for sections in the .sup file, however there are multiple sections per subtitle line. There is always (in my experience) a 0x16, 0x17, 0x14, 0x15, and 0x80 flagged section for displayed subtitles. There can be multiple 0x15 sections if the bitmap data is large. There are also "empty" subtitles which are used to end a subtitle which only have 0x16, 0x17, and 0x80 flags. Subtitles only have a start time and no end time or duration, so a subtitle is ended by the next subtitle starting. So if two subtitle lines are separated by a time period, a blank subtitle section is used to end the first subtitle.

Referencing the linked page these are the flags each header can have.

TIMES = 0x16
SIZE = 0x17
PALETTE = 0x14
BITMAP = 0x15
END = 0x80

Hopefully explaining everything with hex code of a full subtitle should help. I separated each of the sections and truncated the palette and bitmap sections.

Header structure, always 13 bytes long

50 47        start of header
00 01 E3 E0  time code
00 00 00 00  second time code (normally zero)
16           flag
00 13        data size

To get the time code to a usable form take the hex and convert to decimal, then multiple by 100,000 and divide by 9 to get nanoseconds.

0001e3e0 -> 123872 *100,000/9 = 137635555 ns = 1.37635555 sec

start of .sup file
1st subtitle

50 47 00 01 E3 E0 00 00 00 00 16 00 13 07 80 04 38 10 00 02 80 00 00 01 00 00 00 00 05 41 02 6F   Times section of subtitle, gives the start time of the subtitle

50 47 00 01 E3 34 00 00 00 00 17 00 13 02 00 05 41 02 6F 00 81 00 37 01 02 40 03 CB 03 04 00 46   Size section of subtitle

50 47 00 01 CD 04 00 00 00 00 14 01 47 00 00 00 ...       Palette section of subtitle

50 47 00 01 CD 2C 00 00 00 00 15 0C 68 00 00 00 ...      Bitmap section of subtitle

50 47 00 01 CD 2C 00 00 00 00 80 00 00     End section of subtitle, denotes the end of one subtitle

2nd subtitle (actually blank which ends 1st subtitle)

50 47 00 07 E7 80 00 00 00 00 16 00 0B 07 80 04 38 10 00 05 00 00 00 00   Times section of subtitle, gives the start time of the subtitle. Previous subtitle ends when this "subtitle" begins

50 47 00 07 E6 D4 00 00 00 00 17 00 13 02 00 05 41 02 6F 00 81 00 37 01 02 40 03 CB 03 04 00 46   Size section of subtitle

50 47 00 07 E6 D3 00 00 00 00 80 00 00      End section of subtitle, denotes the end of one subtitle
2
  • What is the "size" of a subtitle? the width? height? font size? Why can an empty/blank subtitle have a size?
    – jiggunjer
    Dec 14, 2015 at 2:26
  • If you are are referring to a section with the size flag 0x17. According to the linked reference this section holds position and size information and is either 10 or 19 bytes long. Since pgs subs are bitmap based this size and position should only be for how large and where the bitmap data is displayed on the screen. I do not know why a blank pgs subtitle can have a size. I just know that is how some actual bluray subs have been formatted. The linked reference has more information on what kind of data the sections contain.
    – pball
    Dec 15, 2015 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.