Home
RecentChanges

Search:

» AviSynth is a powerful video FrameServer for Win32.

AviSynth Links:
»Download
»Learn to script
»FAQ
»Manual
»Discussion fora
»Project page
»External filters
»FeedBack

» You can add pages to this website immediately. No login required.
Edit this document

» AboutAviSynth

 

Avisynth 
Logo

ScriptGrammar

( Diese Seite in flag-germany.gif Deutsch )

All AviSynth scripting statements have one of these forms:

  1. variable_name = expression
  2. expression
  3. return expression
  4. end

In the first case, expression is evaluated and the result (which is always a video clip) is assigned to variable_name. In the second case, expression is evaluated and the result is assigned to the special variable last. In the third case, expression is evaluated and is used as the "return value" of the script--that is, the video clip that will be seen by the application which opens the AVS file. The fourth case is equivalent to return last.

An expression can have one of these forms:

  1. numeric_constant or string_constant
  2. variable_name or clip_property
  3. Function(args)
  4. expression.Function(args)
  5. expression1 operator expression2
  6. bool_expression ? expression1 : expression2

In the first case, the value of the expression is the value of the constant. In the second case, the values correspond to ClipProperties or ScriptVariables (which must have been previously initialized). In the third case, the value is the return value of an AVS function (see below). The fourth case is an alternate syntax (called "OOP notation") which is equivalent to Function(args, expression).

The final two cases show that one can manipulate expressions using all of the usual arithmetic and LogicalOperators (from C) as you'd expect on ints, floats, vals, and bools, as well as execute code conditionally with the ternary operator. Strings can be concatenated with '+'. The following operators are also defined on video clips: a + b is equivalent to UnalignedSplice(a, b), and a ++ b is equivalent to AlignedSplice(a, b).

The functions in AviSynth's scripting language are, by and large, video filters. (You can also define your own ScriptFunctions). Functions can take up to sixty arguments (hope that's enough), and the return value is always a clip. Functions always produce a new video clip and never modify an existing one. To see the syntax of the function call for each built-in filter, view the FiltersByCategory.

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, 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).

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.

Avisynth ignores anything from a # character to the end of that line. This can be used to add comments to a script.

Avisynth ignores case: aViSouRCe is just as good as AVISource.

Multiple Avisynth statements on a single line can only be achieved in the context of OOP notation or embedding filters as parameters of another function such as:

  AviSource("c:\video.avi").Trim(0, 499)   -or-   AudioDub(AviSource("c:\video.avi"), WavSource("c:\audio.wav"))

Avisynth statements can be split across multiple lines by placing a backslash ("\") either as the last non-space character of the line being extended, or as the first non-space character on the next line.

Line splitting examples (both valid and equal):

  Subtitle("Hello, World!", 100, 200, 0, \
    999999, "Arial", 24, $00FF00)

-or-

  Subtitle("Hello, World!", 100, 200, 0,
    \ 999999, "Arial", 24, $00FF00)

Back to AviSynthManual

SourceForge Logo

 


Edit this document | View document history
Document last modified Sun, 18 Jul 2004 08:32:16