Log in

View Full Version : Blur Private Parts?


warrenjb
9th May 2020, 17:01
I'm making a movie of my kids growing up with some old dv tapes. There's a scene with the kids dancing naked. They're 1 &3 so I think it's cute but they'll be embarrassed. Suggestions for blurring out their private parts? Thanks!

FranceBB
9th May 2020, 17:57
If they are moving at inconstant speed (i.e randomly) it can become a pain to do that in Avisynth as you would have to "move" your blurred blocks frame by frame. It can be done, it's just extremely tedious. As much as I hate suggesting NLE over frame servers, I generally do it with AVID Media Composer. There are other NLE that can do it in an automated fashion like Davinci Resolve. What they do is to make a mask internally and follow the blocks with the values you specified in time. Another good tracking program which has been the de facto standard and has many integrations with other programs is Mocha. Anyway since you asked how to do it with a frame server (namely Avisynth) I'm gonna wait for others to reply...

warrenjb
9th May 2020, 18:03
Thanks for your reply! It's a pretty short clip without a lot of movement so I can probably apply the blur with a big enough radius to have it work without any or maybe only some slight movement. I am having a hard time finding a 64 bit filter that would allow me to do this, however. Any suggestions?

StainlessS
9th May 2020, 18:03
Agree with FraneBB, however,

EDIT: Script REMOVED. See post #9

videoh
9th May 2020, 18:37
Post a link to the clip so we can experiment. :p

StainlessS
9th May 2020, 20:06
EDIT: Script REMOVED. See post #9

real.finder
9th May 2020, 20:12
Post a link to the clip so we can experiment. :p

FBI open up! :D

StainlessS
9th May 2020, 20:20
Can somebody look at my prev post, Animate seems to apply effect to entire clip, and NOT just the Start, End range,
did I cock up somewhere or is v3.5.2 animate bugged ?

EDIT: Overlay also has Start End Args, and used via Conceal() function, perhaps related.
Is Overlay incompatible with Animate ?

EDIT:
Arh crap,
Animate is a meta-filter which evaluates its parameter filter with continuously varying arguments. At frame start_frame and earlier, the filter is evaluated with the arguments given by start_args. At frame end_frame and later, the filter is evaluated with the arguments given by end_args. In between, the arguments are linearly interpolated for a smooth transition.

StainlessS
9th May 2020, 21:26
ConcealRange.avs

/*

https://forum.doom9.org/showthread.php?p=1911260#post1911260
Req:- Masktools2, FastBlur, Avs+
YUV444 or RGB Only, 8 -> 32 bit.

*/

Function EllipMsk(clip c,int W, Int H,Bool "Soft") {
# Req mt_tools_2, Returns frame WxH same FPS as c and without audio
Soft=Default(Soft,False)
# INFIX_H="(((x-.5)^2 +(y-.5)^2) < .25 ? 255 : 0"
# Elliptical Disk (Hard Edge) :: mode = "relative", Radius=0.5, Rad^2=0.25 :: SOFT_Inner rad:(Rad*0.9)^2~=0.2
# INFIX_S="((x-.5)^2+(y-.5)^2)<.2?255 : (((x-.5)^2+(y-.5)^2)<.25 ? ((.25-((x-.5)^2+(y-.5)^2))*5100):0)"
# Elliptical Disk (Soft Edge) :: (.25-0.2)*5100=255 : (.25-.25)*5100=0.0] :: mode="relative", 0.25~=1.0 : 0.2~=0.9
rpn = (!Soft)
\ ? "x 0.5 - 2 ^ y 0.5 - 2 ^ + 0.25 < 255 0 ? scalef" [* RPN: EllipMsk [Hard Edge] *]
\ : "x 0.5 - 2 ^ y 0.5 - 2 ^ + 0.2 < 255 x 0.5 - 2 ^ y 0.5 - 2 ^ + 0.25 < 0.25 x 0.5 - 2 ^ y 0.5 - 2 ^ + - 5100 * 0 ? ? scalef" [* RPN: EllipMsk [Soft Edge] *]
c.Blankclip(width=W,height=H,Length=1).Killaudio
return Last.mt_lutspa(mode = "relative", expr = rpn, chroma = "-128" )
}


Function RectMsk(clip c,int W, Int H,Bool "Soft") {
# Req mt_tools_2, Returns frame WxH same FPS as c and without audio
Soft=Default(Soft,False)
# INFIX_H = "255"
# INFIX_S = "max(abs(x-.5),abs(y-.5)) < .45 ? 255 : ((.5 - max(abs(x-.5),abs(y-.5)) ) * 5100)"
rpn=(!Soft)
\ ? "255 scalef"
\ : "x 0.5 - abs y 0.5 - abs max 0.45 < 255 0.5 x 0.5 - abs y 0.5 - abs max - 5100 * ? scalef"
c.Blankclip(width=W,height=H,Length=1).Killaudio
return Last.mt_lutspa(mode = "relative", expr = rpn, chroma = "-128" )
}

Function Conceal(clip c,clip bc,clip msk, Float x, Float y,Float Opacity) {
mw = Msk.Width mh=Msk.Height
ow=c.width-2*mw oh=c.Height-2*mh
xc = Round(min(max(0.0,x),ow))
yc = Round(min(max(0.0,y),oh))
x = xc + mw/2
y = yc + mh/2
bc=bc.crop(x,y,mw,mh)
c.Overlay(bc,mask=msk,x=x,y=y,opacity=Opacity)
}

Function ConcealRange(clip c,clip bc,clip msk,Int "S", Int "E",float "sx",Float "sy",Float "ex",float "ey", Float "sop",Float "eop") {
/*
Blur/Conceal clip c with blurred clip clip bc using Mask msk, frames S to E, sx,sy start coords, ex,ey end coords.
Start and End Args S & E, are similar but not exactly like trim.
ConcealRange(c,bc,msk, 0,0) # Entire clip
ConcealRange(c,bc,msk, 100,0) # Frame 100 to End of Clip
ConcealRange(c,bc,msk, 0,-1) # Frame 0 Only
ConcealRange(c,bc,msk, 1,1) # Frame 1 Only
ConcealRange(c,bc,msk, 1,-1) # Frame 1 Only
ConcealRange(c,bc,msk, 1) # Frame 1 Only [Not same as Trim()], E defaults to -1 ie single frame.
ConcealRange(c,bc,msk, 1,-3) # Frames 1 to 3 (ie 3 frames)
ConcealRange(c,bc,msk, 100,200) # 101 Frames, 100 to 200
ConcealRange(c,bc,msk, 100,-50) # Frames 100 to 149 ie 50 frames

X coords sx, and ex, allowed range 0 -> c.width.
Y coords sy, and ey, allowed range 0 -> c.height.
sop, eop, Start and End Opacity, Default 1.0, range 0.0 -> 1.0
*/
FMX=c.FrameCount-1
S = Min(Max(Default(S,0),0),FMX) E = Default(E,-1)
sx=Default(sx,0.0) sy=Default(sy,0.0)
ex=Default(ex,0.0) ey=Default(ey,0.0)
sop=min(max(Default(sop,1.0),0.0),1.0) eop=min(max(Default(eop,1.0),0.0),1.0)
E = (E==0) ? FMX : E
E = Min(((E < 0) ? S-E-1 : E),FMX) # S <= E <= FMX : E is +ve END Frame number (may be 0)
Empty = c.BlankClip(Length=0)
CS = (S==0) ? Empty : c.Trim(0,-S)
C2E = (E==0?FMX:E)
mw=Msk.Width mh=Msk.Height
cpad = c.Addborders(mw,mh,mw,mh)
bcpad = bc.Addborders(mw,mh,mw,mh)
CM = cpad.Animate(S,C2E,"Conceal", bcpad,Msk,sx,sy,sop, bcpad,Msk, ex,ey,eop)
CM = CM.Trim(S,C2E).crop(mw,mh,-mw,-mh)
CE = (E==FMX) ? Empty : c.Trim(E+1,0)
CS ++ CM ++ CE
}

##############################################################

AviSource("D:\Parade.avi").Trim(100,0) # Source Clip

# Either YUV444 or RGB
ConvertToYV24.ConvertBits(10)
#ConvertToPlanarRGB.ConvertBits(10)
#ConvertToRGB24
#ConvertToRGB48
#ConvertToRGB64

####### CONFIG ###############################################

DISK = True # True = Disk/Ellipse, Else Rectangle
PIXELATE = False # True = PIXELATE, False=Blur
PIXSZ = 8 # PIXELATE Size, (maybe 8 or 4)

# FastBlur args # Fastblur args if PIXELATE=False
FBlurRad = 5
FBlurIter = 3

# Mask args [size of concealed area]
MWidth = 128
MHeight = MWidth
MSOFT = True # Soft Edge mask

# Opacity of Overlay'd concealment. [You are unlikely to want anything less than about 0.9, usually 1.0]
sop = 1.0 # Start frame Opacity
eop = sop # End frame opacity same as start opacity.

# OTHER STUFF
BLANKFG = false # Show ForeGround(blurred/concealed Area) in Blue [see path traveled better].
BLANKBG = False # Show BackGround in Pink

####### END CONFIG ########################
Assert(IsRGB || (Height==ExtractU.Height&&Width==ExtractU.Width),"YV444 or RGB ONLY")


W = Width
H = Height
BPC = BitsPerComponent

#
BClip = (PIXELATE) ? BilinearResize(W/PIXSZ,H/PIXSZ).PointResize(W,H) : Last.Fastblur(FBlurRad,iterations=FBlurIter) # Concealing clip
MSK = Last.BlankClip(pixel_type="Y8").ConvertBits(BPC) # Mask
MSK = (DISK) ? MSK.EllipMsk(MWidth,MHeight,Soft=MSOFT) : MSK.RectMsk(MWidth,MHeight,Soft=MSOFT)
#

Last = (BLANKBG) ? Last.BlankClip(Color=$C04060) : Last
BCLip= (BLANKFG) ? BCLip.BlankClip(Color=$0000FF) : BClip

#################################################################################
# Demo coords, Start,End Frm, Start X,Y End X,Y Start,End Opacity(default 1.0 if not supplied)
ConcealRange(Last,BClip,Msk, 0, 499, 0, 0, W, H, sop, eop)
ConcealRange(Last,BClip,Msk, 500, 999, W, H, W, 0, sop, eop)
ConcealRange(Last,BClip,Msk, 1000, 1499, W, 0, 0, H, sop, eop)
ConcealRange(Last,BClip,Msk, 1500, 1999, 0, H, 0, 0, sop, eop)
ConcealRange(Last,BClip,Msk, 2000, 2499, 0, 0, W/2,H/2, sop, eop)
#################################################################################

ConvertToRGB32 # For viewing HBD

EDIT: Fastblur and Masktools2 both available in x64 flavours.

Original
https://i.postimg.cc/ydDcfC6B/Conceal-Range-00.jpg (https://postimages.org/)

Pixelated
https://i.postimg.cc/jqJyPTk4/Conceal-Range-01.jpg (https://postimages.org/)

Blurred
https://i.postimg.cc/3J5mZqs5/Conceal-Range-02.jpg (https://postimages.org/)

Pixelated/BlankBG
https://i.postimg.cc/28Qv9wYq/Conceal-Range-03.jpg (https://postimages.org/)

Blurred/BlankBG
https://i.postimg.cc/htMmctfc/Conceal-Range-04.jpg (https://postimages.org/)

StainlessS
10th May 2020, 19:31
Prev post, High Bit Depth capable, Req AVS+.

Added Start and End overlay Opacity args.