Examples :: Apply a swap transition

This script demonstrates basic use of AVSLib's filters. The example script applies a vertical in-to-out swap transition between a still photo and a clip. In order to fit things together other filters (resizing, editing and utility) are also used.

First the script:

LoadModule("avslib", "filters", "edit")
LoadModule("avslib", "filters", "resize")
LoadModule("avslib", "filters", "animate")
LoadModule("avslib", "filters", "utility")

# load a clip and a photo; convert photo to match clp

clpname = "story.avi"
phoname = "photo.jpg"

clp = AVISource(clpname)
ovlap = Round(clp.Framerate / 5)

pho = ImageSource(phoname, start=0, end=2*ovlap-1)
pho = pho.AssumeFPS(clp.Framerate)
pho = pho.ResizeToTarget(clp)  # this, coded as is, will do a bilinear resize
pho = pho.ConvertToTarget(clp)
pho = pho.AudioDub(clp)

# create a vertical from-center-to-outside swap transition
# for this we only need to animate size

ph1 = pho.EditTrim(0, ovlap).Amplify(0)
ph2 = pho.EditTrim(ovlap)

black = ph2.BlankClip(color=color_black)
white = ph2.BlankClip(color=color_white)

tmask = LineAnim(black, white, w_start=2, w_end=clp.Width).ScaleToPC()

# add ovlap frames of the stil photo length at the begining

return EditJoin(ph1, \
	Overlay(ph2, clp.EditTrim(0, ovlap), mask=tmask), \
	clp.EditTrim(ovlap), \

The script loads an image and converts it to a clip with the same properties as the base story clip. Then it animates a white over a black mask to create the swap effect and finally combines the parts with EditJoin.