View Full Version : GraMaMa in a Function


blazerqb11
26th August 2009, 14:41
I can't seem to get GraMaMa working in a function. No matter how simple the function I always get this error:

Avisynth open failure:
Script error: Invalid arguments to function "Gramama"

Here is the simplest function I could think of using GraMaMa in order to rule out as many other possible problems as I could. Can anyone tell me what I'm doing wrong?

Function circle(clip video1, clip video2)
{
overlay( video1, video2, mask=Gramama(1,100,100,20, binarize=true) )
}

circle( Trim(0,100), Trim(200,300) )


By the way, the follow code which is not a function, but in my understand does the exact same thing as the previous function should, works with no problems:

video1 = Trim(0,100)

video2 = Trim(200,300)

overlay( video1, video2, mask=Gramama(1,100,100,20, binarize=true) )

I'm basically just using GraMaMa to make a circular mask, so alternatively, if anyone knows of another function that I could use to achieve the same effect, let me know.

Didée
26th August 2009, 15:18
Here's your function again, just with >inherent "last"< made visible:

Function circle(clip video1, clip video2)
{
[last]
overlay( video1, video2, mask=[last].Gramama(1,100,100,20, binarize=true) )
}

See? You either need to pass a base clip as argument to GraMaMa (variant A), or make sure that "inherent last" is defined (variant B).

Variant (A):
Function circle(clip video1, clip video2)
{
overlay( video1, video2, mask=video1.Gramama(1,100,100,20, binarize=true) )
}

Variant (B):
Function circle(clip video1, clip video2)
{
video1
overlay( video1, video2, mask=Gramama(1,100,100,20, binarize=true) )
}

AVIL
26th August 2009, 15:23
Hi,

In the example that works (i.e. the second) there are three clips involved: video1, video2 and last, wich is the clip trimmed to form video1 and video2. This clip is implicit and invisible but exists. In the example in the function form, last clip is not transmitted (there isn't such clip at function evaluation). So the scripts fails.

Try this:

Function circle(clip original, clip video1, clip video2)
{
overlay( video1, video2, mask=original.Gramama(1,100,100,20, binarize=true) )
}

circle( last, last.Trim(0,100), last.Trim(200,300) )

Good luck

blazerqb11
26th August 2009, 16:33
Hey, thanks everyone. I got my function working. I guess for I didn't realize that GraMaMa needed a clip as an argument because in all my working examples it was using "last".