PDA

View Full Version : Effects for Subtitles


jjones3535a
18th July 2009, 04:02
Hi,

I was wondering if there are any plugins or particular techniques for animating subtitles. Right now I'm using scripts like this:



title=BlankClip(length=25, width=640, height=480, fps=30, fps_denominator=1001, color=$000000, pixel_type="YV12", audio_rate=48000)

title=title.Animate(16,30,"Subtitle", \
"Hello Again World!",100,400,16,50,"Comic Sans MS",40,$00FF00,$000000,5,0,0,\
"Hello Again World!",320,240,16,50,"Comic Sans MS",40,$00FF00,$000000,5,0,0)

return title


to create an Animated Subtitle on my clips. This works well, but I was wondering if there was a plugin or better technique. Basically, I'd like to be able to create a variety of Subtitle animations/effects, for example I'd like to have the subtitle:
- Fly-in from left/right/top/bottom
- Scroll across bottom/top/middle
- Zoom in/out
- Spin in/out
- Fade in/out
- etc

Each of these effects could be created with a variety of techniques, but I was wondering if there was a plugin that grouped effects specifically for Subtitles. Something like the wonderful TransAll plugin for transitions.

Thanks for the help.

thewebchat
18th July 2009, 05:13
Use TextSub() and the Substation Alpha format that is apparently popular in many piracy circles. Specs (http://moodub.free.fr/video/ass-specs.doc) for the format. You want to read about \t.

jjones3535a
20th July 2009, 19:21
@thewebchat - thanks, I looked into Substation Alpha and it looks great, but seems a bit overkill for what I'm looking to do.

I also came across SubtitleEx which seems to have a few more effects/options than Subtitle, so I think that will work. However, I just had one other question. I've read the SubtitleEx docs and can't figure out a way to have a background color around by subtitle text. You can control text color and halo color but there doesn't seem to be a way to have a background color.

Does anyone know if it is possible to have a background box with SubtitleEx or is there another method for having a background area for subtitled text?

Thanks.

thewebchat
20th July 2009, 22:50
In SSA, this would be "border style opaquebox", but you could for example just draw a box to put your subtitles in using BlankClip + Overlay.

jjones3535a
21st July 2009, 04:59
thanks. I'm trying to get BlankClip + Overlay to work. Here's what I've got so far, but I'm having 2 issues:

title = BlankClip(length=50, width=Width, height=Height, fps=5)
txt="Here is some text|here is line 2|here is line 3"
title = title.subtitleex(txt,x=10,y=10,firstframe=0,lastframe=50)
bg=blankclip(length=50, width=round(title.width), height=40, color=$999999, fps=5)
Overlay(title,bg, x=0, y=0, opacity=1.0)


This creates the subtitle and a gray "background" area, however, I'm having trouble positioning the text from SubtitleEx (the x and y coordinates don't seem to work properly as the text is clipped). Also, the gray BlankClip I created covers the subtitle text. How to do properly position the text? And how to have the text on top of the gray box?

Any help or suggestions would be greatly appreciated.

Thanks.

thewebchat
21st July 2009, 05:55
I don't know about the usage of SubtitleEx, but clearly you need to overlay the box *before* you call SubtitleEx.

JohannesL
21st July 2009, 15:36
I use this for positioning the text:

x=Width()/2, y=Height()/2+(Height()/5), effects="c"

Tweak it to your likings.

I wrote this function for personal use to simplify adding subtitles with a soft shade some time ago. It might be of help somehow.


function SubExSoftShade(clip c, string "text", int "firstF", int "lastF", int "widX", int "heiY", int "SubSize", string "font")
{
last = c
Assert(defined(text), "SubExSoftShade: No text specified.")
firstF = Default(firstF,0)
lastF = Default(lastF,FrameCount())
widX = Default(widX,Width()/2)
heiY = Default(heiY,(Height()/2)+Height()/5)
SubSize = Default(SubSize,(Width()+Height())/40)
font = Default(font,"Bitstream Vera Sans")
SubtitleEx(text, x=widX, y=heiY, firstframe=firstF, lastframe=lastF, effects = "bssss,c,f(10,10)", textcolor = $20000000, halocolor = $60000000, size=SubSize, font=font)
SubtitleEx(text, x=widX-1, y=heiY-1, firstframe=firstF, lastframe=lastF, effects = "b,c,f(10,10)", textcolor = $00FFFFFF, halocolor = $FF000000, size=SubSize, font=font)
return (last)
}

jjones3535a
21st July 2009, 19:54
@JohannesL - thanks. that's a nice little function and it centers the subtitle text very well. however, I'm still struggling with getting SubtitleEx to position text the way Subtitle's Align property does. SubtitleEx has some additional features (bold, underline, built-in effects, etc) that are nice the quirky alignment is still an issue for me. I'm probably just doing something wrong.

Also, I've been able to create a background "box" around the subtitle using Overlay and BlankClip thanks to the suggestion by @thewebchat. Here's the code:


txt = "Here is some text\nhere is line 2"

title = BlankClip(length=50, width=Width, height=Height, fps=fr)
box = Blankclip(length=50, width=320, height=100, color=$999999, fps=fr)
out = Overlay(title, box, x=0, y=0, opacity=1.0)
out = out.Subtitle("Here is some text\n Here is line 2", font="Georgia", size=36, text_color=$ffffff, align=7,lsp=0)
return out


This works quite well as it places a gray box around the subtitle, but I'm looking to add one more feature. Does anyone know how to calculate the height and/or width of the subtitle text itself?

I'd like to have the background box enclose the subtitle text. Right now I'm hard coding the width=320 and height=100 bits, but it would be nice if I could calculate the Height and Width on the fly so it surrounds the text more neatly.

Any thoughts? Thanks.

thewebchat
21st July 2009, 21:02
Calculating the size of a line of text is a lot more complicated than just drawing it/applying effects. Unless you actually communicate with the font renderer/parser, it is not possible. There are some scripting frontends for Substation that add this in, but generally it's not possible.

Edit: I suppose you could hack some OCR-style code that tries to find the boundaries of the text, but good luck with that.

Gavino
21st July 2009, 21:16
Getting the exact text width is difficult unless you are using a fixed-width font. I suppose you could get a rough estimate from the number of characters and (some function of) the font size.

The text height is slightly easier, font size being a first approximation, but if you want to allow for multi-line text, you would need to scan the string to count the newlines.

Re the alignment in SubtitleEx, it only supports the equivalent of Subtitle alignment 4, 5, or 6. Left/Right alignment is requested by using +ve/-ve values of x, and center alignment by including the "c" effect.