Tip:
Highlight text to annotate it
X
Go ahead.
Let's take care of our function, we call MOTION.
Its purpose is to calculate the size and position
of the clip overlapped on the background will then provide
the values to be entered in the LAYER command .
I actually found this function on the web.
and I've adapted to this script as it works really well.
Remember that among the arguments that will use,
when it comes to pixels, the values must be integers.
Then each numeric variable will be preceded by INT function
which round off the value to the nearest whole number.
The first argument produces a video clip from the background and call it BG_F.
The second argument indicates the clips to overlap, we will call CLIP_F.
ALPHA is opacity. This subject requires integers.
X indicates the horizontal position.
Y the vertical position.
W is width and H is the height of the clip.
Now start the body of the function with the opening brace.
Even here we use the functions WIDTH and HEIGHT
and we have to specify which refer to the clip.
HEIGHT value includes the reflected image
but we must respect the proportions, then divide it by two.
Convert W and H sizes in percentages.
Write this line that calculates the ratio between real clip width and W value.
which varies during the animation.
But since the clip size must be at least 4 pixels, set some conditions:
In this line we set the W minimum value to 4
use the conditional operator consists of
QUESTION MARK and COLON, similar to the IF THEN in Basic.
If the result of the previous line W is less than 4,
W is brought to 4 otherwise remains valid result.
repeat for H.
Now we create a correspondence between the position
declared by X and Y and dimensions W and H.
We must ensure that while the clip size increase
it remain centered respect to the starting position as in a zoom
and with the optical illusion that move near to the horizontal plane.
In AviSynth the position in the video frame is calculated
using as a reference the top left corner,
then inserting two fixed values we obtain
that during the animation clip size will be increase
without moving in the horizontal and vertical space,
as if it were anchored in one spot.
If instead for every increment of W and H subtract it's half value to X and Y
the clip will move to the left and upward,
but the movement will be offset by its size and the result is what we want.
The minimum height and width must be 4 pixels
therefore we have conditioned W and H but will always be visible
even at the beginning of the sequence, but is more effective a gradual appearing.
There is already a filter to do this, but its variants FADEIN and FADEOUT
fade away into a selectable color while the gradient
in this case must be the complete transparency.
LAYER among its parameters has also opacity.
We use one of the variables that increase, for example H
and write a few lines to determine the transparency.
H multiplied for 2 accelerates the transition from 0 to 255 and the second line
determines the maximum value to 255, as we have seen before.
Now create the clip that will be overlap by the background.
Color space must be RGB32 as explained above
add RESIZE with W and H variables and the LOOP filter
that allows us to use clips of various durations
without running the risk that one end before the other.
LOOP has some variables set with integers.
TIMES controls how many times the loop is repeated,
the default value is -1 which is equal to infinite.
START and END FRAME FRAME indicates the movie segment
we want to be looped by default is the whole movie.
Limit ourselves to use the filter with its default values
so write LOOP parenthesis opened and closed.
Declare LAYER so that it uses the other variables of this function.
BG_F is the background
CLIP_F is the video
ADD is the operator
ALPHA corresponds to opacity
X and Y are the variables of the clip position in the background.
Now the function is over, we close the body with the brace
We're almost done.
Now we have finally become the scene dynamic and do it with the ANIMATE filter
This filter checks the values of its arguments for a defined number of frames
and applies them to the filter called inside.
This is the syntax.
You can also write well.
and is the form we will use.
START FRAME indicates the initial frame
END FRAME indicates the final frame.
From the next frame the filter does not work anymore.
STRING FILTERNAME call the filter that will be applied the argument values,
in our case the MOTION.
START_ARGS: the arguments must have an initial value
END_ARGS: the final values that the arguments must reach
Declare a new variable, L, that initially load the background image.
Apply ANIMATE.
Insert the filter action field .
START is the starting frame and was defined at the beginning of the script as TC.
TC represents the number of frames compared to the animation lenght.
Call the function we created, MOTION.
Specify what it must be applied.
Since the function performs the layer filter must specify both the background
and the overlapped clip and arguments that come into play with the animation.
OP corresponds to opacity then take the alpha value in MOTION function.
In this regard it's better to specify that the variables declared in the defined function
can also have the same name as the external variables
since will be considered only within the function
then we could repeat the same name for the same arguments.
Moving on.
After OP we see X1.
This variable refers to the initial horizontal clip position.
Y is the reference vertical position,
is the intersection point between the planes that we have see at the beginning.
The clips should never be positioned above this point
which is also the vertical starting position.
Now define the initial size. We begin with two zero.
In reality will be at least 4 both vertically and horizontally
since in MOTION we made sure that this is the minimum value
This is the first part of the ANIMATE function, are the starting points.
The second part will define the arguments end points.
X1 and Y1 are the end coordinates
while W1 and H1 are the final size expressed as a percentage.
For example, if W1 is 20, the width will be 20% of the horizontal clip resolution
The same applies to the height.
Repeat for each clip.
To make the script easily editable, the starting and ending frames of ANIMATE
refer to the variable declared in the beginning, TC,
but nothing prevents to insert the values as desired.
So also to increase the number of videos just add CLIP sections
and a corresponding number of ANIMATE line.
In this example, I added a border of 2 pixels, with the filter AddBorders.
Script is finished, add the calling line RETURN L
and save it with the AVS extension.
This is the final result.
Actually exist filters that perform this function
and the script could be simplified in some passages,
but I preferred this method to be able to explain more possible arguments
The tutorial is over
I hope that was clear, comprehensive and useful.
Thanks for the time that you have dedicated.