Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
9th April 2018, 17:50 | #1 | Link |
Registered User
Join Date: Mar 2018
Location: The netherlands
Posts: 2
|
Avisynth script performance
I have been following this forum for some time, and I have already gained a lot of information for my avisynth script.
I learned a lot from: StainlessS, VideoFred, johnmeyer and many. First of all, thank you for that Only now I am looking if I can tune the performace of my avisynth script. I have already applied many of the mentioned tricks, but think that this is not yet the maximum possible. Because currently it is around 3.5fps. I have already thought about migrating to vaporsynth, only I wonder if that will get the desired speed (8fps minimum). That is why I hope that people can help here. The flow:
Note: indeed it is based on the script of videofred and many of the later mentioned improvements. if I harm someone with this script, let me know, I will of course remove it. If I have not given someone a credit, please let me know. Code:
#============================================================================================= # cleaning, degraining, resizing, stabilizing, sharpening, auto-levels and auto-white balance. #============================================================================================= SetFilterMTMode("DEFAULT_MT_MODE", 2) film= "Yourmovie.avi" # source clip, you must specify the full path here #PARAMETERS #================================================================================================================================= result="result1" # specify the wanted output here trim_begin=3 trim_end=10 play_speed=24 #SIZE, CROP AND BORDERS PARAMETERS #............................................................................................................... CLeft=40 CTop=56 CRight=56 CBottom=40 #crop values after Depan and before final resizing WDown = 1024 HDown=768 #Downscale size before actions WUp=1540 HUp=1084 #Upscale size after sharping bord_left=0 bord_top=0 bord_right=0 bord_bot=0 #STABILISING PARAMETERS #............................................................................................................... maxstabH=20 maxstabV=20 #maximum values for the stabiliser (in pixels) 20 is a good start value est_left=20 est_top=60 est_right=60 est_bottom=60 #crop values for special Estimate clip cutoff_value= 0.5 # no need to change this, but you can play with it and see what you get #CLEANING PARAMETERS #............................................................................................................... dirt_strenght=40 # set this lower for clean films. #DENOISING PARAMETERS #............................................................................................................... block_size= 16 #block size of MVDegrainMulti() block_over= 8 #block overlapping of MVDegrainMulti() # SHARPENING PARAMETERS #............................................................................................................... first_USM_radius= 5 #Radius for the first Unsharpmask second_USM_radius= 2 #Radius for the second Unsharpmask first_USM_sharpness= 40 #Radius for the first Unsharpmask second_USM_sharpness= 40 #Radius for the second Unsharpmask first_blur= 0.8 #this smooths out the heavy sharpening effects second_blur= 0.8 #this smooths out the heavy sharpening effects sharpen= 0.8 #Sharpening factor # END PARAMETERS, BEGIN SCRIPT #================================================================================================================================= #LOAD PLUGINS #............................................................................................................... Loadplugin("plugins/RemoveGrainSSE2.dll") Loadplugin("plugins/Repair.dll") Loadplugin("plugins/Depan.dll") Loadplugin("plugins/RemoveDirtSSE2.dll") Loadplugin("plugins/MVTools.dll") Loadplugin("plugins/mvtools2.dll") Loadplugin("plugins/gammac.dll") Loadplugin("plugins/warpsharp.dll") LoadPlugin("plugins/FredAverage.dll") LoadPlugin("plugins/unsharpHQ.dll") #START SCRIPT #............................................................................................................... source = DirectShowSource(film, audio=false, video=true).assumefps(play_speed).converttoYV12() source = source.trim(trim_begin,0) trimming = framecount(source)-trim_end source = trim(source,0,trimming) #Down scaling #............................................................................................................... source = source.Lanczos4Resize(WDown, HDown) #STABILIZING/CROPPING #............................................................................................................... mdata = source.crop(20,20,-20,-20).colorYUV(autogain=true).crop(est_left,est_top,-est_right,-est_bottom) vectors = source.MSuper().MAnalyse(isb=false) mdata = MDepan(mdata,vectors,rot=false, zoom=false) source =source.DePanStabilize(data=mdata,cutoff=cutoff_value, dxmax=maxstabH,dymax=maxstabV,zoommax=0,rotmax=0,method=0,info=false).deflicker() source = source.crop(CLeft,CTop,-CRight,-CBottom) #REMOVEDIRT #............................................................................................................... source = RemoveDirtSMC(source,dirt_strenght,false) #GAMMAC CORRECTION #............................................................................................................... source = source.converttoRGB24() Average = source.FredAverage(invert=true) source = source.gammac(dc = Average, show=false) source = source.converttoYV12() #UP scaling #............................................................................................................... source = source.Lanczos4Resize(WUp, HUp) #SHARPEN #............................................................................................................... source = source.unsharpmask(first_USM_sharpness,first_USM_radius,0) source = source.blur(first_blur,mmx=false) source = source.unsharpmask(second_USM_sharpness,second_USM_radius,0) source = source.blur(second_blur,mmx=false) source = source.sharpen(sharpen,mmx=false) #DENOISING #............................................................................................................... source = source.McDegrainSharp(2,bsrch=true,Precise=true) #RESULT #............................................................................................................... source = source.converttoYV12().addborders(bord_left, bord_top, bord_right, bord_bot) result1 = source Eval(result)# #REMOVE DIRT FUNCTIONS #............................................................................................................... function RemoveTempGrain(clip clp, int "_mode") { _mode = Default(_mode, 17) rg = RemoveGrain(clp, mode=_mode) return TemporalRepair(rg, clp) } function RemoveDirtS(clip clp, int "limit", bool "_grey") { _grey = Default(_grey, false) limit = Default(limit, 6) clensed = clp.Clense(grey=_grey, cache=4) alt = clp.RemoveGrain(10) return (RestoreMotionBlocks(clensed, clp, alternative=alt, pthreshold=4, cthreshold=6, gmthreshold=40, \ dist=1, dmode=2, debug=false, noise=limit, noisy=16, grey=_grey)) } function RemoveDirtSMC(clip clp, int "limit", bool "_grey") { _grey = Default(_grey, false) limit = Default(limit, 6) super1 = MSuper(clp, pel=2, sharp=2) bvec1 = MAnalyse(super1, isb=true, blksize=16, delta=1, truemotion=true) fvec1 = MAnalyse(super1, isb=false, blksize=16, delta=1, truemotion=true) backw1 = MFlow(clp, super1, bvec1) forw1 = MFlow(clp, super1, fvec1) clp = Interleave(backw1, clp, forw1) clp = clp.RemoveDirtS(limit, _grey).removetempgrain(10) clp = clp.SelectEvery(3, 1) return clp } function McDegrainSharp(clip c, int "frames", float "bblur", float "csharp", bool "bsrch", int"strenght", bool "Precise") { frames = default(frames, 2) strenght = default(strenght,400) bblur = default(bblur, 1.0) csharp = default(csharp, 1.0) bsrch = default(bsrch, true) blocks = 16 overl = block_over c2 = c.blur(bblur) super = bsrch ? c2.MSuper(pel=2, sharp=1) : c.MSuper(pel=2, sharp=1) super_rend = c.sharpen(csharp).MSuper(pel=2, sharp=1,levels=1) backward_vec3 = MAnalyse(super, isb = true, delta = 3, blksize=blocks, overlap=overl) backward_vec2 = MAnalyse(super, isb = true, delta = 2, blksize=blocks, overlap=overl) backward_vec1 = MAnalyse(super, isb = true, delta = 1, blksize=blocks, overlap=overl) forward_vec1 = MAnalyse(super, isb = false, delta = 1, blksize=blocks, overlap=overl) forward_vec2 = MAnalyse(super, isb = false, delta = 2, blksize=blocks, overlap=overl) forward_vec3 = MAnalyse(super, isb = false, delta = 3, blksize=blocks, overlap=overl) (frames<=0) ? c :\ (frames==1) ? c2.MDegrain1(super_rend, backward_vec1,forward_vec1,thSAD=strenght) :\ (frames==2) ? c2.MDegrain2(super_rend, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=strenght) :\ c2.MDegrain3(super_rend, backward_vec1,forward_vec1,backward_vec2,forward_vec2,backward_vec3,forward_vec3,thSAD=strenght) return(last) } |
Tags |
avisynth |
Thread Tools | Search this Thread |
Display Modes | |
|
|