View Full Version : InpaintDelogo - advanced logo removal & hardcoded subtitles extraction
StainlessS
11th November 2021, 02:45
OK, tried with v2.60 std, OK.
IsPlus = FindStr(VersionString.lcase,"avisynth+")!=0
(IsPlus) ? Import(".\Analyze5FX.avs") : GImport(".\Analyze5FX.avs")
x = LSMASHVideoSource(".\899.mp4")
x = x.crop(1124,24,-52,-636).Trim(30,100) # trimed for speed
mask = ImageSource(".\WieMHwJ.png",0,0)
# Mode 1 test
m0 = x.Analyze5FX(mask=mask, mode=1, show=0)
m1 = x.Analyze5FX(mask=mask, mode=1, show=1)
m2 = x.Analyze5FX(mask=mask, mode=1, show=2)
mu = Stackhorizontal(m0.AddBorders(0,0,2,0,$000000), m0)
md = Stackhorizontal(m1.AddBorders(0,0,2,0,$000000), m2)
Stackvertical(mu.AddBorders(0,0,0,2,$000000), md)
with Grunt[GScriptClip], GScript[If/While etc], RT_stats[other stuff] in 2.60 std plugins. [and LSMash]
Really going to bed now. [I hope].
[Same "no frame found to analyse", but no crash]
EDIT: And the entire script as I have it [with the DBase].
function Analyze5FX(clip clp, val "mask", int "Mode", int "Analyze5Th", string "Ignore", int "Show") {
mask = default (mask , "")
Mode = default (Mode , 1 )
Analyze5Th = default (Analyze5Th , 15)
Ignore = default (Ignore , "none")
Show = default (Show , 0)
Assert (!(Mode < 1 || Mode > 2), """"Mode" value must be between 1 and 2.""")
Assert (!(Analyze5Th < 1 || Analyze5Th > 255), """"Analyze5Th" value must be between 1 and 255.""")
Assert (!(Show < 0 || Show > 2), """"Show" value must be between 0 and 2.""")
Assert ((Ignore == "top" || Ignore == "bottom" || Ignore == "left" || Ignore == "right" || Ignore == "none"), """"Ignore" string must be 'top', 'bottom', 'left', 'right' or 'none'.""")
VW = clp.Width
VH = clp.Height
Th = Analyze5Th
mask = (IsClip(mask)) ? mask.ConvertToY8(matrix="PC.709").MTballoon2PX(2) : nop
clpS = clp.ScriptClip("subtitle(string(current_frame))")
# Construct a clip to check thresholds (for deblending analysis) #
#================================================================#
if(Mode == 1) {
VFX2="""
if(!mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) {
RT_DBaseSetField(Analyze5DB,current_frame,0,2)
Assert (FALSE, "Mask image is invalid.") # Not really a good place for Assert()
}
VW = Last.Width
VH = Last.Height
# Convert X,Y,W,H coords to L,T,-R,-B coords
mL = YIRL_X
mT = YIRL_Y
mR = -VW + mL + YIRL_W
mB = -VH + mT + YIRL_H
Assert (!(mL < 8 && -1*mR < 8 || mT < 8 && -1*mB < 8), "Mask image or Loc is invalid.") # Not really a good place for Assert()
# Coords mod2 round up
mL = mL + (mL % 2)
mT = mT + (mT % 2)
mR = mR - (mR % 2)
mB = mB - (mB % 2)
RT_DBaseSet(Analyze5DB,current_frame,1, mL,mT,mR,mB) # Write VoodooFX style coords to DB
# Crop 2x2 pxs area from above or below the logo and make a background from it
mid = (VW-mL+mR)/2+mL
mid = mid + (mid % 2)
clp2x2 = (mT >= -1*mB) ? Last.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : Last.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)
Return clp2x2.PointResize(VW, VH) # Same size as input clip
"""
Analyze5DB = ("~InpaintDelogo_Analyze5_"+RT_LocalTimeString+".DB").RT_GetFullPathName
RT_DBaseAlloc(Analyze5DB,Mask.FrameCount,"iiiii") # Alloc DBase records, number of frames in mask clip
clpB = clp.GScriptClip(VFX2, local=true, args="mask,Analyze5DB", after_frame=true)
clpB.RT_ForceProcess # FORCE PROCESS ENTIRE CLIP
Msk1 = mask.MTballoon2PX(2).mt_logic(mask, mode="xor") # 2px wide mask around logo (+2px offset from the base mask)
clp5 = clpB.Overlay(clp, mask=Msk1)
# RT_FileDelete(Analyze5DB)
} else {
# Construct a clip to check thresholds (for Automask=1) #
#=======================================================#
cT = clp.crop(4, 4, -4, -1*(VH-6))
cB = clp.crop(4, VH-6, -4, -4)
cL = clp.crop(4, 4, -1*(VW-6), -4)
cR = clp.crop(VW-6, 4, -4, -4)
if(Ignore == "top") {
cT = cB
} else if (Ignore == "bottom") {
cB = cT
} else if (Ignore == "left") {
cL = cR
} else if (Ignore == "right") {
cR = cL
}
wc = StackHorizontal(cr,cl).TurnLeft
hc = StackVertical(ct,cb)
if(wc.width > hc.width) {
hc = hc.PointResize(wc.width, hc.height)
out = StackVertical(wc,hc)
} else if(wc.width < hc.width) {
wc = wc.PointResize(hc.width, wc.height)
out = StackVertical(wc,hc)
} else {
out = StackVertical(wc,hc)
}
clp5 = (Show == 2) ? out.PointResize(VW, VH) : out
}
# Delete frames above thresholds (that leaves us with the suitable frames for analysis) #
#=======================================================================================#
# Mod of Gavino's DeleteFrames() - https://forum.doom9.org/showthread.php?t=163107
clp5
fc = FrameCount()
res = BlankClip(clp, length=0)
condition = "YPlaneMinMaxDifference >" +String(Th)+ " || UPlaneMinMaxDifference >" +String(Round(Th/2))+ " || VPlaneMinMaxDifference >" +String(Round(Th/2))
current_frame = 0
while (current_frame < fc) {
while (Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
if (current_frame < fc) { # not at end
start = current_frame # start of wanted section
while (!Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
clpX = (Show == 1) ? clpS : (Show == 2) ? clp5 : clp # 0: Original frames, 1: Original frames + frameNo, 2: Constructed clips (Mode=2 clip is upsized for show)
res = res + clpX.Trim(start, start-current_frame)
}
}
Assert (!(res.FrameCount < 2), """No frames found to analyze, increase "Analyze5Th".""")
return res
}
EDIT: With return clp5 just before your delete frames stuff, I get this
https://i.postimg.cc/SR46DbDL/R95703761-00.jpg (https://postimages.org/)
Some error message on frame. [too small to read]
VoodooFX
11th November 2021, 03:09
That image doesn't look correct. This is how it looks on avs+:
https://i.imgur.com/Ig5JNGy.png
EDIT:
Both tops are just original frames, the bottom left is original frame + original FrameNo, the bottom right is constructed clip (with defaults should be almost one solid color).
EDIT2:
Just noticed that it's "before your delete frames stuff", clp5 should be constructed clip (shouldn't be actual logo in there, just some different color instead at worst, that's why there are no frames on res output)
StainlessS
11th November 2021, 04:07
OK, I've figured out something I forgot a long time ago [I guess I avoid it automatically, but forgot why I do it].
Using GScript [v2.60 std], Scriptclip (or other runtime stuff), is NOT parsed withing GScript, it uses ScriptClip parsing from v2.60 std, so it dont work
when GImport-ing scripts that uses If/for/while etc withing runtimes script.
You need a function external to scriptclip, but within a Gscript parsed region.
This dont work
GScript("""
Function Test26_A(clip c) {
c
SSS="
if(current_frame % 2 ==0) { # <<<<<<<< Error at curly brace, scriptclip dont know what it is
Subtitle(String(current_frame,"+Chr(34)+"%.0f]"+Chr(34)+"))
}
return last
"
return Scriptclip(SSS)
}
""")
blankclip
test26_A()
but this works fine
GScript("""
Function _LOW_Test26_B(clip c) {
c
if(current_frame % 2 == 0) {
Subtitle(String(current_frame,"%.0f]"))
}
return last
}
""")
Function Test26_B(clip c) {
return c.Scriptclip("_LOW_Test26_B")
}
blankclip
test26_B
Or this if GImport-ed under v2.60 std
Function _LOW_Test26_B(clip c) {
c
if(current_frame % 2 == 0) {
Subtitle(String(current_frame,"%.0f]"))
}
return last
}
Function Test26_B(clip c) {
return c.Scriptclip("_LOW_Test26_B")
}
blankclip
test26_B
_LOW_Test26_B is parsed by Gscript, but called from within v2.60 std Scriptclip.
Also this if GImport-ed
Function Test26_B(clip c) {
Function _LOW_Test26_B(clip c) {
c
if(current_frame % 2 == 0) {
Subtitle(String(current_frame,"%.0f]"))
}
return last
}
return c.Scriptclip("_LOW_Test26_B")
}
blankclip
test26_B
EDIT: the parts in red above [and prev code block] should not be GImported, should be in client script.
defo going to bed now.
The Multi-Instance scripts developed by Martin53 and Gavino, use above style calls with simple single line scriptclip and GScript enabled function.
[I use that style a lot]
Maybe should defo be going onto wiki, cos I'm bound to forget why again.
EDIT: VX, the error occurs at first curly brace, need external lo level function for VFX2.
VFX2="""
if(!mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) { # <<<<<<<<
RT_DBaseSetField(Analyze5DB,current_frame,0,2)
Assert (FALSE, "Mask image is invalid.") # Not really a good place for Assert()
}
So like this [but still not like your images - yet]
function Analyze5FX(clip clp, val "mask", int "Mode", int "Analyze5Th", string "Ignore", int "Show") {
Function _VFX2(clip c,clip mask) {
c
if(!mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) {
Assert (FALSE, "Mask image is invalid.") # Not really a good place for Assert()
}
VW = Last.Width
VH = Last.Height
# Convert X,Y,W,H coords to L,T,-R,-B coords
mL = YIRL_X
mT = YIRL_Y
mR = -VW + mL + YIRL_W
mB = -VH + mT + YIRL_H
if(mL < 8 && -1*mR < 8 || mT < 8 && -1*mB < 8) {
Assert (FALSE, "Mask image or Loc is invalid.") # Not really a good place for Assert()
}
# Coords mod2 round up
mL = mL + (mL % 2)
mT = mT + (mT % 2)
mR = mR - (mR % 2)
mB = mB - (mB % 2)
# Crop 2x2 pxs area from above or below the logo and make a background from it
mid = (VW-mL+mR)/2+mL
mid = mid + (mid % 2)
clp2x2 = (mT >= -1*mB) ? Last.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : Last.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)
Return clp2x2.PointResize(VW, VH) # Same size as input clip
}
mask = default (mask , "")
Mode = default (Mode , 1 )
Analyze5Th = default (Analyze5Th , 15)
Ignore = default (Ignore , "none")
Show = default (Show , 0)
Assert (!(Mode < 1 || Mode > 2), """"Mode" value must be between 1 and 2.""")
Assert (!(Analyze5Th < 1 || Analyze5Th > 255), """"Analyze5Th" value must be between 1 and 255.""")
Assert (!(Show < 0 || Show > 2), """"Show" value must be between 0 and 2.""")
Assert ((Ignore == "top" || Ignore == "bottom" || Ignore == "left" || Ignore == "right" || Ignore == "none"), """"Ignore" string must be 'top', 'bottom', 'left', 'right' or 'none'.""")
VW = clp.Width
VH = clp.Height
Th = Analyze5Th
mask = (IsClip(mask)) ? mask.ConvertToY8(matrix="PC.709").MTballoon2PX(2) : nop
clpS = clp.ScriptClip("subtitle(string(current_frame))")
# Construct a clip to check thresholds (for deblending analysis) #
#================================================================#
if(Mode == 1) {
ARGS="mask"
clpB = clp.GScriptClip("_VFX2("+args+")", local=true, args=ARGS, after_frame=true)
Msk1 = mask.MTballoon2PX(2).mt_logic(mask, mode="xor") # 2px wide mask around logo (+2px offset from the base mask)
clp5 = clpB.Overlay(clp, mask=Msk1)
} else {
# Construct a clip to check thresholds (for Automask=1) #
#=======================================================#
cT = clp.crop(4, 4, -4, -1*(VH-6))
cB = clp.crop(4, VH-6, -4, -4)
cL = clp.crop(4, 4, -1*(VW-6), -4)
cR = clp.crop(VW-6, 4, -4, -4)
if(Ignore == "top") {
cT = cB
} else if (Ignore == "bottom") {
cB = cT
} else if (Ignore == "left") {
cL = cR
} else if (Ignore == "right") {
cR = cL
}
wc = StackHorizontal(cr,cl).TurnLeft
hc = StackVertical(ct,cb)
if(wc.width > hc.width) {
hc = hc.PointResize(wc.width, hc.height)
out = StackVertical(wc,hc)
} else if(wc.width < hc.width) {
wc = wc.PointResize(hc.width, wc.height)
out = StackVertical(wc,hc)
} else {
out = StackVertical(wc,hc)
}
clp5 = (Show == 2) ? out.PointResize(VW, VH) : out
}
# Delete frames above thresholds (that leaves us with the suitable frames for analysis) #
#=======================================================================================#
#return clp5
# Mod of Gavino's DeleteFrames() - https://forum.doom9.org/showthread.php?t=163107
clp5
fc = FrameCount()
res = BlankClip(clp, length=0)
condition = "YPlaneMinMaxDifference >" +String(Th)+ " || UPlaneMinMaxDifference >" +String(Round(Th/2))+ " || VPlaneMinMaxDifference >" +String(Round(Th/2))
current_frame = 0
while (current_frame < fc) {
while (Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
if (current_frame < fc) { # not at end
start = current_frame # start of wanted section
while (!Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
clpX = (Show == 1) ? clpS : (Show == 2) ? clp5 : clp # 0: Original frames, 1: Original frames + frameNo, 2: Constructed clips (Mode=2 clip is upsized for show)
res = res + clpX.Trim(start, start-current_frame)
}
}
Assert (!(res.FrameCount < 2), """No frames found to analyze, increase "Analyze5Th".""")
return res
}
Client
IsPlus = FindStr(VersionString.lcase,"avisynth+")!=0
(IsPlus) ? Import(".\Analyze5FX.avs") : GImport(".\Analyze5FX.avs")
x = LSMASHVideoSource(".\899.mp4")
x = x.crop(1124,24,-52,-636).Trim(30,100) # trimed for speed
mask = ImageSource(".\WieMHwJ.png",0,0)
x=x.BilinearResize(x.width*4,x.height*4)
mask=mask.BilinearResize(mask.width*4,mask.height*4)
# Mode 1 test
m0 = x.Analyze5FX(mask=mask, mode=1, show=0)
m1 = x.Analyze5FX(mask=mask, mode=1, show=1)
m2 = x.Analyze5FX(mask=mask, mode=1, show=2)
mu = Stackhorizontal(m0.AddBorders(0,0,2,0,$000000), m0)
md = Stackhorizontal(m1.AddBorders(0,0,2,0,$000000), m2)
Stackvertical(mu.AddBorders(0,0,0,2,$000000), md)
VoodooFX
11th November 2021, 08:33
if(current_frame % 2 ==0) { # <<<<<<<< Error at curly brace, scriptclip dont know what it is
Ha, told ya that error is at the first curly bracket (https://forum.doom9.org/showthread.php?p=1956958#post1956958). :)
the parts in red above [and prev code block] should not be GImported, should be in client script.
That's a dealbreaker, but the first working example works. Here is version with less Inception:
User script:
GImport("c:\Analyze5FX.avs")
GImport("c:\InpaintDelogo.avs")
x = LSMASHVideoSource("D:\899.mp4")
x = x.crop(1124,24,-52,-636).Trim(30,100) # trimed for speed
mask = ImageSource("D:\mask.bmp",0,0)
# Mode 1 test
m0 = x.Analyze5FX(mask=mask, mode=1, show=0)
m1 = x.Analyze5FX(mask=mask, mode=1, show=1)
m2 = x.Analyze5FX(mask=mask, mode=1, show=2)
mu = Stackhorizontal(m0.AddBorders(0,0,2,0,$000000), m0)
md = Stackhorizontal(m1.AddBorders(0,0,2,0,$000000), m2)
Stackvertical(mu.AddBorders(0,0,0,2,$000000), md)
Analyze5FX.avs:
Function VFX2(clip mask, string Analyze5DB) {
Status = (mask.RT_YInRangeLocate(Baffle=1,lo=255,hi=255)) ? 1 : 2
if(Status==1) {
RT_DBaseSet(Analyze5DB,0,Status,YIRL_X,YIRL_Y,YIRL_W,YIRL_H)
} else {
RT_DBaseSetField(Analyze5DB,0,0,Status)
}
return Last
}
function Analyze5FX(clip clp, val "mask", int "Mode", int "Analyze5Th", string "Ignore", int "Show") {
mask = default (mask , "")
Mode = default (Mode , 1 )
Analyze5Th = default (Analyze5Th , 15)
Ignore = default (Ignore , "none")
Show = default (Show , 0)
Assert (!(Mode < 1 || Mode > 2), """"Mode" value must be between 1 and 2.""")
Assert (!(Analyze5Th < 1 || Analyze5Th > 255), """"Analyze5Th" value must be between 1 and 255.""")
Assert (!(Show < 0 || Show > 2), """"Show" value must be between 0 and 2.""")
Assert ((Ignore == "top" || Ignore == "bottom" || Ignore == "left" || Ignore == "right" || Ignore == "none"), """"Ignore" string must be 'top', 'bottom', 'left', 'right' or 'none'.""")
VW = clp.Width
VH = clp.Height
Th = Analyze5Th
mask = (IsClip(mask)) ? mask.ConvertToY8(matrix="PC.709").MTballoon2PX(2) : nop
clpS = clp.ScriptClip("subtitle(string(current_frame))")
# Construct a clip to check thresholds (for deblending analysis) #
#================================================================#
if(Mode == 1) {
# Get coords of the logo mask
Analyze5DB = ("~InpaintDelogo_Analyze5_"+RT_LocalTimeString+".DB").RT_GetFullPathName
RT_DBaseAlloc(Analyze5DB,1,"iiiii")
ARGS="Analyze5DB"
Parse = mask.ScriptClip("VFX2("+args+")", local=true, args=ARGS, after_frame=true)
Parse.RT_YankChain(n=0)
Assert (!(RT_DBaseGetField(Analyze5DB,0,0) == 2), "Mask image is invalid.")
mX = RT_DBaseGetField(Analyze5DB,0,1)
mY = RT_DBaseGetField(Analyze5DB,0,2)
mW = RT_DBaseGetField(Analyze5DB,0,3)
mH = RT_DBaseGetField(Analyze5DB,0,4)
RT_FileDelete(Analyze5DB)
# Convert X,Y,W,H coords to L,T,-R,-B coords
mL = mX
mT = mY
mR = -VW + mW + mX
mB = -VH + mY + mH
Assert (!(mL < 8 && -1*mR < 8 || mT < 8 && -1*mB < 8), "Mask image or Loc is invalid.")
# Coords mod2 round up
mL = mL + (mL % 2)
mT = mT + (mT % 2)
mR = mR - (mR % 2)
mB = mB - (mB % 2)
# Crop 2x2 pxs area from above or below the logo and make a background from it
mid = (VW-mL+mR)/2+mL
mid = mid + (mid % 2)
clp2x2 = (mT >= -1*mB) ? clp.crop(mid-2, mT-2, -1*(VW-mid), -VH+mT+2) : clp.crop(mid-2, VH+mB-2, -1*(VW-mid), mB+2)
clpB = clp2x2.PointResize(VW, VH)
Msk1 = mask.MTballoon2PX(2).mt_logic(mask, mode="xor") # 2px wide mask around logo (+2px offset from the base mask)
clp5 = clpB.Overlay(clp, mask=Msk1)
} else {
# Construct a clip to check thresholds (for Automask=1) #
#=======================================================#
cT = clp.crop(4, 4, -4, -1*(VH-6))
cB = clp.crop(4, VH-6, -4, -4)
cL = clp.crop(4, 4, -1*(VW-6), -4)
cR = clp.crop(VW-6, 4, -4, -4)
if(Ignore == "top") {
cT = cB
} else if (Ignore == "bottom") {
cB = cT
} else if (Ignore == "left") {
cL = cR
} else if (Ignore == "right") {
cR = cL
}
wc = StackHorizontal(cr,cl).TurnLeft
hc = StackVertical(ct,cb)
if(wc.width > hc.width) {
hc = hc.PointResize(wc.width, hc.height)
out = StackVertical(wc,hc)
} else if(wc.width < hc.width) {
wc = wc.PointResize(hc.width, wc.height)
out = StackVertical(wc,hc)
} else {
out = StackVertical(wc,hc)
}
clp5 = (Show == 2) ? out.PointResize(VW, VH) : out
}
# Delete frames above thresholds (that leaves us with the suitable frames for analysis) #
#=======================================================================================#
# Mod of Gavino's DeleteFrames() - https://forum.doom9.org/showthread.php?t=163107
clp5
fc = FrameCount()
res = BlankClip(clp, length=0)
condition = "YPlaneMinMaxDifference >" +String(Th)+ " || UPlaneMinMaxDifference >" +String(Round(Th/2))+ " || VPlaneMinMaxDifference >" +String(Round(Th/2))
current_frame = 0
while (current_frame < fc) {
while (Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
if (current_frame < fc) { # not at end
start = current_frame # start of wanted section
while (!Eval(condition) && current_frame < fc) {
current_frame = current_frame+1
}
clpX = (Show == 1) ? clpS : (Show == 2) ? clp5 : clp # 0: Original frames, 1: Original frames + frameNo, 2: Constructed clips (Mode=2 clip is upsized for show)
res = res + clpX.Trim(start, start-current_frame)
}
}
Assert (!(res.FrameCount < 2), """No frames found to analyze, increase "Analyze5Th".""")
return res
}
Now same needs to be done with the subs extractor thingy and it should be compatible with Avs 2.6 again (just no autoloading there). :thanks:
EDIT:
Just remembered one thing I didn't understand, if you feed RGB24 clip to that frame deleting block it gave me some error.
condition needs to be changed to condition = "RPlaneMinMaxDifference >" +String(Th), should work with mode=2 (no need for mask there).
EDIT2:
Removed "Double GScript" stuff from Analyze5FX.avs.
StainlessS
11th November 2021, 14:03
Ha, told ya that error is at the first curly bracket.
Clever clogs.
That's a dealbreaker, but the first working example works.
I just meant that you dont [usually] put your entire script including eg Avisource("...") in Plugins, nor do you Import nor GImport an entire script,
so you would not add your "User script" to the GImport script. [that was intended for everybody, not just a capable coder like yourself].
Gotta get some milk [mine sour].
EDIT: I just noticed that you've stolen a CopyRight'ed image of mine for your avatar.
Still not got the damn thing working properley, on last try (using more like the original patch code), it was prodcuing something quite akin
to the mandelbrot stuff, looks well weird.
https://i.postimg.cc/HLBXTG4m/Uglarm-Client-00.jpg (https://postimages.org/)
If there had been a logo in above images, they would certainly have been eliminated.
Had I done above patterns deliberately, I would have been quite proud if it. :)
That is very naughty of you, my legal brief will be in contact shortly. [EDIT: 'Brief', Brit slang for solicitor/lawyer or more specifically barrister]
Its no wonder that you're a "Banned User".
VoodooFX
11th November 2021, 20:31
you've stolen a CopyRight'ed image of mine for your avatar.
Yeap, I'm infamous for stealing the Mandelbrot's abstract art from the museums.
I guess that's why they banned me. There is an old murican proverb (https://www.youtube.com/watch?v=eKgPY1adc0A): Ban me once, shame on... shame on you, the banned can't be banned again. :D
Anyway, here you go:
# Version 1.46 : 2021/11/11. Support for AviSynth v2.6 [with the StainlessS's help].
And there is a "small" price to pay. [I would blame StainlessS]
Notes for AviSynth v2.6 users:
# "InpaintDelogo.avsi" needs to be renamed to "InpaintDelogo.avs",
# and loaded manually in AviSynth script with: GImport("C:\AviSynth 2.5\plugins\InpaintDelogo.avs")
# Subs extraction is up to 600% slower than with AviSynth+!
EDIT:
OH gosh, oh tinboy, YOU [we] broke something in AvsPmod... definitely something weird is going on... I need to get that can of beer now...
StainlessS
11th November 2021, 21:09
GScript("""
Function VFX1_GScript(clip c, string FrameDB, int CropW, int CropH) {
c
n = current_frame
Status = RT_DBaseGetField(FrameDB,n,0)
if(Status == 0) { # Unknown Status
Status = crop(CropW,CropH,-1*CropW,-1*CropH).AverageLuma.Sign
if(Status == 1) { RT_DBaseSet(FrameDB,n,Status) }
}
Return Last
}
""")
Nah, Nah, Nah !!!, I might as well talk to the wall.
When you GImport(), you dont need the GScript thingy, Instead of, not as well as.
[Dont know what effect doubling up on Gscript thingy will have, cant be good]
Nice George Dubya clip, says it all really :)
EDIT:
Also, you can just put the script [avs or avsi] in AvsInit GIMPORT folder, does auto load for scripts [with GSCript("...") wrappers REMOVED].
AvsInit:- https://forum.doom9.org/showthread.php?t=176749&highlight=AvsInit
Not sure, maybe Real.Finder has a similar functioning setup.
EDIT:
Test script
blankClip
ScriptClip("""RT_Subtitle("%d]",current_frame)""")
And Debug output from AvsInit:
00000348 20:27:00 AvsInit:
00000349 20:27:00 AvsInit: Auto load plugins script ENTRY
00000350 20:27:00 AvsInit:
00000351 20:27:00 AvsInit_ShowInfo:
00000352 20:27:00 AvsInit_ShowInfo: AvsInit_Version = 1.10
00000353 20:27:00 AvsInit_ShowInfo: GScript Available = AVS+
00000354 20:27:00 AvsInit_ShowInfo: RT_Stats Version = 2.00Beta13
00000355 20:27:00 AvsInit_ShowInfo: SysInfo Version = 0.127000
00000356 20:27:00 AvsInit_ShowInfo: SysInfo.dll DIR = C:\VideoTools\AvisynthRepository\AVSPLUS370_x86\plugins
00000357 20:27:00 AvsInit_ShowInfo: VersionString = AviSynth+ 3.7.1 (r3482, master, i386)
00000358 20:27:00 AvsInit_ShowInfo: SetMemoryMax = 1024
00000359 20:27:00 AvsInit_ShowInfo: Avisynth Bitness = 32
00000360 20:27:00 AvsInit_ShowInfo: WorkingDir = C:\VideoTools\AvisynthRepository\AVSPLUS370_x86\plugins\
00000361 20:27:00 AvsInit_ShowInfo: ProcessName = C:\NON-INSTALL\VDUB\VDUB2\VirtualDub.exe
00000362 20:27:00 AvsInit_ShowInfo: ParentProcessName = PSPad.exe
00000363 20:27:00 AvsInit_ShowInfo: OSVersionString = Windows 10 (x64) (Build 18363)
00000364 20:27:00 AvsInit_ShowInfo: OSVersionNumber = 10.000000
00000365 20:27:00 AvsInit_ShowInfo: OS Bitness = 64
00000366 20:27:00 AvsInit_ShowInfo: CPUName = Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz / Coffee Lake (Core i7)
00000367 20:27:00 AvsInit_ShowInfo: Cores = 06:12 (Phy:Log)
00000368 20:27:00 AvsInit_ShowInfo: CPU Extensions = MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, FMA3, RDSEED, ADX, AVX, AVX2
00000369 20:27:00 AvsInit_ShowInfo: Total Memory = 32621MB
00000370 20:27:00 AvsInit_ShowInfo: Avail Memory = 29677MB'
00000371 20:27:00 AvsInit_ShowInfo: Screen Res = 1920x1080
00000372 20:27:00 AvsInit_ShowInfo: Screen BitsPerPixel = 32
00000373 20:27:00 AvsInit_ShowInfo: Time = Thursday 11 November 2021 20:27:00[GMT Standard Time]
00000374 20:27:00 AvsInit_ShowInfo: User TEMP Dir = C:\Users\steve\AppData\Local\Temp
00000375 20:27:00 AvsInit_ShowInfo: ComSpec = C:\Windows\system32\cmd.exe
00000376 20:27:00 AvsInit_ShowInfo: Computer Name = OMEN-W10P5
00000377 20:27:00 AvsInit_ShowInfo: User Name = steve
00000378 20:27:00 AvsInit_ShowInfo:
00000379 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\DBSC.avsi
00000380 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\dither.avsi
00000381 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\Favc.avsi
00000382 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\InpaintDelogo.avsi
00000383 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\JohnFPS.avsi
00000384 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\McDegrain.avsi
00000385 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\Misc.avsi
00000386 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\RoboSplice.avsi
00000387 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\SetMTMode.avsi
00000388 20:27:00 AvsInit_DImport: Importing ... C:\VideoTools\AvisynthRepository\GIMPORT\SpotLess.avsi
00000389 20:27:00 AvsInit_DImport: IMPORTED 10 scripts from 'C:\VideoTools\AvisynthRepository\GIMPORT'
00000390 20:27:00 AvsInit_DImport: IMPORTED 0 scripts from 'C:\VideoTools\AvisynthRepository\AVSPLUS370_x86\plugins\GIMPORT'
00000391 20:27:00 AvsInit_DLoadConditional: STARTING DLL SCAN on C:\VideoTools\AvisynthRepository\MACHINE
00000392 20:27:00 AvsInit_DLoadConditional: DePan.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000393 20:27:00 AvsInit_DLoadConditional: DePanEstimate.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000394 20:27:00 AvsInit_DLoadConditional: dfttest.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000395 20:27:00 AvsInit_DLoadConditional: DGDecodeNV.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000396 20:27:00 AvsInit_DLoadConditional: FFMS2.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000397 20:27:00 AvsInit_DLoadConditional: LSMASHSource.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000398 20:27:00 AvsInit_DLoadConditional: masktools2.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000399 20:27:00 AvsInit_DLoadConditional: MedianBlur2.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000400 20:27:00 AvsInit_DLoadConditional: mvtools2.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000401 20:27:00 AvsInit_DLoadConditional: nnedi3.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000402 20:27:00 AvsInit_DLoadConditional: RemoveDirt.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000403 20:27:00 AvsInit_DLoadConditional: TIVTC.dll LoadPlugin OK from 2_WIN7_0\2_AVS26x86\0_CPP
00000404 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\DePan.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000405 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\DePanEstimate.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000406 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\dfttest.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000407 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\ffms2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000408 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\masktools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000409 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\MedianBlur2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000410 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\mvtools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000411 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\nnedi3.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000412 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\2_AVS26x86\0_CPP\TIVTC.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000413 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\1_AVS26Stdx86\0_CPP\ffms2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000414 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\1_AVS26Stdx86\0_CPP\masktools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000415 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\1_AVS26Stdx86\0_CPP\mvtools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000416 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\1_AVS26Stdx86\0_CPP\nnedi3.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000417 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\1_AVS26Stdx86\0_CPP\RemoveDirt.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000418 20:27:00 AvsInit_DLoadConditional: DGDecode.dll LoadPlugin OK from 0_XP\0_AVS25x86\0_CPP
00000419 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\0_AVS25x86\0_CPP\ffms2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000420 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\0_AVS25x86\0_CPP\LSMASHSource.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000421 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\0_AVS25x86\0_CPP\masktools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000422 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\0_AVS25x86\0_CPP\mvtools2.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000423 20:27:00 AvsInit_DLoadConditional: !!! Skipping File 0_XP\0_AVS25x86\0_CPP\RemoveDirt.dll, already loaded from 2_WIN7_0\2_AVS26x86\0_CPP
00000424 20:27:00 AvsInit_DLoadConditional: STARTING SCRIPT SCAN on C:\VideoTools\AvisynthRepository\MACHINE
00000425 20:27:00 AvsInit_DLoadConditional: 13 dll's LOADED : 19 dll's SKIPPED : 0 dll's FAILED
00000426 20:27:00 AvsInit_DLoadConditional: 0 scripts LOADED : 0 Scripts SKIPPED : 0 scripts FAILED
VoodooFX
11th November 2021, 21:37
When you GImport(), you dont need the GScript thingy.
That's another problem I guess, now AvsPmod just doesn't start, AvS+ and no GImport there, it just crash at start when trying to autoload InpaintDelogo.avsi. If you rename avsi to avs, start AvsPmod and rename avs back, then AvsPmod loads script and the script works OK... weird... need to investigate.
StainlessS
11th November 2021, 21:53
[after remove the GScript("...") thingy]
You can just put eg "InPaintDelogo_AutoLoader.avsi" into your plugins, something like
InPaintDelogo_AutoLoader.avsi
IsPlus = FindStr(VersionString.lcase,"avisynth+")!=0
(IsPlus) ? Import("SOMEPATH\Analyze5FX.avs") : GImport("SOMEPATH\Analyze5FX.avs") # where SOMEPATH might be ".\VoodooFX" or other.
Its not rocket science. :)
For AvsInit(), just drop the InPaintDelogo.avsi into one of the GIMPORT folders [has one for each version of Avisynth, but most might use the all Avisynth versions GIMPORT folder].
EDIT:
Subs extraction is up to 600% slower than with AviSynth+!
There has gotta be something weird happening there [maybe the double Gscript/GImport thing], not a lot of difference between
Gscript and AVS+ Gscript extensions usually.
EDIT: When I say "has one for each version of Avisynth", I use and intend use with Groucho2004 "Universal Avisynth Installer":- https://forum.doom9.org/showthread.php?t=172124
which allows easy switch to one of multiple versions of avisynth [1 x86, and 1 x64, simultaneous installed].
VoodooFX
11th November 2021, 22:39
AvsPmod crash at start is fixed:
# Version 1.47 : 2021/11/11. Fixed: "Double Gscript".
Same slow on v2.6, but hey now with the AvsInit ad: :)
# Notes for AviSynth v2.6 users:
# Requirement: GScript ( http://avisynth.nl/index.php/GScript ).
# "InpaintDelogo.avsi" needs to be renamed to "InpaintDelogo.avs",
# and loaded manually in AviSynth script with: GImport("C:\AviSynth 2.5\plugins\InpaintDelogo.avs"),
# or use AvsInit for autoloading ( https://forum.doom9.org/showthread.php?t=176749 ).
# Subs extraction is up to 600% slower than with AviSynth+!
VoodooFX
11th November 2021, 22:56
There has gotta be something weird happening there [maybe the double Gscript/GImport thing], not a lot of difference between
Gscript and AVS+ Gscript extensions usually.
I get (v1.47, no double Gscript):
Extract test: 5s in AvS+, 32s in AvS v2.6.
Mask + Extract test: 55s in AvS+, 80s in AvS v2.6.
Files:
https://we.tl/t-942gjNbEso
GImport("c:\InpaintDelogo.avs") # For v2.6
ImgDir = "d:\IMAGES\"
# Extract test:
LWLibavVideoSource("d:\subs_anime_mask.mkv")
SubsMask2Img(ImgDir=ImgDir)
#~ # Mask + Extract test:
#~ LWLibavVideoSource("d:\subs_anime.mkv")
#~ InpaintDelogo(Loc="0,0,-0,-0",
#~ \ oPP=0,
#~ \ DynMask=4, DynTune=220, DynMask4H=60, KillNoise=-5,
#~ \ Show=4, Extract=1, ImgDir=ImgDir)
Danette
14th November 2021, 20:01
I’m not sure that I understand what the purpose of “Dynamic mask” is. Is it intended to mask a changing logo, within a specified Loc="x,x,-x,-x", and within a single video or can it chase an identical logo that is applied to multiple videos, but in slightly different coordinates …or both?
Perhaps this will be clearer if I explain by way of an example of what I want:
I have 100 episodes of a show. The same sized logo appears in each show. However, that logo, while having fixed coordinates within each episode, may be in slightly different coordinates from one episode to another. I would like to have InpaintDelogo find the logo, within a defined Loc="x,x,-x,-x", and apply the mask wherever that logo appears in the defined Loc="x,x,-x,-x". This Loc="x,x,-x,-x" will have the same coordinates for each episode.
VoodooFX
14th November 2021, 22:06
I’m not sure that I understand what the purpose of “Dynamic mask” is. Is it intended to mask a changing logo, within a specified Loc="x,x,-x,-x", and within a single video or can it chase an identical logo that is applied to multiple videos, but in slightly different coordinates …or both?
“Dynamic mask” is a whole B/W mask clip in Y8, same frame length as video and same dimensions as Loc area, "object" can change there every frame, you can supply such mask from external plugin or use some internal methods.
I don't know any identical object recognition plugin for Avisynth, wonkey_monkey mentioned that he has some experimental plugin, but that's it. (EDIT: There is some AvisythTrackin plugin)
There are few internal DynMask methods to do the dynamic masks for some specific objects like bright-nontransparent logos (like subtitles). (EDIT: There is StainlessS's DetSub plugin)
From your description you would need to use a one frame/image mask, if it changes location in another video then you need to create another image mask for that video. If you don't know how to create a mask in Photoshop then you can use "Automask" parameter and its sub-parameters to do it for you.
(EDIT: If logo is non-transparent and moves just one pixel, then with Inflate=2 you probably can do all videos with same mask)
Post some screens of that logo/mask/script and I can advice further on the matter. There is "Show=1" parameter so you could post screen of that too.
Danette
14th November 2021, 23:58
Thanks. I guess we’ll have to wait for AI.
I think you have an exact understanding of my intent, so I’ll do what I used to do with VDub DeLogo which is, as you said, creating new masks whenever an adjustment is needed for a new episode. I can do this, easily, with PhotoImpact. However, I will be using InpaintDelogo, as I’ve convinced myself that it is far better than VDub DeLogo. I was just hoping that a non-manual adjustment capability was buried in there somewhere.
The Inflate=2 won’t be enough. If Inflate=x had the option to go up to about 20 pixels, then I could adapt to that. If it did inflate that much, even better would be inflating by one, or more, of the 4 coordinates. Generally, these logos only drift horizontally, so top and bottom inflation is not needed.
VoodooFX
15th November 2021, 00:55
Thanks. I guess we’ll have to wait for AI.
AI is not necessary for same object recognition.
I will be using InpaintDelogo, as I’ve convinced myself that it is far better than VDub DeLogo.
If there were anything better in VDub'd Delogo then I would have included option for it.
Generally, these logos only drift horizontally, so top and bottom inflation is not needed.
Then it is just few seconds to move it few pixels in the image editors. Inflate just expands a base mask the few pixels to cover possible artifacts at the edges.
Danette
18th November 2021, 02:44
I am now attempting to apply InpaintDelogo(mask="xxxx.bmp", Loc="xxx,xxx,-xxx,-xxx",Mode="Inpaint") to remove the first logo, but have run into a problem. How do I specify that a mask be applied to one or more ranges of frames in a video? For example; if I want to remove the logo that is present between frames 10870 and 11870 and then also between frames 13000 and 14000. This was simple with VDub Delogo, but I cannot find the method for InpaintDelogo.
VoodooFX
18th November 2021, 04:05
I want to remove the logo that is present between frames 10870 and 11870 and then also between frames 13000 and 14000.
Use Trim. Here a basic example how it's done:
o=DGDecode_mpeg2source("D:\clip.d2v")
# Deinterlace before delogo:
c=o.QTGMC().SelectEven()
# Split video with Trim() & delogo on some ranges:
t1=c.Trim(0, 10869)
t2=c.Trim(10870, 11870).InpaintDelogo()
t3=c.Trim(11871, 12999)
t4=c.Trim(13000, 14000).InpaintDelogo()
t5=c.Trim(14001, 999999)
# Then join video back:
t1+t2+t3+t4+t5
Danette
18th November 2021, 05:31
Ugh! I had considered that. That’s fine for one logo and one or two segments in a couple of videos, but if I have 3-4 logos, all in 1-20 different frame segments in a single video, that’s quite an unwieldy mess of script. I could be looking at 20-30 lines, or more, of trim script. Then, multiply that by a couple hundred videos. VDub’s Delogo starts to look really good as the optimal choice, despite somewhat inferior logo removal.
I appreciate your help, but InpaintDelogo does not seem to be a good choice for situations such as mine.
VoodooFX
18th November 2021, 09:59
Ugh! I had considered that. That’s fine for one logo and one or two segments in a couple of videos, but if I have 3-4 logos, all in 1-20 different frame segments in a single video, that’s quite an unwieldy mess of script.
Then you need to learn a bit more about AviSynth. ;)
Dealing with lots of ranges and logos with ClipClop:
V1 = InpaintDelogo( mask="D:\logo1.bmp")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
V3 = InpaintDelogo( mask="D:\logo3.bmp")
Ranges=""" # Various ranges for various logos
1 0,500; 1 3400,3800; 1 4000,4444
2 2020,2500
3 1100,1900
"""
ClipClop(Last,V1,V2,V3,scmd=Ranges,show=false)
Or ClipClop with nicknames:
V1 = InpaintDelogo( mask="D:\logo1.bmp")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
V3 = InpaintDelogo( mask="D:\logo3.bmp")
NickNames =""" # Psuedonyms for clips (clip index number)
Logo1 = 1
Logo2 = 2
Logo3 = 3
"""
Ranges=""" # Various ranges for various logos
Logo1 0,500
Logo3 1100,1900
Logo2 2020,2500
Logo1 3400,3800
Logo1 4000,4444
"""
ClipClop(Last,V1,V2,V3,scmd=Ranges,nickname=NickNames,show=false)
Or RemapFrames:
V1 = InpaintDelogo( mask="D:\logo1.bmp")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
V3 = InpaintDelogo( mask="D:\logo3.bmp")
ReplaceFramesSimple(Last,V1,Mappings="[0 500] [3400 3800] [4000 4444]")
ReplaceFramesSimple(Last,V2,Mappings="[2020 2500]")
ReplaceFramesSimple(Last,V3,Mappings="[1100 1900]")
Danette
18th November 2021, 14:01
Then you need to learn a bit more about AviSynth.
You are making an understatement ...I need to learn a lot more about Avisynth!
Thanks for the lesson. Odd that my searching didn't find any of that approach. I will work with that script to see how well it works for my situation. It looks like it should do the job.
VoodooFX
18th November 2021, 14:39
If some of your ranges/logos overlap then I dunno if ClipClop will do the job properly in those examples. StainlessS should know.
RemapFrames example would need adjustment to do overlaps.
Danette
18th November 2021, 16:00
Yes, the logos are all overlaps, with some instances of three at a time.
VDub Delogo handles them and, I suspect, these, or similar, codes were used.
StainlessS
18th November 2021, 16:04
The later [in SCMD/CMD] range/frame overrides previously specified ranges/frames,
specifying clip index 0, restores to original source [first clip arg].
SCMD="""
1 100,200 # replace range 100 to 200 with range from clip 1
0 50 # but frame 50 restored to source frame
"""
EDIT:
with some instances of three at a time.
Ho Ho ho, good luck with that.
VoodooFX
18th November 2021, 16:37
Yes, the logos are all overlaps, with some instances of three at a time.
Then this should work, I think:
Ranges1="""
1 0,500; 1 3400,3800; 1 4000,4444
"""
Ranges2="""
1 2020,2500
"""
Ranges3="""
1 1100,1900
"""
V1 = InpaintDelogo( mask="D:\logo1.bmp")
ClipClop(Last,V1,scmd=Ranges1,show=false)
V2 = InpaintDelogo( mask="D:\logo2.bmp")
ClipClop(Last,V2,scmd=Ranges2,show=false)
V3 = InpaintDelogo( mask="D:\logo3.bmp")
ClipClop(Last,V3,scmd=Ranges3,show=false)
Or:
V1 = InpaintDelogo( mask="D:\logo1.bmp")
ReplaceFramesSimple(Last,V1,Mappings="[0 500] [3400 3800] [4000 4444]")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
ReplaceFramesSimple(Last,V2,Mappings="[2020 2500]")
V3 = InpaintDelogo( mask="D:\logo3.bmp")
ReplaceFramesSimple(Last,V3,Mappings="[1100 1900]")
Danette
18th November 2021, 20:34
Ho Ho ho, good luck with that.
As a point of curiosity, any idea how Karel Suhajda accomplished this, so easily (from a users standpoint) in VDub? Is VDub simply more dynamic, for code, than Avisynth?
V1 = InpaintDelogo( mask="D:\logo1.bmp")
ReplaceFramesSimple(Last,V1,Mappings="[0 500] [3400 3800] [4000 4444]")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
ReplaceFramesSimple(Last,V2,Mappings="[2020 2500]")
V3 = InpaintDelogo( mask="D:\logo3.bmp")
ReplaceFramesSimple(Last,V3,Mappings="[1100 1900]")
I’ll try this, in the next several days, as it seems that the first code is going to require the same 20-30 script lines, per video, as the trim approach would.
StainlessS
19th November 2021, 03:40
Sorry, I have no idea what Karel Suhajda accomplished, nor how.
VoodooFX
19th November 2021, 22:20
I played a bit with new analyze func, good results so far, but I compared it to AviUtl logoscan and I get there selected significantly different frames, maybe Threshold there doesn't mean MinMax threshold...
Can anyone who can read c++ look there and tell what is done with that Threshold param?
In filter.cpp (https://github.com/makiuchi-d/delogo-aviutl/blob/master/logoscan/filter.cpp) /scanpix.cpp (https://github.com/makiuchi-d/delogo-aviutl/blob/master/logoscan/scanpix.cpp) I see that it's defined as tTHY and then I can't understand what is going on with it there.
I’ll try this, in the next several days, as it seems that the first code is going to require the same 20-30 script lines, per video, as the trim approach would.
20-30 lines in script is usual... Do you write your scripts in MeGUI's editor? If you do then I understand your frustration with that small screen. Get AvsPmod (https://forum.doom9.org/showthread.php?t=175823)!
VoodooFX
21st November 2021, 10:36
Does anyone have wishes/suggestions about delogo and stuff?
I've decided to rewrite automask and deblend, to do it right this time. Incorporating smart analysis into current hacks needs to tweak them, I think for me it's easer just to remove those hacks and do a proper delogo in the first place... They usually work well in normal cases, but not for those poor souls who wants to delogo Nth recompressed videos (where logo/blending is simply damaged by artifacts).
[Those hacks are to work around some flaws in the Karel Suhajda's delogo design, which was copied and consequently flaws were inherited by AvsInpaint].
What about idea to incorporate all masks into one file? That would make it more universal, in case you would want to use masks on other videos with same logo, you would need to change only coords to move all logo masks, but at the current state you can move only by 2 pxs, it's possible to add compatibility to 1px, but lots of stuff then need to be rechecked/rewritten and probably there would be some performance penalty. I'm not sure if it's worth to bother, there are no problems for the savy avs users...
kedautinh12
21st November 2021, 13:15
I wish inpaintdelogo easy to use :D
VoodooFX
21st November 2021, 13:30
I wish inpaintdelogo easy to use :D
There will be even more parameters, but I promise I'll stop after 100. [word of the boy scout] :D
But you never stated what is hard there for you, almost everything there happens automatically, except setting loc of the logo and the analysis frames for deblend, but in v2 analysis stuff will be automated.
Probably you didn't used previous delogo scripts where there were less parameters, and you could change any of them but still that didn't made logo disappear. :D
dot75
21st November 2021, 17:46
hello I would like to hide this parental advisory I understood how to hide the round logo on the other hand it does not work for the advisory
InpaintDelogo( Loc="1018,922,-254,-106)
VoodooFX
21st November 2021, 18:56
hello I would like to hide this parental advisory I understood how to hide the round logo on the other hand it does not work for the advisory
InpaintDelogo( Loc="1018,922,-254,-106)
Hi, upload your attachment to imgur.com or to other image hosting site.
dot75
21st November 2021, 19:24
Hi, upload your attachment to imgur.com or to other image hosting site.
https://imgur.com/a/llDwuXB
VoodooFX
21st November 2021, 19:52
And where is the mask image? Post your full script too and version of InpaintDelogo.
Btw, your Loc doesn't leave minimum 10pxs space at the top and right sides, use "1018,920,-248,-106".
dot75
21st November 2021, 20:01
InpaintDelogo( mask="H:\Mask8.bmp",
\ Automask=0, aMix=-0,Loc="1672,914,-184,-100",
\ Mode="Inpaint",
\ Analyze=3, FrW=54, FrS=0,dPP=0,Show=0,Inflate=2)
for parental advisor
InpaintDelogo( Loc="1018,920,-248,-106",DynMask=3, DynInflate=4, Dyn3Seq=13, ClpBlend=11, Show=5)
VoodooFX
21st November 2021, 20:07
And version of InpaintDelogo?
DynMask=3 is probably not a correct method here.
dot75
21st November 2021, 20:08
And version of InpaintDelogo?
DynMask=3 is probably not a correct method here.
yes 1.48
VoodooFX
21st November 2021, 20:32
What means "does not work"?
That round logo looks like it's transparent so correct would be to deblend it. For text use inpaint, you can do both logos in one go with mode="Both".
Why you use Dynamic=3? Why Dyn3Seq=13, is logo there for only half second? Show=5 doesn't do delogo, it only shows you a mask.
dot75
21st November 2021, 20:43
What means "does not work"?
That round logo looks like it's transparent so correct would be to deblend it. For text use inpaint, you can do both logos in one go with mode="Both".
Why you use Dynamic=3? Why Dyn3Seq=13, is logo there for only half second? Show=5 doesn't do delogo, it only shows you a mask.
how to do I must put the loca twice ?
the text disappears at frame 1300
VoodooFX
21st November 2021, 21:00
how to do I must put the loca twice ?
the text disappears at frame 1300
You don't. Include both logos in same Loc. And both logos should be in the mask.
If logo is not in the whole video then delogo only that range, example is there https://forum.doom9.org/showthread.php?p=1957647#post1957647
dot75
21st November 2021, 21:46
V2 = InpaintDelogo( mask="H:\Mask9.bmp",
\ Automask=0, aMix=-0,Loc="1018,920,-248,-106",
\ Mode="Inpaint",
\ Analyze=3, FrW=54, FrS=0,dPP=0,Show=1,Inflate=2)
https://imgur.com/a/bO2XYi6
VoodooFX
21st November 2021, 22:13
You didn't set a black frame: FrB.
dPP has nothing to do with Inpaint mode.
EDIT:
How did you get that mask?
It's incorrect:
https://i.imgur.com/CPQ1AG2.png
Mask should be: white where logo is, and the rest is black.
Danette
22nd November 2021, 04:04
V1 = InpaintDelogo( mask="D:\logo1.bmp")
ReplaceFramesSimple(Last,V1,Mappings="[0 500] [3400 3800] [4000 4444]")
V2 = InpaintDelogo( mask="D:\logo2.bmp")
ReplaceFramesSimple(Last,V2,Mappings="[2020 2500]")
V3 = InpaintDelogo( mask="D:\logo3.bmp")
ReplaceFramesSimple(Last,V3,Mappings="[1100 1900]")
Had a chance to test this code approach. It works perfectly AND can handle, at least, three separate logos simultaneously. Thanks.
Question: if I am creating a manual mask (all blue 255 background with the logo white), why bother with the location of the logo? When I tried setting Loc=”0,0,-0,-0” , and applied the manual mask mentioned, the logo was covered exactly as it is when a selection tightly bound by location coordinates is used.
Does anyone have wishes/suggestions about delogo and stuff?
What about idea to incorporate all masks into one file? That would make it more universal, in case you would want to use masks on other videos with same logo, you would need to change only coords to move all logo masks, but at the current state you can move only by 2 pxs, it's possible to add compatibility to 1px, but lots of stuff then need to be rechecked/rewritten and probably there would be some performance penalty. I'm not sure if it's worth to bother, there are no problems for the savy avs users...
I think that you have some of my interests to use. Of particular value, to me, would be the previously mentioned idea of being able to track a logo that doesn’t change, other than its’ location. If this can be done, a further enhancement would be to have the delogo function adapt to minor variations in the logo itself, e.g.; if the logo mask changed by 2%, the delogo function would adapt as it happened.
I like that idea of all masks into one file!
VoodooFX
22nd November 2021, 05:52
Question: if I am creating a manual mask (all blue 255 background with the logo white), why bother with the location of the logo? When I tried setting Loc=”0,0,-0,-0” , and applied the manual mask mentioned, the logo was covered exactly as it is when a selection tightly bound by location coordinates is used.
You are mixing up with Vdub's Delogo, there is no "blue" for InpaintDelogo, the base mask should be only white and black.
Loc is area which will be processed, if you process whole frame then it will be pretty slow.
Of particular value, to me, would be the previously mentioned idea of being able to track a logo that doesn’t change.
That would be nice. You can try to make a thread at Avisynth Development (https://forum.doom9.org/forumdisplay.php?f=69), maybe someone would be interested in making such tracking or someone secretly has such plugin.
dot75
22nd November 2021, 07:15
You didn't set a black frame: FrB.
dPP has nothing to do with Inpaint mode.
EDIT:
How did you get that mask?
It's incorrect:
https://i.imgur.com/CPQ1AG2.png
Mask should be: white where logo is, and the rest is black.
Just via Analyze=3
the result and not good you are right iam lost lol
VoodooFX
22nd November 2021, 08:21
Just via Analyze=3
the result and not good you are right iam lost lol
But you didn't set the black frame parameter there [and Automask=1 creates the base mask].
Here is the mask I made with Photoshop from your screenshot:
https://i.imgur.com/guOQbvt.png
dot75
22nd November 2021, 08:38
But you didn't set the black frame parameter there [and Automask=1 creates the base mask].
Here is the mask I made with Photoshop from your screenshot:
https://i.imgur.com/guOQbvt.png
I'm going to start over .
you did it with Photoshop I don't know anything about photo editing I guess that's complicated to do ?
VoodooFX
22nd November 2021, 08:55
I don't know anything about photo editing I guess that's complicated to do ?
It took me all ~30 seconds to do it.
dot75
22nd November 2021, 09:13
It took me all ~30 seconds to do it.
yes when we know how to do it
I will try to learn with gimp or photofiltre
Danette
22nd November 2021, 15:34
You are mixing up with Vdub's Delogo, there is no "blue" for InpaintDelogo, the base mask should be only white and black.
No, this wasn’t a mix-up with VDub’s Delogo. When I initially made a black image for Automask, then ran it, the mask color appeared as a blue (0,0,255 RGB) in my particular image editor (it was black in another image viewer, though). So, I assumed that was ok and began using blue as the mask, but always making the logo white. Guess what: it seems to work the same with the blue mask (I can’t tell a difference in the result). However, I will return to a black mask, since it is just as easy and, perhaps, the value may be so subtle that I am overlooking it.
Using a blue mask even worked identically to a black mask when using Automask. However, I’ve decided not to use Automask because it doesn’t identify a logo image well enough and does falsely find other non-logos, despite amix settings and best efforts to get a solid black image in the location area, requiring manual adjustments in the image editor, anyway.
The other reason that I say it wasn’t a mix-up with VDub’s DeLogo is because, from a user standpoint, VDub’s DeLogo doesn’t require a user-created mask. All you need do is to capture the image, open the image in a image editor, and paint the logo red (255,0,0 RGB). VDub’s DeLogo then takes it from there and, internally, processes it all. That may be an idea for simplifying InpaintDelogo for users, since you are de-constructing VDub’s DeLogo and looking for improvement ideas.
That would be nice. You can try to make a thread at Avisynth Development (https://forum.doom9.org/forumdisplay.php?f=69), maybe someone would be interested in making such tracking or someone secretly has such plugin.
Done
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.