View Full Version : Remove disturbing vertical jitter???


dragon_warrior
6th March 2011, 14:16
Whew, here comes another trouble with my encode
I have some DVD footage which are to be encoded to h264, but the source is flooded with vertical "jitter" (I don't know if I call it the right way). After deinterlacing using QTGMC, the "jitter" are still there.
I've googled up and found this thread
http://forum.videohelp.com/threads/312908-vertical-jitter-reduction-filters

It seems Stab does nothing to the video, so I come up with the idea to seek for some help from you guys.
Here are some screenshots (cropped and deinterlaced)
http://img854.imageshack.us/img854/6229/28305176.png
http://img854.imageshack.us/img854/3238/28264877.png
http://img854.imageshack.us/img854/5536/73437536.png

Thanks in advance :)

*edit:
Sample vob (http://www.multiupload.com/XL0E45MQDY) (20 Mb)

Didée
6th March 2011, 15:19
Here are some screenshots (cropped and deinterlaced)
Advice will be hard without a vanilla unprocessed sample.

dragon_warrior
7th March 2011, 05:11
Advice will be hard without a vanilla unprocessed sample.

Oops, I totally forgot abou this
A 23-sec sample vob can be grabbed from here
http://www.multiupload.com/XL0E45MQDY

Didée
7th March 2011, 08:18
Oh my, this is bad. Looks like some kind of motion-interpolation has been used at some point in the production chain. It's pretty much the kind of artifacts that you would get if you had the clean source, and would apply MVTools' MFlow/BlockFPS for a FPS change. Also, note the bleeding at the scene change.

Alas I don't see a quick hat trick to repair this. I'll let it breed a little, the best ideas come suddenly from deep underneath. But don't expect anything - this might be impossible to fix in a satisfying manner.

dragon_warrior
7th March 2011, 10:38
Alas I don't see a quick hat trick to repair this. I'll let it breed a little, the best ideas come suddenly from deep underneath. But don't expect anything - this might be impossible to fix in a satisfying manner.

Thanks
(I can't imagine how they can release it as the bonus dvd o_O)

Ghitulescu
7th March 2011, 10:56
Are you referring to the "ghost" vertical bars?
I think these are encoding defects ... they can only be removed by filters like delogo ...

dragon_warrior
9th March 2011, 06:46
Are you referring to the "ghost" vertical bars?
I think these are encoding defects ... they can only be removed by filters like delogo ...

Could you make it more clear?

Ghitulescu
9th March 2011, 09:11
delogo = selectively removal of artifacts (useful to remove stations' logo, hence the name)

Didée
9th March 2011, 09:54
Delogo approach.

Step#1: Export all frames to BMP
Step#2: Start Image editor
etc....

Story continues as expected. :D

Didée
10th March 2011, 11:52
Here's a kind of desperate attempt.

1-stage cleaning: way, way, waaay to weak.

2-stage cleaning: better, but way too weak.

Bigger weapons! We need bigger weapons!

The below script does the following:
Use a dumb temptoral median as preparation for a depan-compensated temporal median as preparation for a motion-compensated temporal median afterburned with a motion compensated MDegrain.

"We need bigger weapons."

3-stage cleaning does a reasonable job at removing the jumping bars. Computational effort is huge, however, and it also does some noticeable damage in areas where you don't want to.


Result: LINK (http://www.mediafire.com/download.php?5qbq5dhg8f2ud9j) (MediaFire, ~46MB, stacked before/after)

Script:
# Plugins: - RemoveGrain
# - MaskTools2
# - Depan + DepanEstimate
# - MVTools2


mpeg2source("Sample_(dragon_warrior).d2v")
crop(0,64,-0,-64,true)

bob(0,0.5)
a=last

clense(reduceflicker=false).merge(last,0.5).clense(reduceflicker=false)
mot=removegrain(11,0).removegrain(20,0).DepanEstimate(range=2)
take2=a.depaninterleave(mot,prev=2,next=2,subpixel=2)
clean1=take2.TMedian2().selectevery(5,2)

sup1 = clean1.minblur(1).removegrain(11,0).removegrain(11,0)
\ .mt_lutxy(clean1,"x 1 + y < x 2 + x 1 - y > x 2 - y ? ?",U=2,V=2)
\ .msuper(pel=2,sharp=0)
sup2 = a.msuper(pel=2,levels=1,sharp=2)
#bv23=sup1.manalyse(isb=true, truemotion=false,global=true,delta=3,blksize=16,overlap=8,search=5,searchparam=4,DCT=5)
bv22=sup1.manalyse(isb=true, truemotion=false,global=true,delta=2,blksize=16,overlap=8,search=5,searchparam=4,DCT=5)
bv21=sup1.manalyse(isb=true, truemotion=false,global=true,delta=1,blksize=16,overlap=8,search=5,searchparam=4,DCT=5)
fv21=sup1.manalyse(isb=false,truemotion=false,global=true,delta=1,blksize=16,overlap=8,search=5,searchparam=4,DCT=5)
fv22=sup1.manalyse(isb=false,truemotion=false,global=true,delta=2,blksize=16,overlap=8,search=5,searchparam=4,DCT=5)
#fv23=sup1.manalyse(isb=false,truemotion=false,global=true,delta=3,blksize=16,overlap=8,search=5,searchparam=4,DCT=5)

#a.mdegrain3(sup2,bv21,fv21,bv22,fv22,bv23,fv23,thSAD=499) # << this is the "2-fold" variant

interleave(a.mcompensate(sup2,fv22),a.mcompensate(sup2,fv21),a,a.mcompensate(sup2,bv21),a.mcompensate(sup2,bv22))
TMedian2().selectevery(5,2)

sup3 = last.msuper(pel=2,sharp=2)
bv33=sup3.manalyse(isb=true, truemotion=false,global=true,delta=3,blksize=8,overlap=4,search=5,searchparam=4,DCT=5)
bv32=sup3.manalyse(isb=true, truemotion=false,global=true,delta=2,blksize=8,overlap=4,search=5,searchparam=4,DCT=5)
bv31=sup3.manalyse(isb=true, truemotion=false,global=true,delta=1,blksize=8,overlap=4,search=5,searchparam=4,DCT=5)
fv31=sup3.manalyse(isb=false,truemotion=false,global=true,delta=1,blksize=8,overlap=4,search=5,searchparam=4,DCT=5)
fv32=sup3.manalyse(isb=false,truemotion=false,global=true,delta=2,blksize=8,overlap=4,search=5,searchparam=4,DCT=5)
fv33=sup3.manalyse(isb=false,truemotion=false,global=true,delta=3,blksize=8,overlap=4,search=5,searchparam=4,DCT=5)

last.mdegrain3(sup3,bv31,fv31,bv32,fv32,bv33,fv33,thSAD=499)

stackvertical(a,last)
return(last)


#--------------------------------------------------------------
# Helper functions

function MinBlur(clip clp, int r, int "uv")
{
uv = default(uv,3)
uv2 = (uv==2) ? 1 : uv
rg4 = (uv==3) ? 4 : -1
rg11 = (uv==3) ? 11 : -1
rg20 = (uv==3) ? 20 : -1
medf = (uv==3) ? 1 : -200

RG11D = (r==0) ? mt_makediff(clp,clp.sbr(),U=uv2,V=uv2)
\ : (r==1) ? mt_makediff(clp,clp.removegrain(11,rg11),U=uv2,V=uv2)
\ : (r==2) ? mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20),U=uv2,V=uv2)
\ : mt_makediff(clp,clp.removegrain(11,rg11).removegrain(20,rg20).removegrain(20,rg20),U=uv2,V=uv2)
RG4D = (r<=1) ? mt_makediff(clp,clp.removegrain(4,rg4),U=uv2,V=uv2)
\ : (r==2) ? mt_makediff(clp,clp.medianblur(2,2*medf,2*medf),U=uv2,V=uv2)
\ : mt_makediff(clp,clp.medianblur(3,3*medf,3*medf),U=uv2,V=uv2)
DD = mt_lutxy(RG11D,RG4D,"x 128 - y 128 - * 0 < 128 x 128 - abs y 128 - abs < x y ? ?",U=uv2,V=uv2)
clp.mt_makediff(DD,U=uv,V=uv)
return(last)
}

# median of 5 clips from Helpers.avs by G-force
Function Median2(clip "input_1", clip "input_2", clip "input_3", clip "input_4", clip "input_5", string "chroma")
{
chroma = default(chroma,"process") #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)
}

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

dragon_warrior
10th March 2011, 16:34
The script does make a stunning result, Didee. Many thanks
Compared with the astounding effect, the damage are small (according to my eyes), thus, they cannot ruin the whole clip.
Which lines [in the script] should I delete if I only want to keep the processed clip? I can hardly figure it out
Again, I really appreciate your hard work.

Didée
10th March 2011, 16:42
Just comment (or delete) the stackvertical() line:

stackvertical(a,last)

"a" is the bobbed original input, and the processed clip is present in "last".

@MeGui
10th March 2011, 17:50
Woooww, this is the very best path to make stunning Delogo filter "D"...great job!:)

dragon_warrior
11th March 2011, 10:52
Yep, got it now.
I got a speed of 1 fps on my sluggish Core 2 Duo system, which means have to wait for 5 hrs to have the video output.
Thanks for writing an awesome tool, Didee :)

pirej
12th March 2011, 11:22
Nice script Didée, maybe little off topic, but.. i tried it on my sample with a LOT of BAD tracking error's , and it's very effective on correcting them, and yes "it also does some noticeable damage in areas where you don't want to", but i could use it as an overlay over the original, covering only the damaged part.
Thanks.