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. |
13th March 2021, 21:06 | #21 | Link |
Moderator
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
|
The masktools2 is 2.2.10.0 dated 6/12/2017. It's served me well since then but you think I should get a newer version? Okay, replaced it with MaskTools2 2.2.26, pinterf from 9/4/2020.
The same message appears: "_lut: unsupported colorspace, masktools only support planar YUV colorspaces (YV12, YV16, YV" ([ScriptClip], line 83)" |
14th March 2021, 00:41 | #25 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Script removed, see https://forum.doom9.org/showthread.p...10#post1938110
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 14th March 2021 at 21:46. |
14th March 2021, 05:57 | #27 | Link |
Registered User
Join Date: Feb 2021
Posts: 124
|
manono, I was thinking about the error in mt_lut (([ScriptClip], line 83)) and changed my old version of the FillBorders2 function (post #7) for you.
Try using this version: Code:
function FillBorders2(clip c, int "thr", int "pad", int "MaxBorders", bool "debug") { thr = Default(thr, 5) pad = Default(pad, 0) MaxB = Default(MaxBorders, 16) debug = Default(debug, false) w = width(c) h = height(c) gScriptClip(c, """ pre = ConvertToY8()#.ColorYUV(off_y=-15) x1 = AverageLuma(crop(pre, 0, 0, -w+1, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+2, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+3, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+4, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+5, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+6, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+7, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+8, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+9, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+10, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+11, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+12, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+13, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+14, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+15, 0)) < thr ? \ (AverageLuma(crop(pre, 0, 0, -w+16, 0)) < thr ? 16 : 15) : 14) : 13) : 12) : 11) : 10) : 9) : 8) : 7) : 6) : 5) : 4) : 3) : 2) : 1) : 0 x2 = AverageLuma(Crop(pre, w-1, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-2, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-3, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-4, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-5, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-6, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-7, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-8, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-9, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-10, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-11, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-12, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-13, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-14, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-15, 0, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, w-16, 0, 0, 0)) < thr ? 16 : 15) : 14) : 13) : 12) : 11) : 10) : 9) : 8) : 7) : 6) : 5) : 4) : 3) : 2) : 1) : 0 y1 = AverageLuma(Crop(pre, 0, 0, 0, -h+1)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+2)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+3)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+4)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+5)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+6)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+7)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+8)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+9)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+10)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+11)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+12)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+13)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+14)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+15)) < thr ? \ (AverageLuma(Crop(pre, 0, 0, 0, -h+16)) < thr ? 16 : 15) : 14) : 13) : 12) : 11) : 10) : 9) : 8) : 7) : 6) : 5) : 4) : 3) : 2) : 1) : 0 y2 = AverageLuma(Crop(pre, 0, h-1, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-2, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-3, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-4, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-5, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-6, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-7, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-8, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-9, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-10, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-11, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-12, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-13, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-14, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-15, 0, 0)) < thr ? \ (AverageLuma(Crop(pre, 0, h-16, 0, 0)) < thr ? 16 : 15) : 14) : 13) : 12) : 11) : 10) : 9) : 8) : 7) : 6) : 5) : 4) : 3) : 2) : 1) : 0 x1 = x1 > 0 ? x1+pad : x1 x2 = x2 > 0 ? x2+pad : x2 y1 = y1 > 0 ? y1+pad : y1 y2 = y2 > 0 ? y2+pad : y2 PreBlur = 0 #If > 0 then there may be an error PostBlur = 0 #Max(x1, x2, y1, y2, 4) #If > 0 then there may be an error b_fix = (x1 + x2 + y1 + y2) > 0 max_fix = Max(x1, x2, y1, y2) msk = b_fix && max_fix >= 8 ? c.mt_lut("0", chroma="-128").ConvertToY8().LetterBox(y1, y2, x1, x2, color=$ffffff).ConvertToYV12() : \ c.mt_lut("0", chroma="-128") fixed = b_fix ? max_fix < 8 ? FillBorders(left=x1, top=y1, right=x2, bottom=y2, mode=0, y=3, u=3, v=3) : \ InpaintLogo(mask=msk, Radius=Max(x1,x2,y1,y2,5)*1.5, PreBlur=PreBlur, PostBlur=PostBlur) : \ c debug == true ? mt_merge(fixed, \ c.mt_lut("0", chroma="-128").ConvertToRGB().LetterBox(y1, y2, x1, x2, color=$ff3333).ConvertToYV12(), \ c.mt_lut("0", chroma="-128").ConvertToY8().LetterBox(y1, y2, x1, x2, color=$ffffff).ConvertToYV12(), \ luma=true)\ .Subtitle("Black borders:\n "+string(y1)+"\n "+string(x1)+" "+string(x2)+"\n "+string(y2), lsp = 10, text_color=$ff3333, font="Courier New", x=MaxB+5, y=MaxB+5) : \ fixed """, args="c, thr, pad, MaxB, debug, w, h") } Last edited by Arx1meD; 14th March 2021 at 06:02. |
14th March 2021, 07:28 | #28 | Link | |
Moderator
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
|
Quote:
In any event, it now works! No more message defacing the top of the movie. And thank you so much. You might want to edit your first post and mention that 2.6.0 users should change the FillBorders2.avs they have to this edited version. And mention it also in the list of required filters. Thanks again. Last edited by manono; 14th March 2021 at 20:40. |
|
14th March 2021, 08:50 | #29 | Link |
Registered User
Join Date: Feb 2021
Posts: 124
|
The Stab_Light function works correctly and does not need to be changed. The problem in FillBorders2 only.
StainlessS, maybe we can find a good example in the AWB_131201.avsi script? Last edited by Arx1meD; 14th March 2021 at 10:09. |
14th March 2021, 21:38 | #30 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Maybe check this out, Arx1meD needs to check that it works as for original.
stab_light_ssS.avsi [EDIT: Remove the _ssS when checked out ok ] Code:
/* # If Avs+, then use Import, else use GImport with Gscript installed. IsPlus = (FindStr(VersionString,"AviSynth+")!=0) AVSI_FN = ".\Stab_Light_ssS.avsi" (IsPlus) ? Import(AVSI_FN) : GImport(AVSI_FN) */ Function Stab_Light(clip clp, int "ts", int "range", int "dxmax", int "dymax", float "zoom", float "PAR", \ bool "mirror", int "MaxBorders", bool "FixBorders", bool "FixFalPos", bool "debug") { ts = Default(ts, 7) # frames to temporal average for better motion estimation (max. 7) range = Default(range, 1) # frames before/after to estimate motion dxmax = Default(dxmax, Round(clp.Width()/180.0)) #maximum deviation in pixels dymax = Default(dymax, dxmax) # x, and y should be the same zoom = Default(zoom, 1) # maximum zoom factor (1 disabled) PAR = Default(PAR, 1.0) # PAR of your source mirror = Default(mirror, false) # Edge filling MaxBorders = Default(MaxBorders, Max(Round(clp.Width()/60.0), 20)) FixBorders = Default(FixBorders, true) FixFalPos = Default(FixFalPos, true) # Fixes borders of MaxBorders more pixels wide debug = Default(debug, false) temp = TemporalSoften(clp, ts, 255, 255, 25, 2) # SC thr to 25 otherwise pans will stutter rep = Repair(temp, TemporalSoften(clp, 1, 255, 255, 25, 2)) inter = Interleave(rep, clp) # temporal stable (better subpixel detection) pre_clp = inter.mt_lut(expr="x 20 1 x 127.5 / - 21 ^ pi x * 255 / cos 21 ^ - * 1.05 * -", Y=3, U=2, V=2).RemoveGrain(mode=17) #ColorYUV(levels="PC->TV") mdata = DePanEstimate(pre_clp, range=range, pixaspect=PAR, trust=0, dxmax=dxmax, dymax=dymax, zoommax=zoom) dp = DePan(inter, data=mdata, offset=-1, mirror=mirror?15:0, pixaspect=PAR, matchfields=false, subpixel=2) stab = SelectEvery(dp, 2, 0) w = Width(clp) h = Height(clp) thr = 10 pre = stab.ConvertToY8()#.ColorYUV(off_y=-15) stab = (!mirror && FixFalPos) \ ? gScriptClip(stab, " AverageLuma(Crop(pre, 0, 0, -w+MaxBorders+1, 0)) < thr ? clp : \ AverageLuma(Crop(pre, w-MaxBorders-1, 0, 0, 0)) < thr ? clp : \ AverageLuma(Crop(pre, 0, 0, 0, -h+MaxBorders+1)) < thr ? clp : \ AverageLuma(Crop(pre, 0, h-MaxBorders-1, 0, 0)) < thr ? clp : Last Return Last ", args="clp, pre, MaxBorders, w, h, thr",Local=true) \ : stab Return (!mirror && FixBorders) \ ? FillBorders2(stab, thr=thr, pad=1, MaxBorders=MaxBorders, debug=debug) \ : stab } Function FillBorders2(clip c, int "thr", int "pad", int "MaxBorders", bool "debug") { Function FillBorders2_dBugS(int y1,int x1,int x2,int y2) { Return "Black borders:\n "+string(y1)+"\n "+string(x1)+" "+string(x2)+"\n "+ string(y2) } thr = Default(thr, 5) pad = Default(pad, 0) MaxB = Default(MaxBorders, Max(Round(c.Width()/60.0), 20)) debug = Default(debug, false) w = width(c) h = height(c) cblank = c.mt_lut( "0", chroma="-128") pre = c.ConvertToY8()#.ColorYUV(off_y=-15) # Moved out of gScriptclip preblank = pre.mt_lut("0", chroma="-128") font="Courier New" gScriptClip(c, " x1 = Pre.FillBorders2_TestBord(0, thr, MaxB, Pad) x2 = Pre.FillBorders2_TestBord(1, thr, MaxB, Pad) y1 = Pre.FillBorders2_TestBord(2, thr, MaxB, Pad) y2 = Pre.FillBorders2_TestBord(3, thr, MaxB, Pad) PreBlur = 0 # If > 0 then there may be an error PostBlur = 0 # Max(x1, x2, y1, y2, 4) #If > 0 then there may be an error b_fix = (x1 + x2 + y1 + y2) > 0 max_fix = Max(x1, x2, y1, y2) msk = (b_fix && max_fix >= 8) \ ? preblank.LetterBox(y1, y2, x1, x2, color_yuv=$ffffff).ConvertToYV12() \ : preblank fixed = (!b_fix) ? Last \ : (max_fix < 8) ? FillBorders(left=x1, top=y1, right=x2, bottom=y2, mode=0, y=3, u=3, v=3) \ : InpaintLogo(mask=msk, Radius=Max(x1,x2,y1,y2,5)*1.5, PreBlur=PreBlur, PostBlur=PostBlur) (debug) \ ? mt_merge(fixed, cblank.ConvertToRGB().LetterBox(y1, y2, x1, x2, color=$ff3333) \ .ConvertToYV12(),preblank.LetterBox(y1, y2, x1, x2, color_yuv=$ffffff).ConvertToYV12(), luma=true) \ .Subtitle(FillBorders2_dBugS(y1,x1,x2,y2), lsp = 10, text_color=$ff3333, font=Font, x=MaxB+5, y=MaxB+5) \ : fixed Return Last ", args="pre, cblank, preblank, thr, pad, MaxB, debug, w, h,Font",Local=true) } Function FillBorders2_TestBord(clip c,int edge, Float thr, int MaxB, Int Pad) { # edge: 0=lft, 1=rgt, 2=top, 3=bot result=0 w=c.width h=c.height for(i = 1, MaxB) { crpd=c.Crop((edge==1)?w-i:0,(edge==3)?h-i:0,(edge==0)?i:0,(edge==2)?i:0) if(crpd.AverageLuma < thr) { result=i+pad } else { i=MaxB } } return result } Code:
IsPlus = (FindStr(VersionString,"AviSynth+")!=0) AVSI_FN = ".\Stab_Light_ssS.avsi" (IsPlus) ? Import(AVSI_FN) : GImport(AVSI_FN) ORG=AviSource(".\Src.Avi") # OP's sample [Left Half] , After ffmpeg conversion to UT_Video AVI STB = ORG.Stab_Light(zoom = 1.00, mirror = false, FixFalPos = true, FixBorders = true, debug = false) D=STB.Subtract(ORG) T=StackHorizontal(ORG,STB) B=StackHorizontal(D,D) StackVertical(T,B) EDIT: If using AvsInit(), can just dump the avsi into GIMPORT folder [whether Avs+ or not]. EDIT: FillBorders2_TestBord(thr) implemented as Float.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 14th March 2021 at 22:08. |
15th March 2021, 02:38 | #31 | Link |
Moderator
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
|
1. I have to use GImport when opening your Stab_Light.avs, StainlessS
2. I also have to include an Import line for FillBorders2 that Arx1meD modified. I use Import and LoadPlugin lines for all filters. I don't have a functioning AviSynth Plugins folder. I think that means the FillBorders2 in your all-in-one function isn't working for me. If I don't, and depend on the one in your script, I get: AviSynth open failure: mt_lut: unsupported colorspace. masktools only support planar YUV colorspaces (YV12, YV16, YV24). H:\AviSynth\Plugins\Stab_Light.avs, line 64 H:\AviSynth\Plugins\Stab_Light.avs, line 49 G:\AviSynth\Ek Do Teen\2.Stabilize.avs, line 63 One of them refers to my script, probably the Stab_Light.avs line: Stab_Light(zoom = 1.00, mirror = false, MaxBorders=16, FixFalPos = true, FixBorders = true, debug = false) I never used the "_ssS". Maybe that's the reason but I don't understand what it's doing in there to begin with. And thanks for putting so much time into this. It's much appreciated. Last edited by manono; 15th March 2021 at 02:42. |
15th March 2021, 06:32 | #32 | Link |
Registered User
Join Date: Feb 2021
Posts: 124
|
StainlessS, I checked your version of the script. Everything works just like the original.
However, there was an error in AviSynth 2.6. I have inserted the FillBorders2_TestBord function wrapped in GScript("""...""") in FillBorders2 and there was no error. We can say that this version is for AviSynth 2.6 only and needs a GScript plugin. (Test version. I do not recommend using it.) Code:
Function Stab_Light(clip clp, int "ts", int "range", int "dxmax", int "dymax", float "zoom", float "PAR", \ bool "mirror", int "MaxBorders", bool "FixBorders", bool "FixFalPos", bool "debug") { ts = Default(ts, 7) # frames to temporal average for better motion estimation (max. 7) range = Default(range, 1) # frames before/after to estimate motion dxmax = Default(dxmax, Round(clp.Width()/180.0)) #maximum deviation in pixels dymax = Default(dymax, dxmax) # x, and y should be the same zoom = Default(zoom, 1) # maximum zoom factor (1 disabled) PAR = Default(PAR, 1.0) # PAR of your source mirror = Default(mirror, false) # Edge filling MaxBorders = Default(MaxBorders, Max(Round(clp.Width()/60.0), 20)) FixBorders = Default(FixBorders, true) FixFalPos = Default(FixFalPos, true) # Fixes borders of MaxBorders more pixels wide debug = Default(debug, false) temp = TemporalSoften(clp, ts, 255, 255, 25, 2) # SC thr to 25 otherwise pans will stutter rep = Repair(temp, TemporalSoften(clp, 1, 255, 255, 25, 2)) inter = Interleave(rep, clp) # temporal stable (better subpixel detection) pre_clp = inter.mt_lut(expr="x 20 1 x 127.5 / - 21 ^ pi x * 255 / cos 21 ^ - * 1.05 * -", Y=3, U=2, V=2).RemoveGrain(mode=17) #ColorYUV(levels="PC->TV") mdata = DePanEstimate(pre_clp, range=range, pixaspect=PAR, trust=0, dxmax=dxmax, dymax=dymax, zoommax=zoom) dp = DePan(inter, data=mdata, offset=-1, mirror=mirror?15:0, pixaspect=PAR, matchfields=false, subpixel=2) stab = SelectEvery(dp, 2, 0) w = Width(clp) h = Height(clp) thr = 10 pre = stab.ConvertToY8()#.ColorYUV(off_y=-15) stab = (!mirror && FixFalPos) \ ? gScriptClip(stab, " AverageLuma(Crop(pre, 0, 0, -w+MaxBorders+1, 0)) < thr ? clp : \ AverageLuma(Crop(pre, w-MaxBorders-1, 0, 0, 0)) < thr ? clp : \ AverageLuma(Crop(pre, 0, 0, 0, -h+MaxBorders+1)) < thr ? clp : \ AverageLuma(Crop(pre, 0, h-MaxBorders-1, 0, 0)) < thr ? clp : Last Return Last ", args="clp, pre, MaxBorders, w, h, thr",Local=true) \ : stab Return (!mirror && FixBorders) \ ? FillBorders2(stab, thr=thr, pad=1, MaxBorders=MaxBorders, debug=debug) \ : stab } Function FillBorders2(clip c, int "thr", int "pad", int "MaxBorders", bool "debug") { Function FillBorders2_dBugS(int y1,int x1,int x2,int y2) { Return "Black borders:\n "+string(y1)+"\n "+string(x1)+" "+string(x2)+"\n "+ string(y2) } thr = Default(thr, 5) pad = Default(pad, 0) MaxB = Default(MaxBorders, Max(Round(c.Width()/60.0), 20)) debug = Default(debug, false) w = width(c) h = height(c) cblank = c.mt_lut("0", chroma="-128") pre = c.ConvertToY8()#.ColorYUV(off_y=-15) # Moved out of gScriptclip preblank = cblank.ConvertToY8() font="Courier New" gScriptClip(c, """ GScript(" Function FillBorders2_TestBord(clip c,int edge, Float thr, int MaxB, Int Pad) { # edge: 0=lft, 1=rgt, 2=top, 3=bot result=0 w=c.width h=c.height for(i = 1, MaxB) { crpd=c.Crop((edge==1)?w-i:0,(edge==3)?h-i:0,(edge==0)?i:0,(edge==2)?i:0) if(crpd.AverageLuma < thr) { result=i+pad } else { i=MaxB } } return result } ") x1 = Pre.FillBorders2_TestBord(0, thr, MaxB, Pad) x2 = Pre.FillBorders2_TestBord(1, thr, MaxB, Pad) y1 = Pre.FillBorders2_TestBord(2, thr, MaxB, Pad) y2 = Pre.FillBorders2_TestBord(3, thr, MaxB, Pad) PreBlur = 0 # If > 0 then there may be an error PostBlur = 0 # Max(x1, x2, y1, y2, 4) #If > 0 then there may be an error b_fix = (x1 + x2 + y1 + y2) > 0 max_fix = Max(x1, x2, y1, y2) msk = (b_fix && max_fix >= 8) \ ? preblank.LetterBox(y1, y2, x1, x2, color=$ffffff).ConvertToYV12() \ : cblank fixed = (!b_fix) ? Last \ : (max_fix < 8) ? FillBorders(left=x1, top=y1, right=x2, bottom=y2, mode=0, y=3, u=3, v=3) \ : InpaintLogo(mask=msk, Radius=Max(x1,x2,y1,y2,5)*1.5, PreBlur=PreBlur, PostBlur=PostBlur) (debug) \ ? mt_merge(fixed, cblank.ConvertToRGB().LetterBox(y1, y2, x1, x2, color=$ff3333) \ .ConvertToYV12(),preblank.LetterBox(y1, y2, x1, x2, color=$ffffff).ConvertToYV12(), luma=true) \ .Subtitle(FillBorders2_dBugS(y1,x1,x2,y2), lsp = 10, text_color=$ff3333, font=Font, x=MaxB+5, y=MaxB+5) \ : fixed Return Last """, args="pre, cblank, preblank, thr, pad, MaxB, debug, w, h,Font",Local=true) } Оr in the original script just wrapped in GScript ("...") for(i = 1, MaxB, 1) {... . (Test version) Code:
function FillBorders2(clip c, float "thr", int "pad", int "MaxBorders", bool "debug") { thr = Default(thr, 5) pad = Default(pad, 0) MaxB = Default(MaxBorders, Max(Round(c.Width()/60.0), 20)) debug = Default(debug, false) w = width(c) h = height(c) gScriptClip(c, """ pre = ConvertToY8()#.ColorYUV(off_y=-15) x1 = 0 x2 = 0 y1 = 0 y2 = 0 GScript(" for(i = 1, MaxB, 1) { if (AverageLuma(Crop(pre, 0, 0, -w+i, 0)) < thr) {x1 = i + pad} else {i=MaxB} } for(i = 1, MaxB, 1) { if (AverageLuma(Crop(pre, w-i, 0, 0, 0)) < thr) {x2 = i + pad} else {i=MaxB} } for(i = 1, MaxB, 1) { if (AverageLuma(Crop(pre, 0, 0, 0, -h+i)) < thr) {y1 = i + pad} else {i=MaxB} } for(i = 1, MaxB, 1) { if (AverageLuma(Crop(pre, 0, h-i, 0, 0)) < thr) {y2 = i + pad} else {i=MaxB} } ") PreBlur = 0 #If > 0 then there may be an error PostBlur = 0 #Max(x1, x2, y1, y2, 4) #If > 0 then there may be an error b_fix = (x1 + x2 + y1 + y2) > 0 max_fix = Max(x1, x2, y1, y2) msk = b_fix && max_fix >= 8 ? c.mt_lut("0", chroma="-128").ConvertToY8().LetterBox(y1, y2, x1, x2, color=$ffffff).ConvertToYV12() : \ c.mt_lut("0", chroma="-128") fixed = b_fix ? max_fix < 8 ? FillBorders(left=x1, top=y1, right=x2, bottom=y2, mode=0, y=3, u=3, v=3) : \ InpaintLogo(mask=msk, Radius=Max(x1,x2,y1,y2,5)*1.5, PreBlur=PreBlur, PostBlur=PostBlur) : \ c debug == true ? mt_merge(fixed, \ c.mt_lut("0", chroma="-128").ConvertToRGB().LetterBox(y1, y2, x1, x2, color=$ff3333).ConvertToYV12(), \ c.mt_lut("0", chroma="-128").ConvertToY8().LetterBox(y1, y2, x1, x2, color=$ffffff).ConvertToYV12(), \ luma=true)\ .Subtitle("Black borders:\n "+string(y1)+"\n "+string(x1)+" "+string(x2)+"\n "+string(y2), lsp = 10, text_color=$ff3333, font="Courier New", x=MaxB+5, y=MaxB+5) : \ fixed """, args="c, thr, pad, MaxB, debug, w, h") } Last edited by Arx1meD; 16th March 2021 at 06:15. |
15th March 2021, 15:13 | #33 | Link |
Registered User
Join Date: Feb 2021
Posts: 124
|
So. There is a good solution:
Code:
VersionNumber() > 2.60 ? Eval(" for(i = 1, MaxB) { if (AverageLuma(Crop(pre, 0, 0, -w+i, 0)) < thr) {x1 = i + pad} else {i = MaxB} } for(i = 1, MaxB) { if (AverageLuma(Crop(pre, w-i, 0, 0, 0)) < thr) {x2 = i + pad} else {i = MaxB} } for(i = 1, MaxB) { if (AverageLuma(Crop(pre, 0, 0, 0, -h+i)) < thr) {y1 = i + pad} else {i = MaxB} } for(i = 1, MaxB) { if (AverageLuma(Crop(pre, 0, h-i, 0, 0)) < thr) {y2 = i + pad} else {i = MaxB} } ") : GScript(" for(i = 1, MaxB) { if (AverageLuma(Crop(pre, 0, 0, -w+i, 0)) < thr) {x1 = i + pad} else {i = MaxB} } for(i = 1, MaxB) { if (AverageLuma(Crop(pre, w-i, 0, 0, 0)) < thr) {x2 = i + pad} else {i = MaxB} } for(i = 1, MaxB) { if (AverageLuma(Crop(pre, 0, 0, 0, -h+i)) < thr) {y1 = i + pad} else {i = MaxB} } for(i = 1, MaxB) { if (AverageLuma(Crop(pre, 0, h-i, 0, 0)) < thr) {y2 = i + pad} else {i = MaxB} } ") |
15th March 2021, 16:01 | #34 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Not really too good if inside gScriptclip,
Reason, will scan and install FillBorders2_TestBord() function as GScript function at every iteration of gScriptclip, ie slow + memory consuming. Above written for using GScript(""" FillBorders2_TestBord()""") inside scriptCip, also applies to GScript(""" for( ... etc """) and Eval(). FillBorders2_TestBord() is better outside of function at main level, or maybe after FillBorders2_dBugS() in FillBorders2(). Quote:
I'm still working on this a bit. And dont worry bout this, its OK. Code:
Function FillBorders2_TestBord(clip c,int edge, Float thr, int MaxB, Int Pad) { # edge: 0=lft, 1=rgt, 2=top, 3=bot result=0 w=c.width h=c.height for(i = 1, MaxB) { crpd=c.Crop((edge==1)?w-i:0,(edge==3)?h-i:0,(edge==0)?i:0,(edge==2)?i:0) if(crpd.AverageLuma < thr) { result=i+pad } else { i=MaxB } } return result } Code:
# edge: 0=lft, 1=rgt, 2=top, 3=bot #crpd=c.Crop( (edge==1)?w-i:0 , (edge==3)?h-i:0 , (edge==0)?i:0 , (edge==2)?i:0) #crpd=c.Crop( ( RGT)?640-8:0 , ( BOT)?480-8:0 , ( LFT)?8:0 , ( TOP)?8:0) LFT = crop( 0, 0, 8, 0) # Width = 8 RGT = crop( 640-8, 0, 0, 0) # Width = 0, means from left coord(640-8) all the way to right edge TOP = crop( 0, 0, 0, 8) # Height = 8 BOT = crop( 0, 480-8, 0, 0) # Height = 0, means from top coord(480-8) all the way to bot edge crop(0,0,0,0) is Full Frame. For for() loop, dont need specify increment if its 1 (default = 1), ie Code:
for(i = 1, MaxB, 1) for(i = 1, MaxB)
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 15th March 2021 at 16:31. |
|
15th March 2021, 18:40 | #35 | Link | |
Registered User
Join Date: Feb 2021
Posts: 124
|
Quote:
When I tested your Stab_Light_ssS.avsi in AviSynth 2.6 I got an error. Then I inserted the FillBorders2_TestBord function in FillBorders2. Checked it and got no error. Last edited by Arx1meD; 15th March 2021 at 18:52. |
|
15th March 2021, 19:13 | #36 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Yeah, but Which Error Message ?
EDIT: You can fix for usage under v2.60 Std ONLY with Code:
GScript(""" Function FillBorders2_TestBord(clip c,int edge, Float thr, int MaxB, Int Pad) { # edge: 0=lft, 1=rgt, 2=top, 3=bot result=0 w=c.width h=c.height for(i = 1, MaxB) { crpd=c.Crop((edge==1)?w-i:0,(edge==3)?h-i:0,(edge==0)?i:0,(edge==2)?i:0) if(crpd.AverageLuma < thr) { result=i+pad } else { i=MaxB } } return result } """)
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 15th March 2021 at 19:23. |
15th March 2021, 19:39 | #37 | Link | ||||
Registered User
Join Date: Feb 2021
Posts: 124
|
I understood. Without GScript ("""...""") there is an error:
Quote:
Quote:
Quote:
Quote:
Last edited by Arx1meD; 15th March 2021 at 19:43. |
||||
15th March 2021, 21:42 | #38 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Arx1meD,
Right, here we go, FINAL version as far as I'm concerned. I've used thr=10.0 instead of 10, and thr = Default(thr,5.0) instead of thr = Default(thr,5), ie float values. I also made other changes you suggested [excluding the GScript stuff]. Here new script, read the comments. Stab_Light.avsi Code:
# Stab_light.avsi /* This script can be IMPORT()'ed under Avs+, OR, under Avs v2.60 Standard [ONLY IF GScript is installed]. Can also be GIMPORT()'ed when GScript Installed. Can Also be auto Loaded by Avisynth if in Plugins directory. [needs Gscript installed if not AVS+]. Can Also be dumped in AvsInit()'s GIMPORT directory for auto loading by AvsInit(). */ Function Fb2FnNameEx(String Fn){Try{Eval(Fn+"()")B=True}catch(e) \ {Assert(e.FindStr("syntax")==0,"Fb2FnNameEx: Error in Function Name '"+Fn+"'")B=(e.FindStr("no function named")==0)}Return B} Fb2IsPlus = (FindStr(VersionString,"AviSynth+")!=0) Fb2HasGScript = Fb2FnNameEx("GScipt") Fb2_GS_S = """ Function FillBorders2_TestBord(clip c,int edge, Float thr, int MaxB, Int Pad) { # edge: 0=lft, 1=rgt, 2=top, 3=bot result=0 w=c.width h=c.height for(i = 1, MaxB) { crpd=c.Crop((edge==1)?w-i:0,(edge==3)?h-i:0,(edge==0)?i:0,(edge==2)?i:0) if(crpd.AverageLuma < thr) { result=i+pad } else { i=MaxB } } return result } """ /* If this avsi script is not in plugins, then HasGScript [Fb2HasGScript] can be FALSE, even if using GImport() from Gscript dll. Not sure why this occurs, so even if Fb2HasGScript==FALSE and is NOT Avs+, then we use Gscript's GEval instead of Eval to install above FillBorders2_TestBord(). We use Eval() to install the function, ONLY if GScript not installed and is AVS+. */ Try { (Fb2HasGScript||!Fb2IsPlus) ? GEval(Fb2_GS_S) : Eval(Fb2_GS_S) } catch (msg) { Assert(False,ScriptFile+": Need GScript or Avs+"+Chr(10)+ \ "IsPlus="+String(Fb2IsPlus)+" : HasGScript="+String(Fb2HasGScript)+Chr(10)+ \ "SysErr="+Msg) } Function Stab_Light(clip clp, int "ts", int "range", int "dxmax", int "dymax", float "zoom", float "PAR", \ bool "mirror", int "MaxBorders", bool "FixBorders", bool "FixFalPos", bool "debug") { ts = Default(ts, 7) # frames to temporal average for better motion estimation (max. 7) range = Default(range, 1) # frames before/after to estimate motion dxmax = Default(dxmax, Round(clp.Width()/180.0)) #maximum deviation in pixels dymax = Default(dymax, dxmax) # x, and y should be the same zoom = Default(zoom, 1) # maximum zoom factor (1 disabled) PAR = Default(PAR, 1.0) # PAR of your source mirror = Default(mirror, false) # Edge filling MaxBorders = Default(MaxBorders, Max(Round(clp.Width()/60.0), 20)) FixBorders = Default(FixBorders, true) FixFalPos = Default(FixFalPos, true) # Fixes borders of MaxBorders more pixels wide debug = Default(debug, false) temp = TemporalSoften(clp, ts, 255, 255, 25, 2) # SC thr to 25 otherwise pans will stutter rep = Repair(temp, TemporalSoften(clp, 1, 255, 255, 25, 2)) inter = Interleave(rep, clp) # temporal stable (better subpixel detection) pre_clp = inter.mt_lut(expr="x 20 1 x 127.5 / - 21 ^ pi x * 255 / cos 21 ^ - * 1.05 * -", Y=3, U=2, V=2) \ .RemoveGrain(mode=17) #ColorYUV(levels="PC->TV") mdata = DePanEstimate(pre_clp, range=range, pixaspect=PAR, trust=0, dxmax=dxmax, dymax=dymax, zoommax=zoom) dp = DePan(inter, data=mdata, offset=-1, mirror=mirror?15:0, pixaspect=PAR, matchfields=false, subpixel=2) stab = SelectEvery(dp, 2, 0) w = Width(clp) h = Height(clp) thr = 10.0 pre = stab.ConvertToY8()#.ColorYUV(off_y=-15) stab = (!mirror && FixFalPos) \ ? gScriptClip(stab, " AverageLuma(Crop(pre, 0, 0, -w+MaxBorders+1, 0)) < thr ? clp : \ AverageLuma(Crop(pre, w-MaxBorders-1, 0, 0, 0)) < thr ? clp : \ AverageLuma(Crop(pre, 0, 0, 0, -h+MaxBorders+1)) < thr ? clp : \ AverageLuma(Crop(pre, 0, h-MaxBorders-1, 0, 0)) < thr ? clp : Last Return Last ", args="clp, pre, MaxBorders, w, h, thr",Local=true) \ : stab Return (!mirror && FixBorders) \ ? FillBorders2(stab, thr=thr, pad=1, MaxBorders=MaxBorders, debug=debug) \ : stab } Function FillBorders2(clip c, float "thr", int "pad", int "MaxBorders", bool "debug") { Function FillBorders2_dBugS(int y1,int x1,int x2,int y2) { Return "Black borders:\n "+string(y1)+"\n "+string(x1)+" "+string(x2)+"\n "+ string(y2) } thr = Default(thr, 5.0) pad = Default(pad, 0) MaxB = Default(MaxBorders, Max(Round(c.Width()/60.0), 20)) debug = Default(debug, false) w = width(c) h = height(c) cblank = c.mt_lut( "0", chroma="-128") pre = c.ConvertToY8()#.ColorYUV(off_y=-15) # Moved out of gScriptclip preblank = cblank.ConvertToY8() font="Courier New" gScriptClip(c, " x1 = Pre.FillBorders2_TestBord(0, thr, MaxB, Pad) x2 = Pre.FillBorders2_TestBord(1, thr, MaxB, Pad) y1 = Pre.FillBorders2_TestBord(2, thr, MaxB, Pad) y2 = Pre.FillBorders2_TestBord(3, thr, MaxB, Pad) PreBlur = 0 # If > 0 then there may be an error PostBlur = 0 # Max(x1, x2, y1, y2, 4) #If > 0 then there may be an error b_fix = (x1 + x2 + y1 + y2) > 0 max_fix = Max(x1, x2, y1, y2) msk = (b_fix && max_fix >= 8) \ ? preblank.LetterBox(y1, y2, x1, x2, color=$ffffff).ConvertToYV12() \ : cblank fixed = (!b_fix) ? Last \ : (max_fix < 8) ? FillBorders(left=x1, top=y1, right=x2, bottom=y2, mode=0, y=3, u=3, v=3) \ : InpaintLogo(mask=msk, Radius=Max(x1,x2,y1,y2,5)*1.5, PreBlur=PreBlur, PostBlur=PostBlur) (debug) \ ? mt_merge(fixed, cblank.ConvertToRGB().LetterBox(y1, y2, x1, x2, color=$ff3333) \ .ConvertToYV12(),preblank.LetterBox(y1, y2, x1, x2, color=$ffffff).ConvertToYV12(), luma=true) \ .Subtitle(FillBorders2_dBugS(y1,x1,x2,y2), lsp = 10, text_color=$ff3333, font=Font, x=MaxB+5, y=MaxB+5) \ : fixed Return Last ", args="pre, cblank, preblank, thr, pad, MaxB, debug, w, h,Font",Local=true) } Code:
# GScript needs to be installed BEFORE attempting to Avs v2.60 std Import/GImport "Stab_Light.avsi". # Either by Plugins AutoLoad, or Manual LoadPlugin() loading. # LoadPlugin(GSCRIPT_PATH_AND_PLUG_NAME) AVSI_FN = ".\Stab_Light.avsi" Import(AVSI_FN) # Import, If not in plugins, Avs+ or avs Std [with gscript]. ORG=AviSource(".\Src.Avi") # OP's sample, After ffmpeg conversion to UT_Video AVI STB = ORG.Stab_Light(zoom = 1.00, mirror = false, FixFalPos = true, FixBorders = true, debug = false) D=STB.Subtract(ORG) T=StackHorizontal(ORG,STB) B=StackHorizontal(D,D) StackVertical(T,B)
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 16th March 2021 at 00:42. |
15th March 2021, 22:38 | #39 | Link |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
|
I have no problem with using it like this https://github.com/realfinder/AVS-St...tsign.avsi#L64 IIRC
__________________
See My Avisynth Stuff |
15th March 2021, 22:54 | #40 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
OK, that works.
But I usually use/force Gscript if it is installed, [ external plugins Override builtin ]. ( If Gscript is installed, then presumably the user intended for it to be used, even if Avs+ ) Plugin Autoload and Name Precedence :- http://avisynth.nl/index.php/Plugins Quote:
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 15th March 2021 at 23:04. |
|
Tags |
deshaker |
|
|