Log in

View Full Version : Problem with variable use and ScriptClip


Bernardd
16th February 2014, 15:51
Hello,
I have problem with variable use and ScriptClip.
For example, this script is ok

AVISource("C:\something.avi")
ScriptClip("ColorYuv(gain_y=myvar)", show=false, after_frame=false)
ConditionalReader("Try file.txt", "myvar", false)

with Try file.txt like this
Type int
Default 12
R 45 300 45
2 0
72 13

But this script is no good. I get "Script Error : invalid arguments to function "RemoveDirtMC" ([ScriptClip], line 1)"

AVISource("C:\something.avi")
ScriptClip("RemoveDirtMc(limit=myvar)", show=false, after_frame=false)
ConditionalReader("Essai file.txt", "myvar", false)

with the same Try file.txt and John Meyer's RemoveDirtMC function, copied below

#REMOVE DIRT FUNCTION
#......................................................................................................................................................................
function RemoveDirt(clip input, int limit, bool _grey)
{
clensed=input.Clense(grey=_grey, cache=4)
alt=input.RemoveGrain(2)
return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,dmode=2,debug=false,noise=limit,noisy=4, grey=_grey)

# Alternative settings
# return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=4,cthreshold=6, gmthreshold=40,dist=1,dmode=2,debug=false,noise=limit,noisy=12,grey=_grey,show=true)
# return RestoreMotionBlocks(clensed,input,alternative=alt,pthreshold=6,cthreshold=8, gmthreshold=40,dist=3,tolerance= 12,dmode=2,debug=false,noise=limit,noisy=12,grey=_grey,show=false)
}

function RemoveDirtMC(clip,int limit, bool "_grey")
{
_grey=default(_grey, false)
limit = default(limit,6)
i=MSuper(clip,pel=2)
bvec = MAnalyse(i,isb=false, blksize=8, delta=1, truemotion=true,dct=0)
fvec = MAnalyse(i,isb=true, blksize=8, delta=1, truemotion=true,dct=0)
backw = MFlow(clip,i,bvec)
forw = MFlow(clip,i,fvec)
clp=interleave(backw,clip,forw)
clp=clp.RemoveDirt(limit,_grey)
clp=clp.SelectEvery(3,1)
return clp
}

I do not understand the error. I have tried without success to write global before limit defintion in RemoveDirtMC function.

Thanks for help.

Gavino
16th February 2014, 17:58
The problem is that the argument 'limit' is declared as mandatory, and so cannot be supplied by name.

You can change the call to:
ScriptClip("RemoveDirtMc(myvar)", show=false, after_frame=false)

Since the function actually has a built-in default value, an alternative is to change the function declaration to make limit optional (which was probably the intent):
function RemoveDirtMC(clip,int "limit", bool "_grey")

Bernardd
16th February 2014, 19:47
Gavino,

Thousand thanks for this quick answer.

The little function script modification (two quotes) is perfect.

But with your function call proposal, i get this error "Script error : Invalid arguments to function MSUPER, RemoveDirtMC line 18". Thus it is necessary to declare now the clip to process like this ScriptClip("removedirtMc(last, myvar)", show=false, after_frame=false) or to indicate the arguments for myvar like this ScriptClip("removedirtMc(limit=myvar)", show=false, after_frame=false).

With your help, my problem is solved.

Thanks

Gavino
16th February 2014, 20:29
Thus it is necessary to declare now the clip to process like this ScriptClip("removedirtMc(last, myvar)", show=false, after_frame=false) ...
That's because of another oddness I have just noticed in the original function declaration - the type of the 'clip' argument is missing, so implicit 'last' does not work.

Change it to:
function RemoveDirtMC(clip clip, int "limit", bool "_grey")

Bernardd
16th February 2014, 21:35
Perfect !
The RemoveDirtMC script is now in accordance with ScriptClip use.
Thousand thanks.

Bernardd
17th February 2014, 15:21
Hello,

Only for information because i have one issue.

This script with RemoveDirtMC function Gavino mod do not work with lasted mvtools2.dll library
AVISource("C:\your_vido.avi")
ScriptClip("removedirtMc(myvar)", show=false, after_frame=false)
ConditionalReader("Try file.txt", "myvar", false)

My computer run wit Vista x86. I have tried without succes this script with 2.5.11.2 or 2.5.11.3 version of mvtools2.dll, with 2.6.0 Alpha 5 [130918] or 2.6 MT 2013.03.09 version of avisynth.dll.
I get error like this "WindowsError: exception: access violation reading 0x08EAEC2F"

But this script is OK with 2.5.11.0 version of mvtools2. I hope this new can help somebody.