PDA

View Full Version : Can't use variable as function argument in AviSynth


LaVacheQuiRi
20th June 2003, 20:57
Hi everybody,

This is my first post so please go easy on me. :) I am using the "BlankClip" and "Subtitle" functions to create opening titles for my movie. I am using AviSynth 2.5.2. My intention is to replace the numerical values of the "first_frame" and "last_frame" arguments of the "Subtitle" function with variables, so I may re-assign variables at the top of my scrips rather than change the hard-coded frame numbers throughout my script. Here is an example:

content=AviSource("content.avs")
FR=content.framerate

T1D = 3 # Title 1 Duration (in seconds)
T2D = 3 # Title 2 Duration
T3D = 3 # Title 3 Duration
T4D = 3 # Title 4 Duration

T1B = 0 # Title 1 beginning frame
T1E = (T1D * FR) - 1 # Title 1 ending frame
T2B = T1E + 1 # Title 2 beginning frame
T2E = T2B + (T2D * FR) - 1 # Title 2 ending frame
T3B = T2E + 1
T3E = T3B + (T3D * FR) - 1
T4B = T3E + 1
T4E = T4B + (T4D * FR) - 1

TDAll = (T1D + T2D + T3D + T4D) * FR

BlankClip(content, 360, color=$FFFFFF) # This line works

#BlankClip(content, TDAll, color=$FFFFFF) # This line doesn't

Subtitle("test", -1, 64, 0, 89, "Times New Roman", 44, 0, $FFFFFF, 8, 0) # This line works

#Subtitle("test", -1, 64, T1B, T1E, "Times New Roman", 44, 0, $FFFFFF, 8, 0) # This line doesn't


I have assigned the variables "T1B" and "T1E" with numerical values, yet when I try to open the script with the second Subtitle line above activated, I get the following error:

Script error: Invalid arguments to function "Subtitle"

The Avisynth site is quite excellent, but it does not contain much sample code demonstrating the use of variables as function arguments. Am I doing something wrong? Any help would be greatly appreciated.

killingspree
20th June 2003, 21:10
hi and welcome to the forum :)

not all first questions are newbie questions ;) ... moving your thread to the avisynth forum!

steVe

Dark-Cracker
20th June 2003, 22:21
hi,

replace :

FR=content.framerate

by :

FR=round(content.framerate)

i think framerate return a float (or perhaps even a string) and this is not very well supported :) .
here is how to cast value for avisynth.
http://www.avisynth.org/index.php?page=ScriptFunctions


Ps: welcome :)

Bye.

LaVacheQuiRi
21st June 2003, 00:16
Thank you Dark-Cracker, that works marvelously. I should be back next week with some new questions. :D