PDA

View Full Version : Rendering subtitles to PNG


P0l1m0rph1c
22nd June 2004, 01:04
OK, I didn't know actually where to put this thread, but here seems apropriate somehow.

We are making an app that will automatize the creation of a DVD from an AVI file, basically. The problem where we are stuck now is how to handle the subs.

We are using spumux to mux the subtitles in the program MPEG2 stream. spumux accepts both PNG and BMP, but they must be 4bpp (and <16 colors). To make those PNG's, we are doing it with avisynth, with a script similar to the following:

LoadPLugin("vsfilter.dll")
BlankClip(13)
AssumeFPS(25)
LanczosResize(720, 574)
TextSub("legpt.sub", 25)
ConvertToRGB24()
ImageWriter("C:\subs\", 0, 13, "PNG")

The problem with this aproach is that this will actually creat 24bpp PNG's, instead of 4bpp, which we don't have a clue how to make with avisynth. So, there are two options: either we (with your help) find a way of writing 4bpp PNG's directly from the script, or we just find another way to render the subtitles.

If i understand correctly, ImageWriter does accept only 24bpp input, except if EBMP is chosen. So, if this is to be made by Avisynth, it would be needed to make a conversion from RGB24 to RGB4 (?), and write a BMP or PNG with each image.

I believe another method for rendering the subs would be better, but we don't actually know which one to use, and probably how...

Any help you could give would be much apreciated.

Bidoche
22nd June 2004, 10:18
Aren't they programs who could convert 24bpp PNG to 4bpp ?

P0l1m0rph1c
22nd June 2004, 19:53
Sure there are. But i dunno no program that can actually do that via CLI, since we need that being run from our app, automatically.

Anyway, i don't think that would be the best solution.

Nocturno
23rd June 2004, 06:42
why render the subs, spumux can handle textbased subs too

from http://dvdauthor.sourceforge.net/doc/spumux.html


Spumux is also able to handle text subtitles, which will be rendered to graphics by spumux. A lot of different text (must be non-graphic) formats are supported (.sub, .srt, .ssa, .smi, .rt , .txt, .aqt, .jss, .js, ass). Spumux will try to determine the format automatically.

If processing textbased subtitles no other streams can be defined, buttons or others need to be processed in another pass with spumux, using another xml file.

Following .xml file shows the available tags and their default settings. Only the textsub tag is mandatory, defaults are used if the specific tag is not specified.

<subpictures>
<stream>
<textsub filename="demo1.srt" characterset="ISO8859-1"
fontsize="28.0" font="arial.ttf" horizontal-alignment="left"
vertical-alignment="bottom" left-margin="60" right-margin="60"
top-margin="20" bottom-margin="30" subtitle-fps="25"
movie-fps="25" movie-width="720" movie-height="574"
/>
</stream>
</subpictures>



how i know this? i'm working on the same sort of program

:D

avih
23rd June 2004, 14:44
Originally posted by P0l1m0rph1c
Sure there are. But i dunno no program that can actually do that via CLI, since we need that being run from our app, automatically.

Anyway, i don't think that would be the best solution.

well, i'm sure imagemagic is able to do that.. that's quite a robust cli suite. and u can probably make a small executable that links to it as a lib...

LB
24th June 2004, 20:23
There is an interesting program which will do what you want, and I becha will never guess the name of it... No it's not rumplestiltskon, but rather it's called Hypersnap. :eek: Hypersnap will do that?! Yes it will.

It is actually has a command-line ability, and it can convert almost any image type. Here are a few filetypes:

bmp, gif, jpg, tif, cmp, cal, fax, eps, img, raw, ica, pict, mac, msp, pcx, ras, tga, wfx, vfm, wpg, png

at these colordepths:

:c1, :c4, :c8, :c24, :c32

So, your conversion command line would be:

hprsnap5.exe -open:test.png -save:png:c4 test2.png

marcellus
24th June 2004, 22:04
Sure there are. But i dunno no program that can actually do that via CLI, since we need that being run from our app, automatically.
Hi, try irfanview, it's free and it has a pretty complex set of operations that it can do via CLI, including converting from one bit depth to another.

SLider3
26th June 2004, 21:06
why render the subs, spumux can handle textbased subs too
Yeah, we knew that! but the rendering it makes, sucks ... and that's why we want to find another way to render the subtitles.

We are using spumux to mux the subtitles in the program MPEG2 stream. spumux accepts both PNG and BMP, but they must be 4bpp (and <16 colors).
Well, in fact it seems that the BMP/PNG must have a maxium of 4 colors. And when we convert the images created via avisynth to 2bpp images, the subtitles rendered don't look so good any more :(

there are two options: either we (with your help) find a way of writing 4bpp PNG's directly from the script, or we just find another way to render the subtitles.
What do you tell me about this? There is a way to write 2bpp (not 4bpp as he said) PNG's directly from the script? Or, do you know another way to render the subtitles? :confused:

Thanks.