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 Display Modes
Old 26th February 2009, 00:39   #1  |  Link
0xdeadbeef
Author of BDSup2Sub
 
Join Date: Jun 2003
Posts: 410
BDSup2Sub - convert and tweak bitmap subtitle streams (VobSub,BD-SUP,BDN XML,HD-SUP)

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)

Download

Current version: 3.9.9 (15.11.2009)
http://www.sendspace.com/file/4mcnk5


Previous versions:
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 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:

Code:
java -jar BDSup2Sub.jar
or in Windows if you don't want a open CMD box:

Code:
javaw -jar BDSup2Sub.jar
There are some instructions available in the online help.

CLI

BDSup2Sub can be (almost) completely controlled from the command line. See online help for details. For a quick help on the command line call it with "/help" or "/?" as only parameter.

Code:
java -jar BDSup2Sub.jar /help
This prints out something like this:
Code:
java -jar BDSup2Sub <in> <out> [options]
Options:
    /res:<n>         : set resolution to 480, 576, 720 or 1080 - default 576
                       Predefined values: keep, ntsc=480, pal=576, 1440x1080
    /fps:<t>         : synchronize target frame rate to <t> - default: auto
                       Predefined values; 24p=23.976, 25p=25, 30p=29.967
                       /fps:keep preserves the source fps (for BD&XML)
    /fps:<s>,<t>     : convert framerate from <s> to <t>
                       Predefined values; 24p=23.976, 25p=25, 30p=29.967
                       /fps:auto,<t> detects source frame rate automatically
    /dly:<t>         : set delay in ms - default: 0.0
    /filter:<f>      : set scaling filter - default: bilinear
                       Supported values: bilinear, triangle, bicubic, bell,
                       b-spline, hermite, lanczos3, mitchell
    /palmode:<s>     : palette mode: keep, create, dither - default: create
    /tmin:<t>        : set minimum display time in ms - default: 500
    /tmerge:<t>      : set max time diff for merging subs in ms - default: 200
    /movin:<r>[,<o>] : move captions inside screen ratio <r>, +/- offset <o>
    /movout:<r>[,<o>]: move captions inside screen ratio <r>, +/- offset <o>
    /movex:<t>[,<o>] : move captions horizontally.<t> may be left,right,center.
                       +/- optional offset <o> (only if moving left or right)
    /cropy:<n>       : crop the upper/lower n lines - default: 0
    /acrop:<n>       : set alpha cropping threshold - default: 10
    /scale:<x>,<y>   : scale captions with free factors - default: 1.0,1.0
    /exppal[+/-]     : export target palette in PGCEdit format - default: off
    /forced[+/-]     : export only forced subtitles - default: off (export all)
    /forceall[+/-]   : set/clear forced flag for all subs - default: off (keep)
    /swap[+/-]       : swap Cr/Cb components - default: off (don't swap)
    /fixinv[+/-]     : fix zero alpha frame palette - default: off (don't fix)
    /verbatim[+/-]   : switch on verbatim console output mode - default: off
Options only for SUB/IDX or SUP/IFO as target:
    /atr:<n>         : set alpha threshold 0..255 - default 80
    /ltr1:<n>        : set lum lo/mid threshold 0..255 - default auto
    /ltr2:<n>        : set lum mid/hi threshold 0..255 - default auto
    /lang:<s>        : set language to string <s> - default: de (only SUB/IDX)
    /pal:<s>         : load palette file <s> - default: use builtin palette

Note:

Boolean parameters like "verbatim" are switched off with a trailing "-".

Wildcard support:
To use wildcards, enclose the whole parameter string in double quotes.
For filenames containing spaces, use single quotes around the file name.
Use "*" for any character and "?" for one character in the source name
Use exactly one "*" in the target file name.
Example:
java -jar BDSup2Sub.jar "'movie* 1?.sup' dvd_*.sub /res:720 /fps:25p"
For more details have a look in the online help

Increasing the RAM size
Java application only get a maximum of 64MB of RAM per default. This can lead to memory problems when loading SUPs with thousands of warnings or if importing XML/PNG with very large images. The java runtime supports command line switches to increase the RAM size though:

Code:
java -Xmx256m -jar BDSUp2Sub.jar
This will increase the maximum heap to 256MB of RAM which should be enough in all cases. Since this is a parameter to the virtual machine, it must be used before the "-jar" and it has no influence on BDSup2Sub's command line switches.

Integration in the Windows Explorer
Unfortunately it's impossible to change the Windows registry in Java without sacrificing platform independence. So to register BDSup2Sub as default application for SUP files, some manual work is needed.
Cut out this text and save it with a plain text editor (e.g. NotePad) as BDSup2Sub.reg (the extension ".reg" is important!).

Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.sup]
@="SUP BD/HD-DVD caption stream"

[HKEY_CLASSES_ROOT\.sup\shell]

[HKEY_CLASSES_ROOT\.sup\shell\open]

[HKEY_CLASSES_ROOT\.sup\shell\open\command]
@="\"E:\\dev\\java\\jre_6_0\\bin\\javaw.exe\" -jar \"d:\\src\\java\\BDSup2Sub\\BDSup2Sub.jar\" \"%1\""
Then replace "E:\\dev\\java\\jre_6_0\\bin" with the path to your Java runtime and "d:\\src\\java\\BDSup2Sub" with your installation directory of BDSup2Sub. Remember to use double backlashes ("\\" instead of "\")!!!
Now save the file and double click it from the Explorer. Chose "yes" in the following two dialogs.
If you (and I) did everything right, BDSup2Sub should be used now to open SUP files when you double click on them.
You can use the same approach of course to open VobSubs. Just replace "sup" with "idx" and "SUP BD/HD-DVD caption stream" with "SUB/IDX caption stream" or whatever you like as name.

Drag'n'Drop
Since version 2.8, BDSup2Sub is able to open files via Drag'n'Drop. Just drag a SUP, XML, IFO or IDX file on the application window and release the mouse button. As BDSup2Sub is not able to open more than one subtitle stream at a time, only one file will be opened if you drag&drop multiple files. Internally, always the first file in the passed list is opened - this might however not be the file that is displayed first in your selection. Anyway, this feature is meant for one file only anyway.
Note: as explained in the SUP/IFO section, Drag'n'Drop of a DVD-SUP will lead to wrong detection as HD-DVD-SUP and the import will fail with error messages. Drag'n'Drop of the IFO works though.

Disclaimer
BDSup2Sub is provided "as is" without warranty of any kind. Use it at your own risk.

BDSup2Sub is freeware in the sense of "free for all to use". Download it, give it to your friends or whatever. If you intend to put it as download on your site, please make a reference to this thread. If you plan to use BDSup2Sub in a commercial environment, please contact me before via PM.

Currently, BDSup2Sub is not open source ("free software") yet, as it's work in progress and I need to clean up and document quite a few things to release the sources to the public. While I hope this might happen soon, chances are it never will. If it should happen, the license used will be most probably either the Apache license 2.0 or the LGPL 3.0. However, if you're interested in the sources to just have a look at the implementation or copy out minor parts for your own projects, you're welcome to. Just drop me a PM.

I you wish to use the JAR as a library for converting subtitles, you're invited to. JavaDocs are included for all interesting public interfaces, so you just need to integrate the JAR in your project. For an example how to interface the core objects, just drop me a note.

Besides, a part of the sources that is licensed under the LGPL or Apache license is already included in the JAR (rename to ZIP and extract the "src" folder).
This includes also the following functionalities:
  • PNG Encoder by J. David Eisenberg (modified to support transparency for palette mode via the tRNS tag). Licensed under the LGPL.
  • Octree Quantize Filter by Jerry Huxtable (modified to support alpha component and better palette reduction). Licensed under the Apache License 2.0.
  • Scaling/filter routine based on Morten Nobel-Joergensen's ResampleOp from his Java image scaling library. Licensed under the LGPL.
  • JFileFilter based on ExampleFileFilter from the FileChooserDemo included in the JDK. Licensed under proprietary Sun license (similar to Apache).

The other sources included (e.g. Props, FileBuffer, BitStream) are completely done by me, myself and I and are released under the Apache License 2.0. In a nutshell that means you can use them and modify them even for closed source projects, as long as you leave some copyright info in (see the included Apache License for details).

Have fun.

Screenshots
Main screen (source in upper part, target in lower part)


Conversion dialog with the basic conversion options


Edit dialog


Move dialog

Last edited by 0xdeadbeef; 15th November 2009 at 23:29.
0xdeadbeef is offline   Reply With Quote
Old 26th February 2009, 05:04   #2  |  Link
BigCondor
Registered User
 
Join Date: Oct 2006
Location: Hong Kong
Posts: 218
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)
Attached Images
 
BigCondor is offline   Reply With Quote
Old 26th February 2009, 15:27   #3  |  Link
Selur
member of flaskmpeg.info
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 1,855
any plans to open the source of the tool?
__________________
german MeGui Essentials, sx264
Selur is offline   Reply With Quote
Old 26th February 2009, 17:18   #4  |  Link
0xdeadbeef
Author of BDSup2Sub
 
Join Date: Jun 2003
Posts: 410
Quote:
Originally Posted by BigCondor View Post
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.

Quote:
Originally Posted by Selur View Post
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.

Last edited by 0xdeadbeef; 26th February 2009 at 17:39.
0xdeadbeef is offline   Reply With Quote
Old 26th February 2009, 19:11   #5  |  Link
Adub
Fighting spam with a fish
 
Adub's Avatar
 
Join Date: Sep 2005
Posts: 2,305
Quote:
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.
Adub is offline   Reply With Quote
Old 26th February 2009, 20:30   #6  |  Link
0xdeadbeef
Author of BDSup2Sub
 
Join Date: Jun 2003
Posts: 410
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 is offline   Reply With Quote
Old 27th February 2009, 01:10   #7  |  Link
0xdeadbeef
Author of BDSup2Sub
 
Join Date: Jun 2003
Posts: 410
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.

Last edited by 0xdeadbeef; 27th February 2009 at 02:05.
0xdeadbeef is offline   Reply With Quote
Old 27th February 2009, 08:20   #8  |  Link
shon3i
BluRay Maniac
 
shon3i's Avatar
 
Join Date: Dec 2005
Posts: 1,710
Do you think about reverse process? DVD->BluRay?
shon3i is offline   Reply With Quote
Old 27th February 2009, 12:27   #9  |  Link
0xdeadbeef
Author of BDSup2Sub
 
Join Date: Jun 2003
Posts: 410
Not really. Would this make sense?
0xdeadbeef is offline   Reply With Quote
Old 27th February 2009, 18:34   #10  |  Link
SquallMX
Registered User
 
Join Date: Nov 2002
Posts: 69
Quote:
Originally Posted by 0xdeadbeef View Post
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.

SquallMX is offline   Reply With Quote
Old 28th February 2009, 02:24   #11  |  Link
woah!
Registered User
 
Join Date: Oct 2003
Posts: 404
1080 to 720 resizing would be very cool if possible, otherwise it works very well thx
woah! is offline   Reply With Quote
Old 1st March 2009, 16:23   #12  |  Link
0xdeadbeef
Author of BDSup2Sub
 
Join Date: Jun 2003
Posts: 410
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.
0xdeadbeef is offline   Reply With Quote
Old 2nd March 2009, 01:42   #13  |  Link
woah!
Registered User
 
Join Date: Oct 2003
Posts: 404
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

Last edited by woah!; 2nd March 2009 at 01:56.
woah! is offline   Reply With Quote
Old 2nd March 2009, 02:18   #14  |  Link
0xdeadbeef
Author of BDSup2Sub
 
Join Date: Jun 2003
Posts: 410
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).

Last edited by 0xdeadbeef; 2nd March 2009 at 02:21.
0xdeadbeef is offline   Reply With Quote
Old 2nd March 2009, 05:47   #15  |  Link
SquallMX
Registered User
 
Join Date: Nov 2002
Posts: 69
Hi, i found a little bug, the program crash when i load this Sup file (From Matrix R1 Bluray):

http://rapidshare.com/files/20426218...track_4609.sup

SquallMX is offline   Reply With Quote
Old 2nd March 2009, 17:54   #16  |  Link
0xdeadbeef
Author of BDSup2Sub
 
Join Date: Jun 2003
Posts: 410
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 is offline   Reply With Quote
Old 2nd March 2009, 20:14   #17  |  Link
0xdeadbeef
Author of BDSup2Sub
 
Join Date: Jun 2003
Posts: 410
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
0xdeadbeef is offline   Reply With Quote
Old 3rd March 2009, 03:12   #18  |  Link
~bT~
н∂-ƒαиαтι˘
 
Join Date: May 2006
Location: Bedfordshire, UK
Posts: 986
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.
~bT~ is offline   Reply With Quote
Old 3rd March 2009, 12:18   #19  |  Link
0xdeadbeef
Author of BDSup2Sub
 
Join Date: Jun 2003
Posts: 410
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.
0xdeadbeef is offline   Reply With Quote
Old 3rd March 2009, 16:13   #20  |  Link
~bT~
н∂-ƒαиαтι˘
 
Join Date: May 2006
Location: Bedfordshire, UK
Posts: 986
^ 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.
~bT~ is offline   Reply With Quote
Reply

Thread Tools
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 23:29.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.