View Full Version : Another problem involving hybrid footage


dragon_warrior
13th April 2011, 09:39
Hi there,
So I've got some hybrid footage that I'm going to encode to vfr using this guide (http://avisynth.org/mediawiki/TIVTC)

NTSC, two pass (enables use of conCycleTP parameter) mkv vfr for hybrid source.
First pass:
mpeg2source("c:\oursource.d2v")
tfm(d2v="c:\oursource.d2v",output="matches.txt")
tdecimate(mode=4,output="metrics.txt")
Second pass (not anime or cartoon):
mpeg2source("c:\oursource.d2v")
tfm(d2v="c:\oursource.d2v",input="matches.txt")
tdecimate(mode=5,hybrid=2,vfrDec=0,input="metrics.txt",tfmIn="matches.txt",mkvOut="mkv-timecodesfile.txt")

Unfortunately, the source is kinda tough and TFM simply cannot remove all of the interlacing lines, as you can see in these 2 captures:
http://img819.imageshack.us/img819/9922/sourcem.png
http://img852.imageshack.us/img852/5707/encode.png

And this is a 10-sec sample just in case you need it: http://www.embedupload.com/?d=2ZGRWYSEKH

Can I completely get rid of those residual artifacts? And is there a way to first IVTC the film sections, then leave the interlaced to another deinterlacer (not the TFM's built-in one)?

Thanks :thanks:

Didée
13th April 2011, 10:53
The problem is that the source has already destroyed chroma channels. The chroma channels exhibit feldblending.

Check this script, step slowly through the vid, and breed a little about what you see:
mpeg2source("EmbedUpload.com_sample.d2v")
separatefields()
stackvertical(last.greyscale(),stackhorizontal(last.utoy(),last.vtoy()))
Basically it should be possible to restore this. A FixBlendIVTC-kind of de-blending would be appropriate.
Alas, the guru-expert for this kind of crap - MOmonster - hasn't been around for a long time...

Edit: to be clear, this source is not a "hybrid" one. The chroma blending is the only actual problem.

dragon_warrior
13th April 2011, 11:37
Hmm, I see some out-of-pattern frames and some like this http://img717.imageshack.us/img717/4576/source1g.png
That's why I think the source is hybrid.
Assuming it's telecined, so a simple TFM + TDecimate + FixBlendIVTC would save the day?

Didée
13th April 2011, 11:51
Assuming it's telecined, so a simple TFM + TDecimate + FixBlendIVTC would save the day?
No, not this way. It's not that simple.

A theoretical "naive" approach would be this:

mpeg2source("EmbedUpload.com_sample.d2v")
src = crop(0,64,-0,-64,true)

luma = src.TFM().tdecimate()

src.blur(0,1).mergechroma(last)
chroma = FixBlendIVTC(post=3).TDecimate()

luma.mergechroma(chroma)

Alas it doesn't quite work out. The two different chains get out of phase. (luma-chroma desync.)

Didée
13th April 2011, 12:40
Giving a try on manual sync'ing the clips. Uninspired brutefore script, could possibly be done more elegant with ScriptClip et.al.
Seems to basically work, but I found at least one mistake somewhere in the sample.

Dunno, don't have any more time now. Perhaps someone else has a better solution.


FWIW, the script:

mpeg2source("EmbedUpload.com_sample.d2v")
src = crop(0,64,-0,-64,true)

luma = src.TFM()

src.blur(0,1).mergechroma(src)
chroma = FixBlendIVTC(post=3)

# manual sync: figure out which frame [previous,current,next] of 'chroma' clip is most similar to current frame of 'luma' clip
diffp1 = mt_lutxy(luma,chroma.selectevery(1,-1),"x y - abs 2 *")
diffn1 = mt_lutxy(luma,chroma.selectevery(1,1),"x y - abs 2 *")
diffc = mt_lutxy(luma,chroma, "x y - abs 2 *")
mp1 = mt_lutf(diffp1,diffp1,"average",expr="x")
mn1 = mt_lutf(diffn1,diffn1,"average",expr="x")
mc = mt_lutf(diffc, diffc, "average",expr="x")

maskp1 = mt_lutxy(mp1,mc,"x y < 255 0 ?")
maskn1 = mt_lutxy(mn1,mc,"x y < 255 0 ?")

luma.mt_merge(chroma.selectevery(1,-1),maskp1,luma=true,Y=2,U=3,V=3)
\ .mt_merge(chroma.selectevery(1, 1),maskn1,luma=true,Y=2,U=3,V=3)

TDecimate()

dragon_warrior
13th April 2011, 16:16
I really appreciate your work. Thank you again.
Seems it's unable to remove all of the artifacts (i.e at the taillight in the first 2 captures). Anyway, the result is nice, though.
Hopefully QTGMC can help me get rid of the shimmerings in the last capture.