Answers.Body: <p>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.</p>
  
  <p>The .sup subtitle splitter I created. <a href="http://forum.doom9.org/showthread.php?p=1737122" rel="nofollow">http://forum.doom9.org/showthread.php?p=1737122</a></p>
  
  <p>SupRip github page with sup related code. You can read more specifics about each section here that I don't discuss.
  <a href="https://github.com/peterdk/SupRip/blob/master/Bluray%20Sup.txt" rel="nofollow">https://github.com/peterdk/SupRip/blob/master/Bluray%20Sup.txt</a></p>
  
  <p>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.</p>
  
  <p>Referencing the linked page these are the flags each header can have.</p>
  
  <pre><code>TIMES = 0x16
  SIZE = 0x17
  PALETTE = 0x14
  BITMAP = 0x15
  END = 0x80
  </code></pre>
  
  <p>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.</p>
  
  <p>Header structure, always 13 bytes long</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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.</p>
  
  <p>0001e3e0 -> 123872 *100,000/9 = 137635555 ns = 1.37635555 sec</p>
  
  <pre><code>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
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-14T02:26:26.550Z
Answers.Text: What is the "size" of a subtitle? the width? height? font size? Why can an empty/blank subtitle have a size?
Answers.UserDisplayName: jiggunjer
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-15T03:06:21.060Z
Answers.Text: 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.
Answers.UserDisplayName: pball
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-13T16:03:55.703Z
Answers.LastActivityDate: 2015-12-13T16:03:55.703Z
Answers.UserDisplayName: pball
Body: <p>I'd like to know if there is any method to split a PGS format subtitle pulled from a bluray as a .sup file.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-26T13:41:32.043Z
Comments.Text: it's not clear what is your goal. what do u mean by "split subtitles"
Comments.UserDisplayName: altarvic
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-27T16:41:28.760Z
Comments.Text: 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.
Comments.UserDisplayName: pball
Tags: <subtitles>
Title: Split PGS subtitles (.sup file)
UserDisplayName: pball
ThreadText: # Split PGS subtitles (.sup file)
  
  (Asked by: username_0 on 2015-08-25)
  
  I'd like to know if there is any method to split a PGS format subtitle pulled from a bluray as a .sup file.
  
  **Tags:** subtitles
  
  > **Comments:**
  > **username_1**: it's not clear what is your goal. what do u mean by "split subtitles"  
  > **username_0**: 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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-12-13. Score: 3 | Accepted answer
  
  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
  
  ```
  
  > **Comments:**
  > **username_2**: What is the "size" of a subtitle? the width? height? font size? Why can an empty/blank subtitle have a size?  
  > **username_0**: 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.  
  
  ---
  
  