View Full Version : Help: How to use animate function
jinkazuya
17th October 2010, 01:06
I am just wondering how to use the animate function or filter...Because I have been to the avisynth wiki...But the info there is kind of vague. The guide does not really explain what arguments are supposed to be within the animate function.
For instance, this is the filter or function:
AVISource("D:\video\jack.avi")
Animate(0,100,"subtitle","Little Jack's",-1000,500,0,150,"Arial",
\ 1000,$FF0000,"Little Jack's",70,300,0,150,"Arial",60,$FF0000)
I know the starting frame is 0 and the ending frame is 100, and then the filter to use here is subtitle, but it is possible to use some other filters so questions:
1. How do the filters affect the animate function. The case here is subtitle, what does it do really and what is the difference between using subtitle and crop?
2) What are those numbers after the string(subtitlte) "little jack's". That's -1000,500,0,150,"Arial",
\ 1000,$FF0000,"Little Jack's",70,300,0,150,"Arial",60,$FF0000)
and what are they really and what do they do? Usually the arguments or parameter does really state what needed to be supplied to them in order for the function to work correctly but here the animate function does not.
Gavino
17th October 2010, 09:30
The example uses Subtitle, but Animate can be applied to any filter or function. You use it when you want a filter's parameters to change smoothly over a range of frames.
Animate (http://avisynth.org/mediawiki/Animate)(clip clip, int start_frame, int end_frame, string filtername, start_args, end_args)
start_frame and end_frame define the range over which the arguments (parameters) to filtername will be varied.
start_args here stands for a list of arguments, which are the ones to be applied at start_frame. Similarly end_args is the list of arguments to be used at end_frame. In between start_frame and end_frame, the arguments change from their starting value to their final value in a linear way.
In the example,
Animate(0,100,"subtitle",
\ "Little Jack's",-1000,500,0,150,"Arial", 1000,$FF0000,
\ "Little Jack's",70,300,0,150,"Arial",60,$FF0000)
you have to look at the documentation for Subtitle (http://avisynth.org/mediawiki/Subtitle) to understand the arguments. Here the subtitle position is being varied from (-1000, 500) to (70, 300) and its size from 1000 to 60, giving the effect of a moving and shrinking title.
jinkazuya
17th October 2010, 09:54
I understand the how the subtitles work and its arguments and in fact I am using it for quite some times but as for animate, it is a bit complicated to understand
So when you mean the position, did you mean the X and Y coordinates?
And what I do not really understand here is 10000 to 60, does it mean the size of the FONT?
Anyway, the arguments of subtitles have more than that, and it also supplies halo_color, spc, align and so on...
Would you please give me an example of the text rolling from right to left and when the text reaches to the edge of the video, it will be cropped and just like the rolling text that is usually seen on commercial TV?
Gavino
17th October 2010, 10:18
So when you mean the position, did you mean the X and Y coordinates?
Yes.
And what I do not really understand here is 10000 to 60, does it mean the size of the FONT?
Yes, it's the argument called size in the Subtitle docs.
Anyway, the arguments of subtitles have more than that, and it also supplies halo_color, spc, align and so on...
That's true, but all these arguments are optional, so you can stop at the last non-default value you need. Since start_args and end_args must both have the same number of arguments, Animate can figure out where the boundary between them is.
Would you please give me an example of the text rolling from right to left and when the text reaches to the edge of the video, it will be cropped and just like the rolling text that is usually seen on commercial TV?
Animate(0,100,"Subtitle",
\ "rolling text",400,500,0,100,
\ "rolling text",-200,500,0,100)
jinkazuya
17th October 2010, 10:25
Here is the syntax or statements, but I did not see the text.
video = blankclip()
Animate(video,0,100,"Subtitle",
\ "rolling text",400,500,0,100,
\ "rolling text",-200,500,0,100)
Also, it is possible to use something like the named argument such as
Animate(video, 0, 100, "Subtitle", x = 400...)?
also btw
what is 0 and 100 here?
Animate(0,100,"subtitle",
\ "Little Jack's",-1000,500,0,150,"Arial", 1000,$FF0000,
\ "Little Jack's",70,300,0,150,"Arial",60,$FF0000)
what is 0 and 150 here?
Gavino
17th October 2010, 10:53
You didn't see the text because BlankClip produces a 640x480 clip by default, and I had used y=500 in the example - the text ended up off the bottom of the screen. You can change 500 to 300, for example.
0 and 100 (and 0 and 150 in the earlier example) are the first_frame and last_frame arguments to Subtitle.
In the earlier example, the title stops moving at frame 100 (Animate's end_frame) but continues to be displayed until frame 150 (Subtitle's last_frame). Note that Animate applies the filter (here Subtitle) to the whole clip - frames before start_frame use arguments from start_args and frames after end_frame use arguments from end_args, so in the example the animation ends at frame 100 but the title continues to be displayed until frame 150.
Unfortunately, Animate does not support named arguments for the filter.
jinkazuya
17th October 2010, 15:21
Thanks a lot and it works...But there was some flickering when the text scrolled across the screen...
last but not least,
Animate(0,100,"Subtitle",
\ "rolling text",400,500,0,100,
\ "rolling text",-200,500,0,100)
As you can see, there are two 0, 100 frames of the rolling text. I am just wondering what the difference is between them? Because I tried modifying the end frame of the first \ "rolling text",400,500,0,100, and there seemed that nothing being affected. What affected the rolling text is the second \ "rolling text",-200,500,0,100) after I modified the ending_frame value of it. So I really wanna know more about this.
Besides, do we really have to use the slash to separate the line of the filter "Subtitles from the rest of the text?
By the way, is it possible to combine fade in and fade out effects with subtitle filter by using animate function?
This is what I really want to do...
I would like to have the text always stay on the top part of the video. No matter how big or small the video is, the text always gotta stay within range. Before starting the animation, I would like the text to fade in from the right side edge of the video and then fade out at the other end(left side) of the video and this will continues for 15 seconds.
Gavino
17th October 2010, 22:50
The first (0, 100) after "rolling text" represents the first and last frames for Subtitle() at the start of the animation, while the second (0, 100) gives the values at the end of the animation. Normally you would use the same pair of values in both the start and end arguments, as you don't want them to vary during the animation. In this example, it also happens that the animation itself runs from frame 0 to 100, but this need not be the same if you want the subtitle also to be shown before or after the animation part, as the earlier "Little Jack's" example showed.
The slash is not necessary - I just used it in the example to distinguish the start and end arguments.
It is possible to fade subtitles in and out with Animate, but you might find it simpler to use the SubtitleEx (http://avisynth.org/mediawiki/External_filters#Subtitling) plugin, which supports fading, motion and other effects.
jinkazuya
18th October 2010, 02:19
blankclip().loop().Animate(0,200,"subtitle", "Hello World!",351,200,0,0,"Arial",10,$FF0000,$00FF00, "Hello
World!",0,200,200,200,"Arial",10,$FF0000,$00FF00)
I am just wondering how can I get the text rolling for five second with fade in and fade out effect. I really appreciate it if I could get a script for this.
Gavino
18th October 2010, 09:22
You can do a fade with Subtitle by varying the text opacity with Animate. However, since the opacity is not a separate argument (it is combined as an alpha with the text colour), you need to write a wrapper function and apply Animate to that instead, eg
function MyTitle(clip c, string text, int "x", int "y", int "first_frame", int "last_frame",
\ int "opacity", int "text_color", int "halo_color") {
opacity = Default(opacity, 255)
transparency = (255-opacity)*$01000000
text_color = transparency + Default(text_color, $FFFF00)
halo_color = transparency + Default(halo_color, 0)
Subtitle(c, text, x, y, first_frame, last_frame, text_color=text_color, halo_color=halo_color)
}
(I have left out the less-used Subtitle arguments. You can add them in if you need them.)
A fade-in can then be achieved by varying the opacity from 0 to 255, eg
Animate(0, 25, "MyTitle", "Hello", 100, 100, 0, 25, 0, "Hello", 100, 100, 0, 25, 255)
Similarly a fade-out would vary the opacity from 255 to 0.
To do both a fade-in and out you would need to call Animate twice and splice the results together.
Of course, you can also combine movement with a fade by varying x and/or y as well.
jinkazuya
18th October 2010, 14:44
Well...This is rather confusing. In C++ or C#, when you supply all the arguments to the function, you have an option - whether to use them or not, which is up to you. However, if you don't use the arguments, you are issued a warning message. However, in avisynth, there is not such a thing.
Anyway, could you please explain how this works because I tried your script, and it just told me that there was no return value.
Besides aren't we supposed to return subtitle in order to use MyTitle in the animate filter? Besides, in C language if the variable is unassigned, it is not allowed to be used but here
text_color = transparency + Default(text_color, $FFFF00)
text_color is unassigned, but it can be used. This really confuses me. Hope you could help.
Gavino
18th October 2010, 16:09
Well...This is rather confusing. In C++ or C#, when you supply all the arguments to the function, you have an option - whether to use them or not, which is up to you. However, if you don't use the arguments, you are issued a warning message. However, in avisynth, there is not such a thing.
Avisynth does not check for unused arguments or variables. Indeed, there is no way to issue a warning message anyway (only errors).
Anyway, could you please explain how this works because I tried your script, and it just told me that there was no return value.
I only showed the function, not the complete script. You need something like:
function MyTitle(...) {
...
}
... # source filter, eg AviSource(...)
Animate(0, 25, "MyTitle", "Hello", 100, 100, 0, 25, 0, "Hello", 100, 100, 0, 25, 255)
Besides aren't we supposed to return subtitle in order to use MyTitle in the animate filter? Besides, in C language if the variable is unassigned, it is not allowed to be used but here
text_color = transparency + Default(text_color, $FFFF00)
text_color is unassigned, but it can be used.
The word 'return' is optional before the last expression in a function.
If text_color is not passed to the function, it is given a 'void' value, which can be tested for by the Default() function.
See http://avisynth.org/mediawiki/User_defined_script_functions
jinkazuya
19th October 2010, 03:51
So how can I keep it continuously looping for about 5 to 10 seconds? I really hope there would be a script like this. In additional, I did not really see the fade in and fade out effect...Is something wrong?
The scrolling text should have the blending fade in and out effect and that would be awesome. I think I have to pick up some lessons on avisynth because this is the language that's expanding each day so it is a bit hard to learn.
Gavino
19th October 2010, 10:19
The opacity feature of Subtitle was introduced in Avisynth 2.58 - perhaps you are using an earlier version? (Use Version (http://avisynth.org/mediawiki/Version)() if you are not sure.) Or perhaps the fade was just too fast for you to notice.
The following script works for me (I've just tried it):
function MyTitle( ... ) { ... } # as shown earlier
BlankClip(length=120, width=400, height=300)
pt1 = Animate(0, 119, "MyTitle", "Hello", 0, 100, 0, 119, 0, "Hello", 200, 100, 0, 119, 255)
pt2 = Animate(0, 119, "MyTitle", "Hello", 200, 100, 0, 119, 255, "Hello", 360, 100, 0, 119, 0)
pt1 + pt2
It fades in a title on the left, while moving it to the right where it finally fades out.
Total length 10 secs (240 frames at 24 fps).
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.