View Full Version : pball's Bluray PGS Subtitle splitter (.sup file splitter)
pball
4th September 2015, 02:34
I was annoyed by the severe lack of tools for splitting PGS subtitles (.sup files). So I created a simple program to split bluray subtitles.
Please report any issues with my program. I've tested it pretty thoroughly but I only have so many subtitles to split. I'm also open to suggestions and feature requests.
Download:
http://www.mediafire.com/download/g2n4qxa0d6wkut7/supsplitter_1.1.zip
Usage:
Syntax: supsplitter input:<input filename> <options> output:<output filename>
output filename will have _1, _2, ... appended to filename if multiple splits are made
Options:
ms:ms-ms<;ms-ms;...> Millisecond times for start and end of output sub file
frames:frame-frame<;frame-frame;...> Frames for start and end of output sub file, starts at 0, requires fps parameter
fps:fps Frames per second of subtitle's video, required when using frames parameter.
Known limitations:
Program will not split a subtitle line between two files. I personally don't see why someone would split a video in the middle of a subtitle being displayed.
To do list:
Update program to properly split subtitle line between two files. (it was requested)
Clean up code and make any improvements possible
Release source code after previous item, it's python currently.
Port to C# to get a smaller exe and just because.
Graphical interface?
Version:
1.1 Fixed error in error message (ironic isn't it)
1.0 Initial release
hubblec4
4th September 2015, 09:13
Thanks, I will test it next days.
hatbrox
14th December 2018, 16:12
Hello,
I would like to use that programme to split a PGS sup file into 4 separate sup file. Each separate file represents an individual TV episode.
the video Frame rate is: 23.976
after watching the bluray and looking at the SUP file with "bdsup2sub" I determined the following split requirements:
Episode 1:
1st subtitle line number: 1
1st subtitle start time: 00:00:01.460
1st subtitle end time: 00:00:04.046
Last subtitle line number: 556
Last subtitle start time: 00:53:29.915
Last subtitle end time: 00:53:31.500
Episode 2:
1st subtitle line number: 557
1st subtitle start time: 00:55:07.805
1st subtitle end time: 00:55:10.891
Last subtitle line number: 1102
Last subtitle start time: 01:52:35.082
Last subtitle end time: 01:52:37.584
Episode 3:
1st subtitle Index number: 1103
1st subtitle start time: 01:54:59.976
1st subtitle end time: 01:55:02.479
Last subtitle Index number: 1653
Last subtitle start time: 02:49:30.327
Last subtitle end time: 02:49:32.829
Episode 4:
1st subtitle Index number: 1654
1st subtitle start time: 02:52:03.814
1st subtitle end time: 02:52:06.900
Last subtitle Index number: 2135
Last subtitle start time: 03:49:09.236
Last subtitle end time: 03:49:10.904
But I don't know how to put the above into the command line parameters.
could you help me out?
cheers,
pball
15th December 2018, 03:57
Well I personally use the frames and fps options, but I played with the millisecond option some to refresh myself. The times you have will not work, you will need the times that the video of each episode starts and stops, otherwise the subtitles will not sync to the video. So episode 1 should start at 0sec and lets say it ends at 54min 25.400sec and episode two starts at 54min 25.401sec and ends at 1h 53min 22.000sec. The below command should work.
supsplitter.exe input:"c:\encoding\subtitle ep 1-3.sup" output:"c:\encoding\subtitle ep 1.sup" ms:0-3265400;3265401-6802000
This will create "subtitle ep 1_1.sup" and "subtitle ep 1_2.sup" since multiple times were given in one command. You could also run the program multiple times with a different output names and ms numbers for each episode.
ep 1 start = 0ms
ep 1 end 54min 25.400sec = 3265.400sec = 3265400ms
ep 2 start just add 1ms to get 3265401ms
ep 2 end 1h 53min 22.000sec = 6802.000sec = 6802000ms
I hope this helps, let me know if you need more help.
hatbrox
19th December 2018, 14:05
Hi,
this works perfectly
I found it easier to sync the English subs with BD2SUP by comparing the 1st subtitle with another subtitle in another language
Many thanks!
screamingtrees
4th April 2022, 16:41
After splitting sup files, is there a known way to join them back together?
cubicibo
4th April 2022, 18:19
If they are split correctly, that is:
before_split.sup ends with an ENDSegment
after_split.sup starts with an Epoch start PCS segment
then you can try to merge them back together using a Hex Editing tool. Just create a new file, paste the content of the two files one after the other without deleting or replacing any bytes. That will create a gap in the object counter but AFAIK players don't care if it is incremented linearly or not.
screamingtrees
4th April 2022, 19:51
Thanks for the reply. I tried this using a "copy sub1.sup+sub2.sup output.sup" command, but it seems like it's not going to work for my purposes. I can't seem to get a "blank" sup segment to keep it's duration when rejoining. Basically I'm splitting out the opening/endings of an anime, removing the subs, and trying to rejoin, but the subs that come after the opening just immediately show up without waiting for the opening theme to play out first. I tried using BDSup2Sub for this, but it caused other problems with my subtitles like shortening some it deemed as "errors".
cubicibo
4th April 2022, 23:02
There is no such thing as duration in PGS. Each caption has a presentation (decode) timestamp and remain on screen until a new presentation empties the graphics plane.
So, if you take the SUP from a given video, slice out (properly) a portion of the raw data then mux it back to the same untouched, video stream, the removed portion will either:
• Display the last shown subtitle (missing plane clear segment)
• Show nothing (the desired behaviour, properly sliced)
I don't know how you generated your two files but it sounds like sub2.sup has modified timestamps in the stream.
wswartzendruber
5th April 2022, 00:06
I believe the last display set in an epoch is the "normal case" which removes compositions from the screen?
cubicibo
5th April 2022, 15:15
I think so?
Thanks for the reply. I tried this using a "copy sub1.sup+sub2.sup output.sup" command, but it seems like it's not going to work for my purposes. I can't seem to get a "blank" sup segment to keep it's duration when rejoining.
Assuming the timing were resets by the splitting tool, try this very elementary python script (https://textup.fr/621455jz) which will move all timestamps of sub2.sup to a value of your calculation (probably equal to duration of part1 + duration of subtitle-sliced sequence).
Usage: python3 pgshift.py input.sup MS output.sup [-dts]
Where:
MS is the shift delay in MILLISECONDS to add or subtract. It must be an integer.
-dts, if provided, also shifts the decoding timestamps
I have seen a few streams which sets PTS = DTS at all time. In general you don't need to specify the optional -dts argument (and in fact it should not matter).
When done, concatenate the two files and hopefully the subtitles appears now properly.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.