PDA

View Full Version : Avisynth Functions


paddycook
24th August 2003, 21:55
Hi,

I'm a newbie, so apologies if this is a stupid question.

I'd like to create functions to cut down the amount of code I rewrite. I've no coding experience, however, and The Avisynth FAQ, whilst including some useful examples of functions, doesn't say how one constructs a basic function i.e. is it saved as a named .avs script and referred to that way, does it have its own extension, is it compiled etc. Could anyone give me a really simple explanation?

Thanks

stickboy
25th August 2003, 01:56
You can put the function definition anywhere in your script:

function Invert(clip c)
{
return c.Levels(0, 1.0, 255, 255, 0)
}

AVISource("foo.avi")
Invert()

Alternatively, you can put it in a separate file and then use Import("scriptname.avs") to include that script into the current one.
Import("myfunctions.avs")

AVISource("foo.avi")
Invert()
The Import command acts as if it copies and pastes one script into the other. This has the benefit of not needing multiple copies of the same function across multiple scripts.

If you put your function definition in a script with the .avsi extension and put that script into your plug-ins directory, Avisynth will import it automatically.

paddycook
25th August 2003, 22:01
Thanks!