Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 11th September 2010, 20:01   #1  |  Link
McDanGeo
Registered User
 
Join Date: Sep 2010
Location: Arkansas U.S.A.
Posts: 1
Frame number variable

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

Last edited by McDanGeo; 11th September 2010 at 20:35. Reason: added code attempts
McDanGeo is offline   Reply With Quote
Old 11th September 2010, 22:57   #2  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Moved to separate thread.
Wilbert is offline   Reply With Quote
Old 11th September 2010, 23:32   #3  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
@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.

When using functions like 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 is a bit of a pain in this regard because any named arguments belong to Animate not the filter being animated.

To get around this issue you can define a user function to feed to Animate so that all the other argument naming etc is done in the user function.

Thus to do what you want :-
Code:
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.
IanB is offline   Reply With Quote
Old 12th September 2010, 03:24   #4  |  Link
ajp_anton
Registered User
 
ajp_anton's Avatar
 
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
Alternatively,

scriptclip("""subtitle("text", size=[some function of current_frame], other options)""")
ajp_anton is offline   Reply With Quote
Old 12th September 2010, 05:33   #5  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
@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.
IanB is offline   Reply With Quote
Old 12th September 2010, 13:54   #6  |  Link
ajp_anton
Registered User
 
ajp_anton's Avatar
 
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
Why is scriptclip bad?
ajp_anton is offline   Reply With Quote
Old 14th September 2010, 05:01   #7  |  Link
stickboy
AviSynth Enthusiast
 
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
Quote:
Originally Posted by ajp_anton View Post
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.
stickboy is offline   Reply With Quote
Old 16th September 2010, 20:54   #8  |  Link
zee944
Registered User
 
Join Date: Apr 2007
Posts: 240
Quote:
Originally Posted by McDanGeo View Post
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
zee944 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 23:52.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.