View Full Version : BDSup2Sub - convert and tweak bitmap subtitle streams (VobSub,BD-SUP,BDN XML,HD-SUP)
0xdeadbeef
26th February 2009, 00:39
http://javaforge.com/displayDocument/icon_128.png?doc_id=76805
BDSup2Sub is a tool I wrote initially to convert captions demuxed from a Blu-Ray transport stream (M2TS) into the DVD VobSub format (SUB/IDX) used by many DVD authoring tools - hence the name. Many more features were added over time as was support for other formats. So in the meantime the name seems a little inappropriate. In a nutshell, it's a subtitle conversion tool (for image based formats) with scaling capabilities and some other nice features.
Feedback is welcome - especially from the authors of other tools to discuss compatibility issues.
To report problems with a subtitle stream, please either post the zipped stream (if it is compliant with the forum rules) or upload it to a "one click hoster" and send me a PM with the link. And don't forget a detailed error description.
Supported Formats
Blu-Ray SUP: Import (since 1.0) and Export (since 1.6)
Sony BDN XML: Import and Export (since 3.3.0)
HD-DVD SUP: Import (since 1.9)
VobSub (SUB/IDX): Import (since 3.5.0) and Export (since 1.0)
DVD-SUP (SUP/IFO): import and export (since 3.9.0)
Features
add a fixed delay to all timestamps (since 1.0)
perform a frame rate conversion e.g. for pal speedup (since 1.0)
synchronize time stamps to output frame rate (since 2.0)
edit times and position of each caption (since 2.3)
control all features (except editing) from the command line (since 1.7)
move all captions inside or outside a given area (since 2.7) or horizontally (since 3.9.6)
scale up/down with a variety of filters (from bilinear over bicubic to Lanczos3 and Mitchell) (since 3.4.0)
edit "forced" flags (since 3.6.0)
exclude single captions from export (since 3.6.0)
erase rectangular regions of a caption (since 3.6.0)
scale captions independently of screen size (since 3.7.0)
automatically remove fade in/out from imported subtitle streams
export the target palette in PGCEdit text format (RGB values 0..255) (since 3.9.0)
edit the imported DVD palette when input is either VobSub or SUP/IFO (since 3.9.1)
edit the frame palette and alpha values when input is either VobSub or SUP/IFO (since 3.9.3)
set/clear forced flags for all captions (since 3.9.9)
Documentation
The complete documentation is available from the help menu inside the application. You can also read it online (http://bdsup2sub.javaforge.com/help.htm).
Download
Current version: 4.0.0 (14.12.2009)
http://www.sendspace.com/file/j3df4s
Previous versions:
3.9.9:http://www.sendspace.com/file/4mcnk5
3.9.8:http://www.sendspace.com/file/epw7ng
3.9.7:http://www.sendspace.com/file/k8lcmo
3.9.6:http://www.sendspace.com/file/w5tfal
The download is a JAR archive that needs an installed Java runtime (Java 6 JRE) to run. You can get it from Sun's website:
http://java.sun.com/javase/downloads/index.jsp (e.g. JRE 6 Update 13)
A complete revision history (http://bdsup2sub.javaforge.com/help.htm#Change_History) can be found at the end of the online help.
Usage
With the Java runtime installed, the JAR can be started by double clicking on it. Alternatively, you can start it from the command line via:
java -jar BDSup2Sub.jar
or in Windows if you don't want a open CMD box:
javaw -jar BDSup2Sub.jar
Have fun.
Screenshots
Main screen (source in upper part, target in lower part)
http://javaforge.com/displayDocument/scrn_main.png?doc_id=76807
Conversion dialog with the basic conversion options
http://javaforge.com/displayDocument/scrn_conv.png?doc_id=76804
Edit dialog
http://javaforge.com/displayDocument/scrn_edit.png?doc_id=76808
Move dialog
http://javaforge.com/displayDocument/scrn_move.png?doc_id=76806
BigCondor
26th February 2009, 05:04
Thanks very much for your effort and sharing.
I have tried to convert two sups with your program and it works. I noticed that the results of idx+sub will vary with the size of the original sup (font size of the original).
The first one in the figure is very nice.
The second one, which engages smaller font, the edges are not all correctly marked.(upper image taken from suprip, lower one from .son file)
Selur
26th February 2009, 15:27
any plans to open the source of the tool?
0xdeadbeef
26th February 2009, 17:18
I noticed that the results of idx+sub will vary with the size of the original sup (font size of the original).
Well, of course they do. The smaller the input picture, the smaller the output picture. For OCR purposes, the best choice would be the original picture from the Blu-Ray SUP. Therefore it doesn't make much sense to use the converted low-res picture for OCR. Besides, the subsampling used for antialiasing also contradicts the idea of OCR in a way.
any plans to open the source of the tool?
Not in the sense of a real open source software since it would be a major effort to clean up the sources to a state that they were worth to be publicly released. Then again, as always with my software, if someone kindly asks for the sourcecode, I will share it of course. Just be warned: the sources are quite a mess currently.
Adub
26th February 2009, 19:11
Well, of course they do. The smaller the input picture, the smaller the output picture. For OCR purposes, the best choice would be the original picture from the Blu-Ray SUP. Therefore it doesn't make much sense to use the converted low-res picture for OCR. Besides, the subsampling used for antialiasing also contradicts the idea of OCR in a way.
Yes, but unfortunately, there doesn't exist a "perfect" solution yet for OCRing blu-ray subtitles. Suprip is pretty good, but suffers from a few major bugs here and there.
0xdeadbeef
26th February 2009, 20:30
Well I sure don't intend to add OCR to SupToSub, so all I could offer would be an export to an easy to implement format. E.g. a bunch of GIFs plus a text file similar to the IDX of VobSub. Then maybe someone could set up a scripting tools to convert this to SRT or whatever.
0xdeadbeef
27th February 2009, 01:10
A little update:
26/02/2009 1.0 -> 1.1
-Added progress dialog for import
-Added check for existing target files and write protection
-Added detection of forced subtitles and the possibility to export only forced subs
-Removed some checks from RLE decoding to support some non-standard frames which write to the next line without EOL
-Fixed two small bugs in run length decoding (fixes reading exports from SupRead)
-Support for multi-packet pictures (well, exactly two packets are supported for the moment)
I edited the first posting...
Sorry, another micro update to 1.1b (not visible in GUI) since there was another bug with multi-packet support for SUPs. This should really work for all two-packet SUPs. I'll add unlimited packet support later though no SUP stream seems to use it.
shon3i
27th February 2009, 08:20
Do you think about reverse process? DVD->BluRay?
0xdeadbeef
27th February 2009, 12:27
Not really. Would this make sense?
SquallMX
27th February 2009, 18:34
Not really. Would this make sense?
Yes:), some Bluray titles don't have subtitles that the DVD versión does have, and sometimes de DVD version is better placed or have better font (Warner BR subtitles are placed in the black bars if the movie is 2.35, some of us hate that, and right now there's no way to change the position, the DVD subtitles can be placed inside the 2.35 image itself).
Another petition, an option to resize BR subs from 1080p to 720p, currently it's not possible to have BD5 at 720 with subtitles because no program exist that converts the subs from 1080p to 720p.
:thanks:
woah!
28th February 2009, 02:24
1080 to 720 resizing would be very cool if possible, otherwise it works very well thx :)
0xdeadbeef
1st March 2009, 16:23
The resizing to 720p itself, although a little different compared to the approach used for VobSub, would be easy to implement. Then again, I don't have any SUP writing functionality yet (as well as SUB/IDX Reading). While one might think that it should be easy to implement a writer when you already know the format to implement a reader, the problem is that I can skip a lot of unknown stuff when reading, but have to write it when writing.
Chances are that with all the guessing about these unknown fields I have to do, the written SUP file creates all kind of problems when used with different players.
woah!
2nd March 2009, 01:42
for me it was just that my WD TV HD Media Player plays MKV/SUB/IDX and i encode my blurays down to 720p MKV's for storage on it. i use subrip right now to ocr to srt and this app would save those steps thats all :)
either way your app does a great job thx ..
edit: actually they look pretty good as they are on my tv playing on the WD player :) so thats very cool and saves me alot of work thx :)
0xdeadbeef
2nd March 2009, 02:18
Hm, my only option would be to export 720p SUPs since SUB/IDX doesn't officially support 720p (and I would be surprised if any player could handle it). Then again, I would be surprised to hear that MKV streams can contain SUPs.
So the 720p SUP would only make sense for the use case that SquallMX suggested (converting a 1080p BD to 720p BD5 to save space).
SquallMX
2nd March 2009, 05:47
Hi, i found a little bug, the program crash when i load this Sup file (From Matrix R1 Bluray):
http://rapidshare.com/files/204262182/00005.track_4609.sup
:helpful:
0xdeadbeef
2nd March 2009, 17:54
Hm, this seems to be from an NTSC stream? The screen size is 720x480, therefore the "downsizing" to PAL (which is the default target resolution) fails with a division by zero.
I'm thinking of a workaround - yet this is not really a planned scenario.
0xdeadbeef
2nd March 2009, 20:14
A little update (edited the first post for download)
02.03.2009 1.1 -> 1.2
Reworked SUP multipacket parsing to support unlimited packets (kinda untested though for > 2 packets).
Fixed bug in detection of primary color & luminance thresholds.
Added workaround to prevent crash when loading SUPs in NTSC/PAL resolution.
Note that "upscaling" NTSC to PAL will not change the size of the bitmap, only the offsets.
Also downsizing from PAL to NTSC might fail - I'll have to reconsider this issue later.
Info was not updated when switching output format
Added fixed line feed after even and off RLE buffer since VobSub sometimes skipped the last line
~bT~
3rd March 2009, 03:12
request: is it possible to remember last folder?
also i noticed after loading the above file for matrix, it says, source fps 23.976 dest fps 25?
is that correct? and yes, that was using the latest version.
0xdeadbeef
3rd March 2009, 12:18
While the program is running, it remembers the last folder. However, it doesn't save any ini file yet. This is on my list however.
Regarding the SRC/TRG frame rates: AFAIK the SUP file doesn't contain any info about the frame rate. Therefore, if you want to convert the frame rate, you have to select the source and target frame rates manually. The 23.976 as source and 25fps as target is just the default setting as this is my typical scenario (PAL speedup from 24p). Indeed the source and target frame rates are only used to calculate a speedup/slowdown factor that's used to manipulate the time stamps.
~bT~
3rd March 2009, 16:13
^ sorry. my bad. it was late last night when i posted that and didn't realise the option above which u must tick to enable changing.
saint-francis
3rd March 2009, 17:45
Therefore, if you want to convert the frame rate, you have to select the source and target frame rates manually.
How is this done? I see no option to specify frame rate. Only resolution. I actually see nothing about frame rates at all in your tool.
Fantastic tool BTW. I'm loving it. Thanks for all of your hard work.
0xdeadbeef
3rd March 2009, 17:53
How is this done? I see no option to specify frame rate. Only resolution. I actually see nothing about frame rates at all in your tool.
Changing the frame rate is not visible in the main view. However, when you select "Save" in the file menu, an export dialog pops up where you can set the checkbox for "Change frame rate". If this checkbox is active, the source and target frame rate can be edited and the time stamps will be changed accordingly during export.
saint-francis
3rd March 2009, 18:32
Changing the frame rate is not visible in the main view. However, when you select "Save" in the file menu, an export dialog pops up where you can set the checkbox for "Change frame rate". If this checkbox is active, the source and target frame rate can be edited and the time stamps will be changed accordingly during export.
Gotcha. Thanks.
turbojet
3rd March 2009, 23:57
Hey thanks for the program it's definitely useful however I came across some subs that are misaligned that I reported here (http://forum.doom9.org/showthread.php?p=1257351#post1257351). If you could take a look at it be much appreciated.
0xdeadbeef
4th March 2009, 01:05
How am I supposed to take a look if you didn't post a stream?
Besides, if two different tools which don't share a single line of code, show the same behavior, chances are that the stream is either buggy or uses an undocumented/unknown formatting feature.
Anyway, without a stream, nobody can tell for sure.
~bT~
4th March 2009, 03:25
how do i get the subs to show up in white rather than grey?
turbojet
4th March 2009, 05:57
Here's one of the many streams (http://www.sendspace.com/file/iyrnxf), most sup's I've converted to 720p with BD-RB has shown the problem so I think it would be a pretty common issue. I just found BDSup2Sub earlier today so this is the first.
I think it is issues with the streams like you say, I've seen many strange displays with SupRip over the past year or so but they seemed to ocr ok so I didn't pay much attention to it. But these strange displays play fine in the retail somehow.
0xdeadbeef
4th March 2009, 12:29
Can you name a frame that you think is misaligned in this SUP?
On the first look, the window (WDS) locations and sizes seem to be valid.
BTW: how was this created? It contains DTS info, so it was probably not created with EAC3TO...
hubblec4
4th March 2009, 17:40
i converted some BD.sups and i find a timestamp problem in the sub.idx
some subtitles are shown too long...
sample is here (http://rapidshare.com/files/205270057/BDSUP-idx.rar.html)
load the sub/idx in SubtitleCreater an go to subtitle 135 and you will see what i mean.
Thats not a mistake of SC because during the playback in MPC the subtitle are shown too long.
hubble
turbojet
4th March 2009, 18:30
Can you name a frame that you think is misaligned in this SUP?
On the first look, the window (WDS) locations and sizes seem to be valid.
BTW: how was this created? It contains DTS info, so it was probably not created with EAC3TO...
5, 8, 11-26, 29-40, 42-56, 58, 63-71, 73,75, 77, 81-83, 86-90, 92, 93, 95-101 are all the 'shifted' entries in the first 100.
It was demuxed with tsmuxer I will try eac3to and see if that changes anything.
eac3to threw an error
s06 Writing the destination file failed.
Aborted at file position 2052063232.
0xdeadbeef
4th March 2009, 19:50
@turbojet
Hm, looks like the windows are perfectly centered, but the image is quite a bit smaller than the window in this case (which it usually isn't). Since there is no window in the VobSub format, the image is displayed at the coordinates of the window and thus is shifted left. Problem is that I'm unsure how to handle this case (image smaller than window) in general. Maybe centering is an option, maybe there are flags in the stream that define what to do. I'll have a look.
@hubblec4
This is obviously a problem in the original stream (or created by the demuxer). If you go to frame 134 in BDSUP2Read, it shows an end time stamp "00:00:00:000". This is of course a bad thing to start with.
Since I wanted to add some time stamp inconsistency checking anyway, I might add some auto fix code as well.
0xdeadbeef
4th March 2009, 22:46
Hope I didn't destroy more than I fixed this time. First post is updated again.
04.03.2009 1.2 -> 1.3
x/y ofs from start PCS is used instead of that from the window definition (fixes most misaligned subtitles)
Time stamp inconsistencies are reported and fixed
Swapped checkboxes in export dialog to emphasize the relation between the "Change frame rate" checkbox and the src/trg FPS
Added ini file to store frame size/position and load/save paths. Probably more to follow.
Added upscaling (indeed the scaling algorithm already supported it, only the factors were wrong)
Allowed all output formats for the moment. Dunno where this will take us, but it's worth a try.
Added layout panel that shows the location of the subtitle
Worked a bit on the user interface (less rescaling of components)
Removed warnings about empty palettes since this seems to be pretty common.
All editable fields of export dialog read out again before saving (indeed already done in 1.2)
turbojet
5th March 2009, 04:45
Thanks!
1.3 got rid of the misaligned subs, at the least the ones I had remembered on 3 of 3 sup's so far. I'm considering it fixed and not going to try to remember those other ones that were misaligned. I'll let you know if I see it happen in the future.
One thing I notice in vista x64 is progress bar is very small screenshot (http://i39.tinypic.com/2i1gt4m.png)
hubblec4
5th March 2009, 06:22
Hello
Thanks for the new version.
A new problem i found.
sample (http://rapidshare.com/files/205493213/00005_-_8_-_Subtitle__PGS___German__893_captions.rar.html)
The subtitles are doubled and the first sub has no endtime in the timestamp. the problem i found on SupRead to. Only SupRip load and show the file correctly.
hubble
0xdeadbeef
5th March 2009, 18:32
Well, again, this is more a problem of the stream.
The section sequence of a typical stream looks like this:
PCS(start)/WDS/PDS/ODS/END PCS(end)/WDS/END
In your stream it looks like this:
PCS(start)/WDS/PDS/ODS/END PCS(start)/WDS/PDS/ODS/END PCS(end)/WDS/END
So the whole start sequence including the the palette and RLE compressed bitmap is duplicated, yet with different start times (PTS). IMHO this doesn't make sense since it wastes lots of space. So this is most probably a authoring fault or a problem with the demuxer.
Then again, I think I can add a workaround.
0xdeadbeef
6th March 2009, 00:37
Just a small update, mainly for the last two issues reported.
Hubble/turbojet, could you give it a try and report back?
06.03.2009 1.3 -> 1.4
Tinkered around with progress dialog to solve problems under Vista. Can't test it though.
Added frame/sequence number checks/warnings
Added automatic elimination of double subtitle start frames.
turbojet
6th March 2009, 04:25
I think progress bar looks ok now (http://i41.tinypic.com/nbez68.png) in vista.
Thanks again
hubblec4
6th March 2009, 10:40
Just a small update, mainly for the last two issues reported.
Hubble could you give it a try and report back?
06.03.2009 1.3 -> 1.4
Added automatic elimination of double subtitle start frames.
Well done. it works pretty good. No doubling anymore.
Thank you
hubblec4
6th March 2009, 11:02
Another problem i have found. please look at my sample (http://rapidshare.com/files/205493213/00005_-_8_-_Subtitle__PGS___German__893_captions.rar.html)
After transcoding the time to show this subtitles is very short. Example. Subtitle 78
here is the original length from SupRip:
78
00:08:47,068 --> 00:08:50,820
-Ich heirate.
-Was? Hör auf, ich versteh ihn nicht.
but in the new file.sub/idx (open it in SC)
78
00:08:49,070 --> 00:08:50,822
-Ich heirate.
-Was? Hör auf, ich versteh ihn nicht.
the endtime seems to be correct but the starttime is too late and nobody can read this subtitle in this short time.
hubble
0xdeadbeef
6th March 2009, 12:14
Damnit, how many samples do you actually have ;) ?
I will have a look this evening. However I assume that this is another case of stream inconsistency that SupRip detects and fixes. I just fear that each workaround added might create new problems. Also with all that stream bug fixing I somehow don't find the time to continue core development.
hubblec4
6th March 2009, 12:28
Damnit, how many samples do you actually have ;) ?
its the same sample like the first with the doubling issue.
i hope you can find a solve. then it works perfect. and the 1080p-output for sub/idx is the best feature!!
the subtitles looks like the original.
hubble
manusse
6th March 2009, 13:32
and the 1080p-output for sub/idx is the best feature!!
I didn't even know it was allowed as sub/idx is a DVD format at the origin. Did you test such a sub/idx stream with VobSub when playing a HD stream. Is it working? Is it also working with AviSynth (TextSub)?
Gives me some ideas for SubtitleCreator....
Cheers
Manusse
hubblec4
6th March 2009, 14:48
I didn't even know it was allowed as sub/idx is a DVD format at the origin. Did you test such a sub/idx stream with VobSub when playing a HD stream. Is it working? Is it also working with AviSynth (TextSub)?
Gives me some ideas for SubtitleCreator....
Cheers
Manusse
only i use mkv with subtitle.sub/idx (and sometimes SRT) and VSfilter.
It works very good the subtitles are correct shown and looks like the original. But SC can't shown the subtitles correctly.
Working with AviSynth....I don't know.
hubble
0xdeadbeef
6th March 2009, 17:25
I didn't even know it was allowed as sub/idx is a DVD format at the origin.
Indeed I just added this as an experimental feature since I was (and am) not sure what the different filters/players make of it. But since there's at least one happy customer, I think I'll leave it in ;).
BTW: SubtitleCreator v2.3rc1 seems to have quite some problems with the SUB/IDX files created by BDSup2Sub. With most of the files (which VobSub resync displays ok), SC crashes at the end of the import. Seems to be a System.NullReferenceException in SubtitleCreator.PreviewForm.ReadSUPCompleted().
0xdeadbeef
6th March 2009, 17:53
Another problem i have found.
...
but in the new file.sub/idx (open it in SC)
78
00:08:49,070 --> 00:08:50,822
-Ich heirate.
-Was? Hör auf, ich versteh ihn nicht.
the endtime seems to be correct but the starttime is too late and nobody can read this subtitle in this short time.
Ok, a quick look in the console output shows that this is a tripled start packet. While I thought I fixed it for any number of start packets, my workaround seems to work only for two. I'll have a look.
manusse
6th March 2009, 18:17
BTW: SubtitleCreator v2.3rc1 seems to have quite some problems with the SUB/IDX files created by BDSup2Sub. With most of the files (which VobSub resync displays ok), SC crashes at the end of the import. Seems to be a System.NullReferenceException in SubtitleCreator.PreviewForm.ReadSUPCompleted().
Thanks for the information. I'll try to have a look.
Cheers
Manusse
customer
??? Do you plan to sell your software later?
0xdeadbeef
6th March 2009, 18:28
Thanks for the information. I'll try to have a look.
Great, thanks!
??? Do you plan to sell your software later?
No way. This was supposed to be ironic. Obviously failed ;)
hubblec4
6th March 2009, 20:56
Ok, a quick look in the console output shows that this is a tripled start packet. While I thought I fixed it for any number of start packets, my workaround seems to work only for two. I'll have a look.
When i open a BD.sup with the "doubling-issue" in SupRead. It shows me that the starttime from the first subtitle is the correct time. but it have no endtime. and the second subtitle had the right endtime but the wrong starttime.
so you could try to take the starttime from the first subtitle and the endtime from the second subtitle...maybe
hubble
0xdeadbeef
6th March 2009, 21:25
06.03.2009 1.4 -> 1.5
Fixed redraw bug and reduced memory needed for zoom modes.
Fixed bug that caused wrong start time in case of multiple start packets or missing end packets.
Extended primary color detection to support "white,light grey" in addition to "light grey, dark grey"
Added possibility to edit/save/load Vobsub palettes
Fixed blatant bug in export of forced subtitles which would export the same frames over and over again
Set default alpha threshold to 80
hubblec4
6th March 2009, 22:40
06.03.2009 1.4 -> 1.5
Fixed bug that caused wrong start time in case of multiple start packets or missing end packets.
Wow, i am very impressed. it works now 100%
Great thanks to you.
Where i can find the Logfile to check the warnings?
hubble
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.