View Full Version : DivX Media subtitle creation (xsub)
Zhnujm
9th February 2005, 19:07
I created a little utility that converts .bmp files to .xsub subtitles, mostly for playback in my hardware player.
The .xsub files can be muxed directly in your avi files with fuse.exe.
Download: link (ftp://zhnujm.dyndns.org/bmptoxsub.zip)
First thing, we need bitmaps for every subtitle.
For that use SubRip and save subtitles as .bmp files.
Format:
-Philips SVCD Designer
-4bits
-Custom Colors (you HAVE to use custom colors, dont know why), color 1 should be black
-Minimum picture width 720, minimum picture height 576 (PAL) or 480 (NTSC)
-As Output format for the timecode file you have to use TurboTitler .tts format
Then convert the bitmaps to .xsub with bmptoxsub:
BMPTOXSUB timecodefile xsubfile bitmapfile(without the numbers at the end) PAL/NTSC switch
Example:
bmptoxsub english\time.tts test.xsub english\bitmap PAL
The bitmap filenames would be in this example bitmap00001.bmp, bitmap00002.bmp,...
Make sure they start with 00001.
The resulting .xsub file can be muxed with fuse.exe:
fuse -v film.avi -s test.xsub -o film.divx
--edit
I did not even know the name of my program...
thefluffy
10th February 2005, 02:16
Cool !
Please note the subtitle bitmap limit is 720 x 480, not 720 x 576. If you exceed this limit, you lose the guarantee of DivX Certified playback.
I'm sure the community will appreciate you respecting the limit.
LordRPI
10th February 2005, 03:28
Nice work! I've tested it out with a clip of my own and it's working!
But just so you know
Example:
bmp2xsub english\time.tts test.xsub english\bitmap PAL
should be
bmptoxsub english\time.tts test.xsub english\bitmap PAL/NTSC
This is excellent work!
Zhnujm
10th February 2005, 15:35
Thanks, at least it works for somebody else than me :)
Originally posted by thefluffy
Cool !
Please note the subtitle bitmap limit is 720 x 480, not 720 x 576. If you exceed this limit, you lose the guarantee of DivX Certified playback.
I'm sure the community will appreciate you respecting the limit.
Does that only mean the bitmap size can not be bigger than 720x480 or also that the bitmap cannot be placed below 480 pixels ?
First thing can surely be solved but the second one would be a major problem for PAL users.
I dont like subtitles in the middle of the screen....
thefluffy
12th February 2005, 02:45
You have a max of 720 x 480 for the subtitle bitmap. This bitmap is then scaled to the video resolution.
So if the subtitle bitmap and video resolution are the same, then it's 1 for 1.
Zhnujm
12th February 2005, 18:55
But there is no scaling if you use a hardware player.
The subtitle is displayed exactly at the position that you define. Lets say i use a 200x50 bitmap and place it at 300,430-499,479 then it appears near the middle of the PAL screen.
So i need to place it at something like 300,510-499,559.
Jeffster
13th February 2005, 02:56
I have just tried your converter with a PAL clip and the settings you suggest including 720-576 for the bitmaps.
It works and the subs play back fine.
I then changed the TV standard setting on my standalone from Multi to NTSC... the result is that the subs are no longer visible, as they are positioned too low. Other than that, the clip still plays back okay.
I made a second sample with the same PAL clip using 720-480 for the bitmap size in SubRip. Forcing NTSC output to my TV and it played fine this time with the subs showing up, although the font seems out of proportion (quite tall). Is that the same on your NTSC clips?
Playback in PAL mode though is a problem. Yes the subs are higher up on the screen, but there is some flickering and weirdness when subs appear.
I imagine the recommened subtitle limit of 480 that was mentioned here is so they will be compatible with NTSC only TV's (as I understand it, Multisystem TV's are rare in America)?
Zhnujm
13th February 2005, 12:25
What hardware player did you use ? For me (Yamaha 550) the subs stay at the same position if i switch from PAL to NTSC.
Im currently testing some PAL/NTSC clips to see what happens.
The next version wont need fullscreen bitmaps so it should be easier to place them on screen.
Jeffster
13th February 2005, 13:07
Originally posted by Zhnujm
What hardware player did you use ?
Philips 640K
Zhnujm
13th February 2005, 19:19
I tried some combinations:
PAL video, 576 bitmap: perfect
PAL video, 480 bitmap: subtitles to high
NTSC video, 480 bitmap: perfect
NTSC video, 576 bitmap: subtitles to low (out of the screen area)
I will implement 2 modes, one wich uses a 720x576 bitmap for PAL and one that uses 720x480 for PAL and moves the subtitles down as far as possible.
thefluffy
15th February 2005, 19:15
That is correct.
For NTSC the resolution limit is 720x480.
For PAL the resolution limit is 720x576.
Zhnujm
15th February 2005, 22:26
Well, thats good to hear even after i created a mode to move the subtitles up to 480.....
Heres the new version:
download (ftp://zhnujm.dyndns.org/bmptoxsub.zip)
Everything is changed, use it like this:
bmptoxsub 1 2 3 4
1: Timecodefile (Philips SVCD-Designer .sub format
2: Output subtitle file (.xsub format)
3: (optional) Path to bitmap files
4: (optional) PALMODE1/PALMODE2(default)
examples:
bmptoxsub test\test.sub subtitle.xsub
bmptoxsub test\test.sub subtitle.xsub c:\files\
bmptoxsub test\test.sub subtitle.xsub PALMODE1
SubRip subtitle format:
SVCD-Designer, 4bits, custom colors,width+height+left+top dividable by 2
It now uses directly the SVCD-Designer .sub format, no need to convert to .tts.
Also theres no need anymore to use fullscreen bitmaps.
The TC&Res option must be enabled in SubRip.
PALMODE1:
Moves subtitles to NTSC save area for PAL->NTSC conversion.
PALMODE2:
Use original subtitle position.
If no path is specified it searches for the bitmap files in the current folder and in the folder where the .sub file is.
Its not tested with NTSC files, so make sure you check the output....
And dont use to complicated filenames, nobody knows what could happen.
LordRPI
16th February 2005, 18:34
Originally posted by thefluffy
That is correct.
For NTSC the resolution limit is 720x480.
For PAL the resolution limit is 720x576.
It's funny, when you actually know the guy in person, you read it with an Australian accent ;)
SeeMoreDigital
16th February 2005, 20:20
Hi Zhnujm,
Do you have an short PAL and NTSC "example clips" you can provide us?
Cheers
Zhnujm
16th February 2005, 21:29
Heres a short example with 2 subtitle streams:
download (ftp://zhnujm.dyndns.org/small.divx)
Download may be slow.
It seems to me that the (Software) DivX-Player does not correctly recognise the subtitle position, i have a dvd that has some subtitles at the top, but the DivX-Player shows them at the bottom. Hardware playback is OK.
SeeMoreDigital
16th February 2005, 22:25
Originally posted by Zhnujm
,,,It seems to me that the (Software) DivX-Player does not correctly recognise the subtitle position, i have a dvd that has some subtitles at the top, but the DivX-Player shows them at the bottom. Hardware playback is OK. Are you using a stand-alone player that recognises PAR/DAR signalling in AVI?
If so, you might be interested to know (or you might already know) that MPEG Modifier will accept Mpeg4 streams with an .divx file extension!
I was hoping that after adding 16:9 DAR signalling to your sample, DivX Player would have displayed the subtitles in the correct place... but sadly it didn't :(
Cheers
thefluffy
16th February 2005, 22:56
The subtitle stream of small.divx is as follows:
00:00:05.080 00:00:07.720 "small000.bmp" (214 464 505 535)
00:00:07.880 00:00:11.400 "small001.bmp" (172 464 545 535)
00:00:11.560 00:00:14.600 "small002.bmp" (174 464 543 529)
00:00:14.960 00:00:16.800 "small003.bmp" (262 504 455 529)
00:00:17.000 00:00:19.040 "small004.bmp" (182 464 535 529)
Lets take the first one for example; left as 214, right as 505, top as 464, and bottom 535. This subtitle shouldn't play at the top of the screen.
Maybe I'm looking at the wrong file ?
Zhnujm
16th February 2005, 23:30
Originally posted by thefluffy
Maybe I'm looking at the wrong file ?
Yes, sorry, maybe i was not that clear, thats NOT the file with the subtitle at the top :)
I can make it available tomorrow.
Zhnujm
17th February 2005, 18:19
Heres the same file as above, but the first and the third subtitle should be at the top:
download (ftp://zhnujm.dyndns.org/small2.divx)
Its works in hardware, but not with DivX-Player.
thefluffy
17th February 2005, 19:25
This is a DivX Player bug. Thanks for the feedback !
Zhnujm
17th February 2005, 22:23
Originally posted by SeeMoreDigital
If so, you might be interested to know (or you might already know) that MPEG Modifier will accept Mpeg4 streams with an .divx file extension!
Nice, seems to work.
I thought it would loose the subtitle streams after saving.
SeeMoreDigital
17th February 2005, 22:37
Originally posted by Zhnujm
Nice, seems to work.
I thought it would loose the subtitle streams after saving. So did I...
I also tried to de-muxing the video stream using AVI-mux (v1.16.11). But could not :o
Have you tried de-muxing the video stream?
Cheers
stephanV
17th February 2005, 23:18
demuxing the video stream should be possible with VirtualDub... AVImux GUI seems to b0rk yes.
SeeMoreDigital
17th February 2005, 23:45
Originally posted by stephanV
demuxing the video stream should be possible with VirtualDub... AVImux GUI seems to b0rk yes. Can you have a go? I don't have VirtualDub or VirtualDubMod installed.
Cheers
stephanV
18th February 2005, 00:04
I'm quite sure it works. VirtualDub will give you a bunch of warnings about the subtitles, but you can ignore those.
Furthermore, its only a <1MB download, and you should have it anyway... :rolleyes:
(how can one work with AVI and not have VirtualDub...)
SeeMoreDigital
20th February 2005, 23:28
Originally posted by stephanV
I'm quite sure it works. But have "you" (or anybody else for that matter) tried it yet?
Cheers
stephanV
20th February 2005, 23:42
works
SeeMoreDigital
21st February 2005, 00:17
Originally posted by stephanV
works Was VirtualDub/Mod able to detect and de-mux both the 640x352 and 1280x720 DivX video streams?
Cheers
stephanV
21st February 2005, 10:08
of course not, only the first stream. the second stream is not in the riff tree of the first. basically what DivX is doing is "copy /b normal.avi+menues+HD.avi new.divx". Since this is not in anyway allowed for AVI, VirtualDub ignores the menues and HD part.
If you want to extract the HD part you need a hexeditor and do some serious "find and replace". I managed to do it though. :)
stephanV
21st February 2005, 11:57
it should also be possible with Haali's splitter and graphedit BTW - since that splitter can detect AVI segments and ignores chunk IDs.
tvdpoll
25th February 2005, 14:05
First of all, thx for the program, it works great!!!! Now I can finaly watch my movies with good subs. The fuse program accepts *.srt files, but they get displayed to high on my dvd-player. With bmptoxsub it's perfect! Just like watching a dvd.
However, I've tried to get this working with *.srt files, converting the text into bitmaps using srt2sup. I get the bitmaps allright, and can convert the *srt file to a *.sub file using subrip, but somehow the bmptoxsub program does not accept the bitmaps. I get no error, but the xsub file is small (about 6k for a 2 hour movie) and does not work, neither on the pc nor on my dvd-player.
Is there a way to get this to work? In that way we can ad subtitles in languages we have not available on the dvd.
Thanks in advance for help and advise!
Zhnujm
25th February 2005, 19:21
Srt2sup seems to create 24bit bmp files, but bmp2xsub only accepts 4bit bmp files.
You can batch convert the images for example with irfanview to 4bit, then it works, but i cannot find a solution to get the right colors.
If i set the outline to black it gets transparent during playback, and custom colors are not possible with srt2sup. A dark gray would be useful.
--edit
I think a can make switch to override the color settings.
Btw, is there any other program for srt to bmp conversion ?
tvdpoll
26th February 2005, 00:46
I do not know of any other program that can convert srt to bitmaps.
I am still trying to get it to work using srt2sup. I am getting quite far, transforming the sup into vob using ifoedit, but ifoedit does not like this very much without a movie-file (have to cheat, and open a file like movie-file and than delete it, before saving the new ifo), but I get some synchronisation problems. Also, the first and last lines are left out (don't know why, probably has to do with the fact that a videofile is missing in ifoedit). Keep on trying dough.
If you could get it to work without the use of ifoedit, that would be great (and easier as well)!
tvdpoll
26th February 2005, 02:03
I seem to have it working!!!
Using srt2sup and irfanview. I am using the following colour settings (attention: I think you need to use these in Global settings).
backround: black
text: grey
outline: white
antialias: silver
It works on my pc. Haven't tested it on my dvd-player yet, and i'm going away for a week tomorrow, but i am sure it will work on my player as well.
Thanks for directing me to irfanview.
Zhnujm
26th February 2005, 23:53
Dont use the old version of bmptoxsub for converting, it will not produce compatible files with SRT2SUP. It seems that SupRip is not able to convert the .srt that SRT2SUP generates correctly to Philips SVCD Designer .sub format, the bitmap coordinates and dimensions are not right.
This does work in software but does not work with my hardware players.
Heres a new version of bmptoxsub: download (ftp://zhnujm.dyndns.org/bmptoxsub.zip)
It takes care of the problems and has 2 new (optional) options:
SRT2SUP - forces outline color to black so you can use any outline color in SRT2SUP
REPOS - changes the position of the subtitles to the bottom safe area, may be useful with SRT2SUP as it places the subs a bit to low for some TVs.
tvdpoll
28th February 2005, 11:57
Thanks once more Zhnujm. This is great news!
Like i said, I am away this week (but do have a internetconnexion), so I can not test it this week. Will try it as soon as I am back, but i am sure it will work great! Now I can add "professional looking"subs to my divx movies!
javierperezch
1st March 2005, 16:32
I managed to generate a SUB file in Philips SVCD format with its corresponding set of 4 bits BMP files using the srt2sup / subrip / InfranView stuff
I used black background, white outline, yellow font and olive antialias.
Then I generated the XSUB file using the last version of BMPTOXSUB using the SRT2SUP mode enabled in order to get black outline instead of white.
Finaly, I muxed an AVI and the resulting XSUB using FUSE.
When I play the generated DIVX file, randomly some subtitle lines are displayed with yellow font (as I wanted to) but others are displayed in cyan. The outline is always white, although I used the SRT2SUP option to get a black outline. The BMPs used to generate the XSUB file are all 4 bits and the text are displayed in yellow when I open the files with Windows 2000 Paint.
I didn't try it on a stand alone player.
Am I doing anything wrong?
Thank you
Zhnujm
1st March 2005, 20:21
Originally posted by javierperezch
Am I doing anything wrong?
I think not.
Two problems:
Colors are not displayed right (yellow is not yellow):
I recognised this also with subrip, try red and it gets displayed as blue, yellow is cyan. I hav no idea why that is, the colors are read from the bitmap file with a function from the DivX SDK. Maybe a bug in the SDK or subtitle demo code.
Second:
Theres no general rule how Irfanview chooses the palette colors. The setting SRT2SUP only changes the second enrty in the palette to black.
In your case this is the oliv antialias :rolleyes:
I think i can solve the second problem by adding an option to choose the palette entry that should be black but i dont now if i can solve the first problem.
Zhnujm
1st March 2005, 20:43
Well problem 1:
The Red and the Blue RGB values are swapped.
Is this definition in subtitleparser.h correct ?
typedef struct _DIVXBITMAPRGBQUAD
{
uint8_t rgbBlue;
uint8_t rgbGreen;
uint8_t rgbRed;
uint8_t rgbReserved;
}
DIVXBITMAPRGBQUAD;
Shouldnt it be Red-Green-Blue instead of Blue-Green-Red ? Unfortunatly i have no idea if the order matters at all.
The colors are right if i swap the Red/Blue values in my program, but not if i change the header file.
javierperezch
1st March 2005, 21:18
Originally posted by Zhnujm
Colors are not displayed right (yellow is not yellow):
I recognised this also with subrip, try red and it gets displayed as blue, yellow is cyan. I hav no idea why that is, the colors are read from the bitmap file with a function from the DivX SDK. Maybe a bug in the SDK or subtitle demo code.
The problem is that for some text lines, colors are displayed correctly, and for others they are swapped.
If colors were displayed always swapped, if for instance I wanted to show blue subtitles, I could write them in red, and then get them displayed in blue. But instead I would get some lines in red and some in blue.
Zhnujm
1st March 2005, 21:43
If you could send me a single bitmap that is correctly displayed as yellow to zhnujm@hotmail.com ?
I cannot reproduce that, the colors are always wrong for me.
I did not recognised this before as i only use white/grey/black for subtitles. And in this case the swapped values have no effect.
javierperezch
2nd March 2005, 13:38
Ok.
I'm sending you some BMP samples to your mail.
Javier
javierperezch
2nd March 2005, 17:08
Zhnujm,
I didn't keep a copy of the BMPs causing the problem, so I tried to generate them again. I don't know why, but I cant reproduce the problem anymore. I did it a lot of times yesterday and allways I got some lines Ok and some wth swapped colors, but now I get all lines with swapped colors!!! It's weird because I'm using the same exact programs I used yesterday in the same way!!!
javierperezch
3rd March 2005, 17:44
Oops! I did it again!
I don't know exactly how (I supposedly did exactly the same than before), but I was able to reproduce the problem again. I'll send you now some samples of the BMPs.
Zhnujm
3rd March 2005, 19:51
Thanks, i got your mail. I will see what happens. Maybe the problem is a different color palette in each BMP file.
Until then heres a new version:
download (ftp://zhnujm.dyndns.org/bmptoxsub.zip)
It switches the red and blue values and has new optional options:
SRT2SUP1 SRT2SUP2 SRT2SUP3 SRT2SUP4
Wich these you can select wich color will be replaced with black. Just look at the palette of the BMP file with irfanview and choose the right color.
SRT2SUP is no more allowed.
yippy_yaya
4th March 2005, 00:56
****************************************************
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
E:\>cd dvd2divx\divx\bitmapn
E:\dvd2divx\divx\BitmapN> bmptoxsub eng\eng.tts eng.xsub eng\eng
Timecode file: eng\eng.tts
Subtitle file: eng.xsub
Bitmap file path: eng\eng
PAL Mode: 2
SRT2SUP Mode: 0
REPOS Mode: 0
Cannot parse, (PAL/NTSC)
E:\dvd2divx\divx\BitmapN>
****************************************************************
What's wrong with mine one???
i save the bmptoxsub inside the bitmapn folder.Inside the bitmapn folder got eng folder. inside the eng folder is *.tts and eng00001.bmp.... files
pls advice.
Zhnujm
4th March 2005, 14:25
Sorry, many things were changed since my first post. tts files do not work anymore, you can directly use the philips .sub format (you have to as i need the position data for the bitmaps and the filenames inside the .sub file).
here the new decription:
bmptoxsub 1 2 3 4 5 6
1: Timecodefile (Philips SVCD-Designer .sub format
2: Output subtitle file (.xsub format)
3: (optional) Path to bitmap files
4: (optional) PALMODE1/PALMODE2(default)
5: (optional) SRT2SUP1/SRT2SUP2/SRT2SUP3/SRT2SUP4
6: (optional) REPOS
In your case a
bmptoxsub eng\eng.sub eng.xsub
should be enough.
If you dont use a bitmap path it searches in the folder where bmptoxsub is and in the folder of the .sub file.
tvdpoll
10th March 2005, 01:36
I'm back home again ;-)
Thx for your work, Zhnujm. It works!
However, I've tried it on a longer srt file (I, Robot), and I get the next error:
Cannot Parse, <POSITION>
I've tried it in REPOS MODE 1 as well, but with the same result.
What can this be?
Thx in advance
----------------
Never mind, i've already figured it out. The txt was 'going off screen'. I now check this within srt2sup before I convert to bitmaps and it works great now!!!!
Thanks so much, Zhnujm; for your nice tool!
Zhnujm
14th March 2005, 15:29
Nice to see that it works, im a bit out of time currently. (World of Warcraft)
I already tried javierperezchs bitmap files and for me both show the same wrong colors (or correct colors with the current bmp2xsub version). So im out of ideas.
Im also want to implement a mode with repositions x and y values so it will completely override srt2sups settings.
tvdpoll
14th March 2005, 17:28
Zhnujm,
Repositioning would be nice. If we could just give the aim size (for instance 720 x 576) and that bmptoxsub would ajust to the bottom and the centre, that would be very fine.
As for the colours, i've used it quite some times now, but i have never had any problems with colors.
Once again, this is a very nice little tool, that increased my pleasure of watching my avis (divx's) on my stand-alone player enormously!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.