User:Gzarkadas/Language elements

From Avisynth

Jump to: navigation, search

[edit] this page may not be needed; will know after finishing Grammar

variables

types

operators

control structures

functions


The functions in AviSynth's scripting language are, by and large, video filters. Although a function can return any type it chooses (this is a useful feature for creating utility code to reuse in scripts; you can define your own script functions) functions which do not return a clip are always limited to intermediate processing of variables to pass as arguments to filters (functions that do return a clip). The script should always return a clip as its final value. After all, AviSynth is a video processing application.

Functions can take up to sixty arguments (hope that's enough), and the return value can be of any type supported by the scripting language (clip, int, float, bool, string). Functions always produce a new value and never modify an existing one. What that means is that all arguments to a function are passed "by value" and not "by reference"; in order to alter a variable's value in AviSynth script language you must assign to it a new value.

To see the syntax of the function call for each built-in filter, view the internal filters. There are also built-in internal functions that perform common operations on non-clip variables.

Args is a list of function arguments separated by commas. The list can be empty. Each argument must be a text string, an integer, a floating-point number, a boolean value or a video clip (that is, an expression). If the filter function expects a video clip as its first argument, and that argument is not supplied, then the clip in the special last variable will be used.

AviSynth filters can take named arguments. The named arguments can be specified in any order, and the filter will choose default values for any that you leave off. This makes certain filters much easier to use. For example, you can now write Subtitle("Hello, World!", text_color=$00FF00, x=100, y=200) instead of Subtitle("Hello, World!", 100, 200, 0, 999999, "Arial", 24, $00FF00). Colors can be specified in hexadecimal as in the example above or in decimal. In both cases it should be specified as RGB value, even if the clip itself is YUV.

You can also make function calls without parentheses, e.g. FilterName arg1, arg2. The primary reason for this is to retain compatibility with old scripts. However, it's sometimes convenient to leave off the parentheses when there's no possibility of confusion.

Personal tools