Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Subtitles

Reply
 
Thread Tools Search this Thread Display Modes
Old 4th September 2015, 02:34   #1  |  Link
pball
Registered User
 
Join Date: Mar 2010
Posts: 18
pball's Bluray PGS Subtitle splitter (.sup file splitter)

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/g2...litter_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

Last edited by pball; 5th June 2016 at 15:06.
pball is offline   Reply With Quote
Old 4th September 2015, 09:13   #2  |  Link
hubblec4
Matroska find' ich toll
 
Join Date: Apr 2008
Posts: 1,370
Thanks, I will test it next days.
hubblec4 is offline   Reply With Quote
Old 14th December 2018, 16:12   #3  |  Link
hatbrox
Registered User
 
Join Date: Jun 2013
Posts: 5
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,
hatbrox is offline   Reply With Quote
Old 15th December 2018, 03:57   #4  |  Link
pball
Registered User
 
Join Date: Mar 2010
Posts: 18
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.
pball is offline   Reply With Quote
Old 19th December 2018, 14:05   #5  |  Link
hatbrox
Registered User
 
Join Date: Jun 2013
Posts: 5
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!
hatbrox is offline   Reply With Quote
Old 4th April 2022, 16:41   #6  |  Link
screamingtrees
Registered User
 
Join Date: Oct 2013
Posts: 14
After splitting sup files, is there a known way to join them back together?
screamingtrees is offline   Reply With Quote
Old 4th April 2022, 18:19   #7  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 100
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.
cubicibo is offline   Reply With Quote
Old 4th April 2022, 19:51   #8  |  Link
screamingtrees
Registered User
 
Join Date: Oct 2013
Posts: 14
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".
screamingtrees is offline   Reply With Quote
Old 4th April 2022, 23:02   #9  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 100
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.
cubicibo is offline   Reply With Quote
Old 5th April 2022, 00:06   #10  |  Link
wswartzendruber
hlg-tools Maintainer
 
wswartzendruber's Avatar
 
Join Date: Feb 2008
Posts: 409
I believe the last display set in an epoch is the "normal case" which removes compositions from the screen?
wswartzendruber is offline   Reply With Quote
Old 5th April 2022, 15:15   #11  |  Link
cubicibo
Registered User
 
Join Date: Feb 2022
Posts: 100
I think so?
Quote:
Originally Posted by screamingtrees View Post
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 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:
Code:
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.
Attached Files
File Type: txt pgshift.txt (5.0 KB, 60 views)

Last edited by cubicibo; 5th April 2022 at 15:33.
cubicibo is offline   Reply With Quote
Reply

Tags
.sup file, pgs subtitle, subtitle splitter, sup file

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:10.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.