Log in

View Full Version : repairing Framedrops (especially on interlaced video)


scharfis_brain
16th July 2004, 10:50
Everyone, who does analogue capping knows them: Framedrops.
with progressive Video, they just produce a small jerk, but with true interlaced video, you'll get a double stutter, because two fields are missing.

my function detects framedrops and replaces them using manao's motion compensation.

function repairframedrop(clip i, float "threshold", bool "interlaced", bool "show")
{

function kbob(clip a)
{
th=5
ord = getparity(a) ? 1 : 0
f=a.kerneldeint(order=ord, sharp=true, twoway=false, threshold=th)
e=a.doubleweave().selectodd().kerneldeint(order=1-ord, sharp=true, twoway=false, threshold=th)
interleave(f,e).assumeframebased
}

# set the defaults
global dropthreshold=default(threshold,0.1)
interlaced=default(interlaced,true)
show=default(show,false)

# commands to generate the two missing fields
a=i.kbob().converttoyv12()
afwd=a.mvanalyse(isb=false)
abwd=a.mvanalyse(isb=true)
a1=a.mvinterpolate(abwd, afwd, bl=0.30, el=0.37, nb=4).selecteven()
a2=a.mvinterpolate(abwd, afwd, bl=0.63, el=0.70, nb=4).selecteven()
a3=interleave(a2,a1).converttoyuy2()
a3=a3.separatefields()
a3=getparity(i) ? a3.selectevery(4,1,2) : a3.selectevery(4,0,3)
a3=a3.weave() .trim(1,0)

# commands to generate the missing fullframe
b=i.converttoyv12()
bfwd=b.mvanalyse(isb=false)
bbwd=b.mvanalyse(isb=true)
b3=mvinterpolate(b,bbwd,bfwd,bl=0.5,el=0.5).trim(1,0).converttoyuy2()

# either replace drop with the two recreated fields or with the fullframe
c3 = interlaced ? a3 : b3

# mark replaced dropped frames
c3 = show ? c3.subtitle("drop") : c3

# detect and replace framedrops
conditionalfilter(i.converttoyv12(),c3,i,"YDifferencefromprevious","<","dropthreshold")

}

there are three (optional) parameters:

bool interlaced : sets the type of interpolation. interlaced or progressive (default = true)

bool show: a yellow "drop" appears on the top left, if a drop as got replaced (default = false)

float threshold: sets the drop detection threshold.
0.0 will never detect a drop
255.0 will always replace the frames
0.1 is default
it has to be set as low as possible, to avoid non-dropped frames getting replaced.


ensure settingup the fieldorder using assumeTFF or assumeBFFcorrectly before calling repairframedrop().

krieger2005
22nd July 2004, 15:07
i know the problem...

thanks. i try it.

juhok
17th December 2008, 14:36
I was looking for something like this. Thanks. Is there an updated version? Doesn't work with latest MVTools per se (or I've got something wrong).