PDA

View Full Version : Creating idx/sub from bmp/txt files


LeMoi
16th May 2009, 15:38
Hello there
i have a vobsub file that can't be displayed with vobsub or subrip (cf http://forum.doom9.org/showthread.php?p=1279224#post1279224 ) ; the only solution left is to create a new vobsub from the bmp/txt files created with SubRip : i created bmps with all subpictures from the vobsub file with SubRip and extracted the timecodes in a txt file.
My question now is how can i create a subtitle file from the bmp/txt files ? I'm pretty sure it should be possible but i couldn't find a way on Google, so i'm asking you experts :)

Thanks in advance for your help

0xdeadbeef
16th May 2009, 18:07
Though I fear this won't really help you:

If you'd convert the text file to a BDN XML file (via a little script, program or whatever), you could use BDSup2Sub to create a VobSub from it.

Example:
<?xml version="1.0" encoding="UTF-8"?>
<BDN Version="0.93" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BD-03-006-0093b BDN File Format.xsd">
<Description>
<Name Title="de2_exp" Content=""/>
<Language Code="deu"/>
<Format VideoFormat="1080p" FrameRate="23.976" DropFrame="False"/>
<Events Type="Graphic" FirstEventInTC="00:04:27:22" LastEventOutTC="02:47:02:13" NumberofEvents="4"/>
</Description>
<Events>
<Event InTC="00:04:27:22" OutTC="00:04:32:10" Forced="False">
<Graphic Width="506" Height="61" X="707" Y="868">de2_exp_0001.gif</Graphic>
</Event>
<Event InTC="00:24:26:03" OutTC="00:24:28:05" Forced="False">
<Graphic Width="585" Height="122" X="667" Y="808">de2_exp_0002.png</Graphic>
</Event>
<Event InTC="01:45:01:10" OutTC="01:45:02:22" Forced="False">
<Graphic Width="411" Height="61" X="755" Y="868">de2_exp_0003.png</Graphic>
</Event>
<Event InTC="02:47:00:19" OutTC="02:47:02:13" Forced="False">
<Graphic Width="530" Height="61" X="696" Y="150">de2_exp_0004.png</Graphic>
</Event>
</Events>
</BDN>

Then again, I fear the BMP pictures could be a problem. Indeed, AFAIK, only palettized 8bit-BMPs can have transparency, while the typical 24bit RGB BMPs don't support transparency at all. However, I don't know a single tool that creates or reads BMPs with transparency correctly. Therefore I couldn't even test if BDSup2Sub would read transparency correctly from a BMP. PNG or GIF would be a far better choice for images with transparency.

Also just in case you decide to take that route due to lack of other (easier) possibilities (which may or may not exist), please be aware that the time codes in BDN XML are a little trickier that it might seem. The BDSup2Sub online help explains some details.

LeMoi
16th May 2009, 22:10
Transparency is not a problem, I think i can change it once the vobsub created with SubtileCreator, for example, and i think that the bmp extracted with SubRip are not 24bit but 8bit like original vobsub ?

0xdeadbeef
16th May 2009, 22:33
IMHO it is a problem. There are only 4 colors allowed per caption for a DVDs. One of them is usually a transparent color (usually, a transparent black), one is typically an opaque black as border of the characters and the last two colors are used for the main color of the characters.

Now if you lose transparency before conversion to VobSub, e.g. black background pixels and black opaque pixels can't be distinguished any more. Even if you are able to restore transparency by editing the IDX file, the (originally) opaque black pixels will be lost as well.

The result is even worse of course if the transparent pixels are white after losing transparency.

LeMoi
16th May 2009, 22:49
Here are examples of the vobsub content :

http://img32.imageshack.us/img32/6360/test00001.png
http://img30.imageshack.us/img30/8639/test00002.png
http://img268.imageshack.us/img268/9672/test00003.png
http://img30.imageshack.us/img30/6382/test00004.png
http://img39.imageshack.us/img39/4647/test00005.png
http://img195.imageshack.us/img195/1691/test00006.png
http://img34.imageshack.us/img34/5611/test00007.png
http://img195.imageshack.us/img195/1618/test00008.png
http://img36.imageshack.us/img36/4588/test00009.png
http://img32.imageshack.us/img32/5922/test00010.png

Do you think that transparency would be a problem ?

0xdeadbeef
16th May 2009, 23:11
It's hard to judge from the images where the transparency is already lost, but most probably there was a black outline which will be lost due to losing transparency.
If you can live with this issue, then this is not the main problem.

Then again, you'd still need a script to convert your text file into the XML format. Maybe also a clever search&replace approach with a good text editor might be possible in a limited amount of time.

How does your text file look like?

manusse
18th May 2009, 21:41
Hi,

Have a look at here: http://forum.doom9.org/showthread.php?t=143576

Cheers
Manusse

SledgeHammer_999
21st May 2009, 10:35
I had similar problems and the way I do it is this(i've read it on these forums, search if you want):
1.Load the IFO in subrip
2.Before clicking "Start", choose Save Subpictures as BMP Files
3.choose a separate folder to save the BMPs
4.In the window that opens choose Spruce DvDMaestro
5.Save the text file(.son)
6.Use the Son2Vsub to convert them into vobsub.

For Son2Vsub use google(it's open source).

0xdeadbeef
21st May 2009, 14:17
Gimme a day or so. I'm pretty close.

http://imagedash.com/uploads/ceu1242908165p.png (http://www.imagedash.com)

0xdeadbeef
21st May 2009, 20:48
Ok, I just released BDSup2Sub 3.8.0 which can import your problematic VobSub. Please give it a try.

Some remarks:

Use "keep existing" for the palette if you want to export to VobSub. Else (BD-SUB/BDN-XML) use "create new".
There are 3 subtitle streams merged in this VobSub. Only the first one ("langidx: 7" -> "id: en, index: 7") is used. To get one of the two french streams, you have to edit the IDX file in a text editor. Edit the line to either "langidx: 8" or "langidx: 9". I might add a select dialog later, but was too lazy to do this today.
I kinda fear that the box around the text will make it impossible to OCR with either SupRip (when exporting BD-SUP) or SubRip (when exporting SUB/IDX). If OCRing is necessary, you can try to delete the boxes by using BDSup2Sub's built in erase feature. Then again, this will be quite a lot of work since you need four erase rectangles per caption (I planned to allow cropping as well, but I'm not even sure if I ever will). Thus it might be faster to export to BDN XML and crop the pictures with a gfx editor, then reimport and export to your wanted format. "Paint.Net" is a free gfx tool that can handle PNGs with transparency.


Hope this helps...

0xdeadbeef
22nd May 2009, 21:21
One more comment:
By chance I noticed that caption #53 of the first french subtitle stream (id: fr, index: 8) is empty.
As I assumed this was a bug in BDSup2Sub, I analyzed the command header of this caption but found to my surprise that it was an issue of the stream. While all the other captions have dozens of alpha updates to implement a fade in/off effect, this caption has only one udpate where the alpha values stay 0.

Maybe I'll add a workaround for stuff like this (like using the alpha values of the previous caption if all values are 0) in a future version, yet for the moment, I can only give you a hint how to modify the SUB file to show this caption:
Edit the two bytes at offset 0xeb953 from 0x00,0x00 to 0xcf,0x80.
I haven't looked any further if there are more issues in the 2nd french stream, but if so, just tell me and I'll have a look.

0xdeadbeef
25th May 2009, 20:06
Not that anybody seems to be interested in this anymore, yet I'd like to add that 3.8.2 now automatically patches the alpha values if they're all 0. Might lead to interesting results in special cases, but generally it works and anyway it's better to see something than to have a completely transparent caption.
-> no manual editing necessary.

LeMoi
25th May 2009, 20:57
Sorry i didn't have time this week to have a look at your last changes, i'll try and see this week...