Examples :: Create an enhanced movie intro clip

This script extends the third example, demonstrating the animation feautures of AVSLib. The script creates a movie intro clip containing a group of subtitles that appear and go in consecutive frames with fade-in and fade-out effects. In addition, subtitles are smoothed to allow a more pleasing view.

First the script:

LoadModule("avslib", "array", "core")
LoadModule("avslib", "filters", "utility")
LoadModule("avslib", "filters", "animate")

# load a clip (640x480)

clp = AVISource("script.avi").ConvertToYV12()

# create a CR/LF delimited array of Subtitle parameters (ie a multiline string)
# text, x, y, first_frame, last_frame, font, size, text_color, halo_color, align

sub_ttl = \
""" "Smiths Productions", 320, 100, 8, 240, "verdana", 28, color_antiquewhite, color_gray30, 2
"prowdly presents", 320, 140, 32, 240, "verdana", 24, color_antiquewhite, color_gray30, 2
"A John Smith Film", 320, 200, 90, 240, "verdana", 28, color_lavenderblush, color_gray30, 2
"The Family Grows", 320, 280, 150, 240, "verdana", 42, color_lightsalmon, color_gray30, 2
"Episode III", 320, 330, 174, 240, "verdana", 36, color_antiquewhite, color_gray30, 2
"Junior walks!", 320, 400, 198, 240, "verdana", 38, color_lavenderblush, color_gray30, 2"""

sub_tms = "1,1,1,1,1,1"

Function FadeSubTitle(clip c, string text, int x, int y, int fs, int fe, \
	string font, int size, int tcolor, int hcolor, int align)
	stmask = c.BlankClip().SubTitle( \
		text, x, y, fs, fe, font, size, color_white, color_gray90, align)
	stmask = stmask.Blur(1.0).ScaleToPC()
	ovl = c.SubTitle(text, x, y, fs, fe, font, size, tcolor, hcolor, align)
	frames = ArrayCreate(fs, fs + Round((fe - fs)/5), fe - Round((fe - fs)/5), fe)
	opac = "0.1,1,1,0.1"
	return PolygonAnim(c, ovl, frames, op_array=opac, mask=stmask)

ttbase = clp.BlankClip(length=241, color=color_gray10)
titles = ttbase.FilterVarChain("FadeSubTitle", sub_tms, sub_ttl)

return Dissolve(titles, ttbase.Trim(0, 20), 10) + clp

The new features introduced are contained inside the FadeSubTitle custom filter.

The filter creates a mask of the subtitle's text (with gray halo_color) that it is blured in order to make the fonts edges fade nicely into the surrounding video. The appearance and disappearance of the subtitle are also faded (in and out) with the use of the PolygonAnim filter.

As a consequence, the final result is much better than that of the third example.