Log in

View Full Version : Frame number variable


McDanGeo
11th September 2010, 20:01
Am new to Avisynth but am enjoying it

I have looked through all of the documentation that I can find but cannot find a system variable that gives me the current frame number

I am trying to adjust the "Size" parameter of "Subtitle" to make the text expand from nothing to full size based on the frame number

These are the lines what I have tried without success:

# size=GetFrameNumber()
# scriptclip(" size=GetFrameNumber() ")
# scriptclip(" size=current_frame ")
# size=value(scriptclip(" (GetFrameNumber()) "))

Is this possible or is there another way to do this?

Thank you

Wilbert
11th September 2010, 22:57
Moved to separate thread.

IanB
11th September 2010, 23:32
@McDanGeo,

Welcome to Avisynth. Like most new users you need to shift your paradigm. Avisynth scripts specify operations on entire clips not individual frames. It takes a little while to get used to this but once your mind clicks into gear you will never look back.

Also it is more normal at Doom9 to open a new thread to ask questions like this. Using existing threads tends to get your issue ignored, as the existing title probably does not represent your issue.

The function you are looking for is Animate (http://avisynth.org/mediawiki/Animate).

When using functions like Subtitle (http://avisynth.org/mediawiki/Subtitle) which have many arguments, it is normal to use argument naming so you do not have to fill in all the default argument positions. Using Animate (http://avisynth.org/mediawiki/Animate) is a bit of a pain in this regard because any named arguments belong to Animate (http://avisynth.org/mediawiki/Animate) not the filter being animated.

To get around this issue you can define a user function to feed to Animate (http://avisynth.org/mediawiki/Animate) so that all the other argument naming etc is done in the user function.

Thus to do what you want :-Function MyTitle(Clip clip, Int mysize) {
Return clip.Subtitle("My Message", font="Arial", size=mysize, text_color=color_palegreen, first_frame=42, last_frame=1342)
}

....Source(...)

Animate(42, 342, "MyTitle", 0.125, 36.0)
Note size=0 will not work with SubTitle, so start with a small number, 0.125, instead, and use first_frame to declare which frame to start the titling.

The above example will evaluate MyTitle from frame 0 to frame 42 with 0.125 and from frame 342 to the end with 36.0. From frame 42 to frame 342 it will smoothly interpolate the argument from 0.125 upto 36.0.

Inside the MyTitle function titling will start at frame 42 and continue until frame 1342, so from frame 342 to 1342 the size will be 36.0.

ajp_anton
12th September 2010, 03:24
Alternatively,

scriptclip("""subtitle("text", size=[some function of current_frame], other options)""")

IanB
12th September 2010, 05:33
@ajp_anton,

Bad advice! Never use scriptclip() unless you have absolutely no other choice.

If you are reaching for scriptclip() or it's relations then you are probably approaching the problem from the wrong direction.

That said, sometimes scriptclip() is the only tool that will do the job, this fortunately is not one of them.

ajp_anton
12th September 2010, 13:54
Why is scriptclip bad?

stickboy
14th September 2010, 05:01
Why is scriptclip bad?It's inefficient, and it causes people to think in the wrong general mindset. It's not really very AviSynth-like.

zee944
16th September 2010, 20:54
I have looked through all of the documentation that I can find but cannot find a system variable that gives me the current frame number

I had the same problem:
http://forum.doom9.org/showthread.php?t=141883