Log in

View Full Version : Adding MDegrain2 to existing script


Floatingshed
23rd November 2015, 22:53
I use this a fair bit for removing film dirt:



function Dirt(clip clap,int "limit",bool "_grey")

{
LoadPlugin("C:\Program Files (x86)\Avisynth 2.5\xtraplugins\mvtools2.dll")

#_grey=false


_grey=default(_grey, false)
limit = default(limit,6)

prefiltered = RemoveGrain(clap,2)
superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)
super=MSuper(clap, hpad=32, vpad=32,pel=2)

bvec = MAnalyse(superfilt,isb=true, blksize=16, overlap=2,delta=1, truemotion=true)
fvec = MAnalyse(superfilt,isb=false, blksize=16, overlap=2,delta=1, truemotion=true)

bvec_re = Mrecalculate(super,bvec,blksize=8, overlap=0,thSAD=100)
fvec_re = Mrecalculate(super,fvec,blksize=8, overlap=0,thSAD=100)

backw = MFlow(clap,super,bvec_re)
forw = MFlow(clap,super,fvec_re)

clp=interleave(backw,clap,forw)
clp=clp.RemoveDirt(limit,_grey)
clp=clp.SelectEvery(3,1)
return clp
}

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)
}




I think it came from John Meyer, I would like to add MDegrain2 to remove some of the smaller grain. Can this be done or does it need a separate script with it's own MAnalyse etc.?
Thanks.

johnmeyer
23rd November 2015, 23:13
The film restoration script posted by VideoFred does exactly that. The code you posted above is from my variation of that script. You can look at my version of his script to see how MDegrain2 is integrated:

My Version of VideoFred's Script (http://forum.doom9.org/showthread.php?p=1595607#post1595607)

Floatingshed
24th November 2015, 10:56
Excellent, thanks John.

Your script is giving nice results but it just grinds to a halt. It starts off at about 18fps and over a period of about 20 minutes is down to 4fps, then crash!. Any ideas? I have tried disabling mt, that makes the demise even quicker. Thanks.

johnmeyer
24th November 2015, 20:27
Sorry, I don't know why that is happening. I have seen instability with MT. Make sure you disable (comment out) all four instances of SetMTMode. There are two more located near the end of the script that are only invoked if you are doing "auto" corrections.

Groucho2004
24th November 2015, 22:25
Your script is giving nice results but it just grinds to a halt. It starts off at about 18fps and over a period of about 20 minutes is down to 4fps, then crash!. Any ideas? I have tried disabling mt, that makes the demise even quicker.
Try running the script through AVSMeter with the "-log" switch. Tell us what happens with speed/CPU/memory usage and if there are any error messages when/if it crashes. Also, post the resulting log file on pastebin.