Current version

v1.10.4 (stable)

Navigation

Main page
Archived news
Downloads
Documentation
   Capture
   Compiling
   Processing
   Crashes
Features
Filters
Plugin SDK
Knowledge base
Contact info
Forum
 
Other projects
   Altirra

Search

Archives

01 Dec - 31 Dec 2013
01 Oct - 31 Oct 2013
01 Aug - 31 Aug 2013
01 May - 31 May 2013
01 Mar - 31 Mar 2013
01 Feb - 29 Feb 2013
01 Dec - 31 Dec 2012
01 Nov - 30 Nov 2012
01 Oct - 31 Oct 2012
01 Sep - 30 Sep 2012
01 Aug - 31 Aug 2012
01 June - 30 June 2012
01 May - 31 May 2012
01 Apr - 30 Apr 2012
01 Dec - 31 Dec 2011
01 Nov - 30 Nov 2011
01 Oct - 31 Oct 2011
01 Sep - 30 Sep 2011
01 Aug - 31 Aug 2011
01 Jul - 31 Jul 2011
01 June - 30 June 2011
01 May - 31 May 2011
01 Apr - 30 Apr 2011
01 Mar - 31 Mar 2011
01 Feb - 29 Feb 2011
01 Jan - 31 Jan 2011
01 Dec - 31 Dec 2010
01 Nov - 30 Nov 2010
01 Oct - 31 Oct 2010
01 Sep - 30 Sep 2010
01 Aug - 31 Aug 2010
01 Jul - 31 Jul 2010
01 June - 30 June 2010
01 May - 31 May 2010
01 Apr - 30 Apr 2010
01 Mar - 31 Mar 2010
01 Feb - 29 Feb 2010
01 Jan - 31 Jan 2010
01 Dec - 31 Dec 2009
01 Nov - 30 Nov 2009
01 Oct - 31 Oct 2009
01 Sep - 30 Sep 2009
01 Aug - 31 Aug 2009
01 Jul - 31 Jul 2009
01 June - 30 June 2009
01 May - 31 May 2009
01 Apr - 30 Apr 2009
01 Mar - 31 Mar 2009
01 Feb - 29 Feb 2009
01 Jan - 31 Jan 2009
01 Dec - 31 Dec 2008
01 Nov - 30 Nov 2008
01 Oct - 31 Oct 2008
01 Sep - 30 Sep 2008
01 Aug - 31 Aug 2008
01 Jul - 31 Jul 2008
01 June - 30 June 2008
01 May - 31 May 2008
01 Apr - 30 Apr 2008
01 Mar - 31 Mar 2008
01 Feb - 29 Feb 2008
01 Jan - 31 Jan 2008
01 Dec - 31 Dec 2007
01 Nov - 30 Nov 2007
01 Oct - 31 Oct 2007
01 Sep - 30 Sep 2007
01 Aug - 31 Aug 2007
01 Jul - 31 Jul 2007
01 June - 30 June 2007
01 May - 31 May 2007
01 Apr - 30 Apr 2007
01 Mar - 31 Mar 2007
01 Feb - 29 Feb 2007
01 Jan - 31 Jan 2007
01 Dec - 31 Dec 2006
01 Nov - 30 Nov 2006
01 Oct - 31 Oct 2006
01 Sep - 30 Sep 2006
01 Aug - 31 Aug 2006
01 Jul - 31 Jul 2006
01 June - 30 June 2006
01 May - 31 May 2006
01 Apr - 30 Apr 2006
01 Mar - 31 Mar 2006
01 Feb - 29 Feb 2006
01 Jan - 31 Jan 2006
01 Dec - 31 Dec 2005
01 Nov - 30 Nov 2005
01 Oct - 31 Oct 2005
01 Sep - 30 Sep 2005
01 Aug - 31 Aug 2005
01 Jul - 31 Jul 2005
01 June - 30 June 2005
01 May - 31 May 2005
01 Apr - 30 Apr 2005
01 Mar - 31 Mar 2005
01 Feb - 29 Feb 2005
01 Jan - 31 Jan 2005
01 Dec - 31 Dec 2004
01 Nov - 30 Nov 2004
01 Oct - 31 Oct 2004
01 Sep - 30 Sep 2004
01 Aug - 31 Aug 2004

Stuff

Powered by Pivot  
XML: RSS feed 
XML: Atom feed 

§ The "subtitler" filter, screen size, and font encodings

I don't remember why I originally wrote the subtitling filter. I'd like to say it was because I fansubbed some anime, but my Japanese skills are extremely minimal and my access to unsubtitled anime even less, so that couldn't have been it. I think it may have actually just been to display some on-screen lyrics to music -- probably Yuzurenai Negai from the Magic Knight Rayearth opening. Or something like that.

The two most common questions I get about the subtitler filter I wrote are:

Fortunately, both of these are easy to fix.

Why are my font sizes and border widths screwed up?

This generally happens due to a missing or mis-set "PlayResY:" statement at the top of the file:

Title: VirtualDub 'subtitler' filter demonstration
Original Script: Avery Lee
ScriptType: v4.00
Collisions: Normal
PlayResY: 240
PlayDepth: 0
Timer: 100.0000

This field indicates the vertical height of the subtitling screen. Sub Station Alpha was meant to be used with a genlock, so it displayed your subtitles at desktop resolution and the entire screen was overlaid on top of the incoming video. Unfortunately, all of the sizes in an SSA script are in pixels, so the size of the screen is relevant; SSA stores the height of the screen in the PlayResY field.

The subtitler filter assumes that you want to subtitle your video as though it were a full screen, so it scales all measurements in the script to match the screen resolution in the script. For most values of PlayResY it assumes a 4:3 aspect ratio, except for 1024, where it assumes 5:4 to fit the common 1280x1024 resolution. The catch is that if the PlayResY field is altered, all values in the script will be scaled. This is probably not what you want. If you are using Sub Station Alpha, remember that it was meant to be WYSIWYG, so the width of your screen will be shrunk to the width of your video!

If the PlayResY: field is missing entirely, the subtitler simply uses the border and size fields verbatim as pixels.

Why does my foreign-language text appear garbled?

The subtitler does not assume the encoding of a font by its name. Nor should you rely on this behavior when making your scripts, even if your script creation program does so.

When a font is selected in Windows, it can either be created with a specific character set or with a generic character set, such as DEFAULT_CHARSET (1). The character set specifies the encoding used for 8-bit text that is rendered through that font. This is necessary because SSA scripts are narrow (8-bit) text and thus the text itself is not sufficient to determine the character set of the text. If you choose the wrong encoding, the OS won't know that it doesn't match, and will display missing character boxes or gibberish instead. You can tell the subtitler renderer to use a particular font by using the {/fe} override, or by setting the Encoding field of the style. The necessary values are GDI character set values and are given in the subtitler filter's README.

So what's wrong with setting encoding to 0 or 1, and letting the OS decide automatically?

First, Windows 95/98 and NT/2000/XP react differently when mapping fonts, so this may cause the script to malfunction on one of those platforms. More importantly, the font may not have a single encoding in it, or may have a different encoding on different language editions of the OS. Arial and MS Sans Serif are generic OS fonts that change on different language editions; Arial Unicode MS is a mammoth font that contains glyphs for nearly any supported language in Windows. Setting the font encoding on the style or dialogue text ensures that the script displays properly.

The third problem is that the subtitler filter works in Unicode, and thus has to know the character set beforehand instead of letting the font system do it. There are many benefits to doing this, one being that the word wrapping code is simpler because it doesn't have to worry about DBCS, and the other being that it fixes some display errors caused by accidentally interpreting follow bytes as the starts of style overrides. However, the side effect of this is that the subtitler must know the correct encoding. If you try to rely on the font system's remapping, or worse, try to use a program that intercepts GDI calls like NJWIN to display foreign language text, the subtitler filter will display trash in the video frame.

As a side note, parsing SSA scripts can be very nasty, because the text encoding can change in the middle of a line. You have to parse the text using DBCS-friendly code, but switch the character set the moment you see an {fe} tag.

I suspect there is a disconnect (bug) between the way the subtitler filter and SSA handles font encoding 0, but haven't gotten a concrete repro case for such a bug yet. If you wish to report such a bug, please give a script file with the problem that uses stock Windows XP fonts and also indicate which language edition of OS you are using.

Why don't my pictures and animations show up?

I don't have image or animation loading code in the filter. Images aren't too bad and I could probably support them, but animations are a real problem; the way SSA supported them was simply to spawn a control to play them on-screen, and that obviously doesn't work when you need the animation in a memory bitmap. Also, I'd have needed my image resampling code, which until recently was not modular. I don't plan to add support for these anytime soon because they basically amount to shoving crappy NLE support into the filter, and I have another program that would be a much better place to add that functionality *cough*.

Comments

Comments posted:


That's three questions.

Scott - 31 03 05 - 16:46


I was tired. :)

Phaeron - 31 03 05 - 23:18


one, two ... many ;)

Murmel - 05 04 05 - 13:50


"Our two main weapons are fear and surprise...and ruthless efficiency"

Ray Barker - 05 04 05 - 19:59


actualy most of the fansubs work with vobsub (with the filter textsub that add a lot of effects that the normal ssa (or ass) do not have. Some of the fansubs use after effects to (it's inclidible what we can do with that prog).

I think it's time to another one like vobsub (with some new effects ^^). I would do it myself if I knew C++ ^^ but I don't know even how to do 1 + 1... >

id - 06 04 05 - 12:46


Hey, do you have any idea what the first "digital fansub" was? I'm just curious :)

Also, when did you create the subtitler filter for vdub originally?

Tofusensei (link) - 05 05 05 - 13:42


about the virtualdubmod, i found out that i should use subtitle workshop for avi clips and then save the subtitles in SSA format to use on virtualdub, but i can't seem to find SSA anywhere, i think the original website was deleted, do you know what program i can use instead for virtual dub that'll actually stick the subtitles onto the clip and not as a separate file?

aya - 03 01 07 - 21:56


Thank You!
I love it when I get smarter! I changed a 1 to 0 (Encoding), and it solved my problem! It is amazing what a difference a single bit can make!

András - 14 02 13 - 22:43

Comment form


Please keep comments on-topic for this entry. If you have unrelated comments about VirtualDub, the forum is a better place to post them.
Name:  
Remember personal info?

Email (Optional):
Your email address is only revealed to the blog owner and is not shown to the public.
URL (Optional):
Comment: /

An authentication dialog may appear when you click Post Comment. Simply type in "post" as the user and "now" as the password. I have had to do this to stop automated comment spam.



Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.