Log in

View Full Version : median2 - flickering after processing


thescrapyard
22nd April 2014, 10:45
Just tried out this function I came across and did a very good job of calming down all grain on old 70's and 80's British Children's DVD's I'm trying to clean up (Fingerbobs, DangerMouse, Paddington Bear, Wind in The Willows), seems originally for grainy analogue captures but works perfectly for grainy BBC DVD transfers

It did exactly what I'm looking for, but using avsp as a test bed for the scripts to get the results I am looking for, I end up with quite bad flickering in the output, like the frame is slightly behind the first one. I'm not sure if this is down to avsp can't keep up when the output is played alongside the source or the cause oft he scripts

Any suggestion on how to stop this would be appreciated

Scripts I'm using are :

function TMedian2(clip c)
{
Median2(c.selectevery(1,-2),c.selectevery(1,-1),c,c.selectevery(1,1),c.selectevery(1,2))
}

Function Median2(clip "input_1", clip "input_2", clip "input_3", clip "input_4", clip "input_5", string "chroma")
{# median of 5 clips from Helpers.avs by G-force
chroma = default(chroma,"false") #default is "process". Alternates: "copy first" or "copy second"
#MEDIAN(i1,i3,i5)
Interleave(input_1,input_3,input_5)
chroma == "process" ? Clense(reduceflicker=false) : Clense(reduceflicker=false,grey=true)
m1 = selectevery(3,1)
#MAX(MIN(i1,i3,i5),i2)
m2 = input_1.MT_Logic(input_3,"min",chroma=chroma).MT_Logic(input_5,"min",chroma=chroma).MT_Logic(input_2,"max",chroma=chroma)
#MIN(MAX(i1,i3,i5),i4)
m3 = input_1.MT_Logic(input_3,"max",chroma=chroma).MT_Logic(input_5,"max",chroma=chroma).MT_Logic(input_4,"min",chroma=chroma)
Interleave(m1,m2,m3)
chroma == "process" ? Clense(reduceflicker=false) : Clense(reduceflicker=false,grey=true)
selectevery(3,1)
chroma == "copy first" ? last.MergeChroma(input_1) : chroma == "copy second" ? last.MergeChroma(input_2) : last
Return(last)
}

And I'm using this simpler set up until I can stop the flickering, then I can add back in the denoising using RemoveNoiseMC and a bit of levels alteration using RoboLevels or AutoLevels


And use this for testing what I'm doing

clip1=dss2("J:\ConvertXToDVD\test09.mkv").ConvertToYV12()
clip2=tdeint(type=4,slow=2,tryweave=true).tmedian2()
stackhorizontal(clip1,clip2)


Which works perfectly for every other filter I have used, until I tried seeing what median2 could help with

Mounir
22nd April 2014, 23:25
median2 is for 2 or more captures not suited for what you want to achieve imo try this instead:

# Mdegrain1 (for interlaced source):
fields=AssumeTFF().SeparateFields() # or AssumeBFF
super = MSuper(fields)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=2)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=2)
MDegrain1(fields, super, backward_vec2,forward_vec2,thSAD=400)
Weave()

OR:
avisource("blabla.avi")
mdegrain2i2(4,0)

function MDegrain2i2(clip source, int "overlap", int "dct")
{
overlap=default(overlap,0) # overlap value (0 to 4 for blksize=8)
dct=default(dct,0) # use dct=1 for clip with light flicker
fields=source.SeparateFields() # separate by fields
super = fields.MSuper()
backward_vec2 = super.MAnalyse(isb = true, delta = 2, overlap=overlap, dct=dct)
forward_vec2 = super.MAnalyse(isb = false, delta = 2, overlap=overlap, dct=dct)
backward_vec4 = super.MAnalyse(isb = true, delta = 4, overlap=overlap, dct=dct)
forward_vec4 = super.MAnalyse(isb = false, delta = 4, overlap=overlap, dct=dct)
fields.MDegrain2(super, backward_vec2,forward_vec2,backward_vec4,forward_vec4,thSAD=400)
Weave()
}

for progressive source:
AVISource("c:\test.avi")
super = MSuper(pel=2, sharp=1)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
backward_vec1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
forward_vec1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400)