Code:
function mocomp(clip i, float amount, string file, int "th", int "th1",bool "vis")
{
th=default(th,7)
th1=default(th1,7)
vis=default(vis,false)
#generate static-area mask
im=motionmask(i,thy1=th1,thy2=th1,thsd=255)
# make motion global compensation of the video
i2f=GenMotion(i,filename=file,delta=amount).trim(1,0)
i2b=GenMotion(i,filename=file,delta=amount-1)
# motion compensate the static-parts-mask
i2fm=GenMotion(im,filename=file,delta=amount).trim(1,0)
i2bm=GenMotion(im,filename=file,delta=amount-1)
# mix fwd. and bckwd. compensation
g2=overlay(i2f,i2b,opacity=amount)
g2= vis ? g2.coloryuv(gain_u=48) : g2
# mix the motioncompensated masks
g2m=logic(i2fm,i2bm,mode="And")
#generate a falsemotionmask
g2mm=interleave(i2f,i2b).motionmask(thy1=th,thy2=th,thsd=255).selectodd().binarize().duplicateframe(0)
#merge static and false mask
g2mmm=logic(g2m,g2mm,mode="and").blur(1).blur(1).binarize(threshold=1,upper=false)
# genrate blended clip out of the input to repair swimming static parts and false generated motion
g2bl=overlay(i,i.trim(1,0),opacity=amount)
g2bl= vis ? g2bl.coloryuv(gain_v=48) : g2bl
# repair genmotion's output
g2rep=overlay(g2bl,g2,mask=g2mmm)
g2rep= vis ? g2rep.subtitle(string(amount)) : g2rep
return g2rep
}
this is the new motencompensation function
amount: float value between 0 and 1.
0 returns curr. frame
1 returns next frame
0.5 returns inbetween frame
0.25 the frame between 0 and 0.5
(and so on)
file: string to the location the deshaker.log (or whatever it is called)
th: int for false motion (differential motion) detection
th1: int for static area detection
vis: enable visualization
blue - motion compensated
red - blended (repaired areas)
usage:
general:
Code:
loadplugin("C:\x\masktools.dll")
loadplugin("C:\x\avisynth_c.dll")
loadCplugin("c:\x\genmotion.dll")
avisource("30p.avi")
i=converttoyv12()
possibilities:
framerate doubler:
Code:
i1=i
i2=i.mocomp(0.50,"c:\deshaker.log")
interleave(i1,i2)
framerate quadrupler:
Code:
i1=i
i2=i.mocomp(0.25,"c:\deshaker.log")
i3=i.mocomp(0.50,"c:\deshaker.log")
i4=i.mocomp(0.75,"c:\deshaker.log")
interleave(i1,i2,i3,i4)
30p to 24p conversion:
Code:
i1=i
i2=i.mocomp(0.25,"c:\deshaker.log")
i3=i.mocomp(0.50,"c:\deshaker.log")
i4=i.mocomp(0.75,"c:\deshaker.log")
interleave(i1,i2,i3,i4)
selectevery(5,1)
hope that helps.