Examples :: Create a simple movie intro clip

This script demonstrates the use of the FilterVarChainfilter, which allows to easily chain arbitrary invocations of a filter with varying arguments. The example creates a simple movie intro clip containing a group of subtitles that appear in consecutive frames (thus the filter that is chained is SubTitle). The intro clip is then joined with the main clip.

First the script:

LoadModule("avslib", "filters", "utility")

# load a clip (640x480)

clp = AVISource("script.avi")

# 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"

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

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

In order to call the FilterVarChain filter, two arrays must be constructed:

  1. The first (sub_ttl in the example) contains the argument lists of each different filter invocation, exactly as they would be written in an Avisynth script, each on a single line. It is thus a multiline string, a choice that was made to ease both its readability and its creation.
  2. The second (sub_tms in the example) contains the number of times that the filter will be called with the arguments' settings of each line of the 1st array. Thus, in the example above each subtitle line is called exactly once.

For more simple cases, where a single group of settings need to be applied many times, the use of FilterChain filter is recommended.