Log in

View Full Version : LeakKernelDeint -- is this script reasonable?


graysky
18th February 2007, 19:43
I've never really done much with avisynth manually before; I usually let MeGUI do what it wants. This time I started reading the docs on decomb, leakkerneldeint, and others and wanted to get some input from people who know. My goal here is to deinterlace and then reduce the framerate from 30 to 24.

My source is an mpeg-2 from a PVR-250 and the material is very likely hybrid material since it's an interview with many different scenes (studio interviews, stock footage, etc.)

Does this script seem reasonable? I know the field order is TTF.

global MeGUI_darx = 16
global MeGUI_dary = 9
DGDecode_mpeg2source("E:\work\test.d2v",cpu=4,info=3)
ColorMatrix(hints=true)

AssumeTFF()
#0 is for BFF
#1 is for TFF
Telecide(guide=1,post=4,hints=true)
LeakKernelDeint(order=1,sharp=true)
Decimate(mode=3,threshold=1.0,quality=3)

crop( 6, 56, -10, -64)
LanczosResize(592,336) # Lanczos (Sharp)

Guest
18th February 2007, 20:19
You don't need to do LeakKernelDeint() at all, because Telecide() is deinterlacing the combed frames with its postprocessing. Also, having a filter between Telecide() and Decimate() can destroy the hints.

graysky
18th February 2007, 20:27
You don't need to do LeakKernelDeint() at all, because Telecide() is deinterlacing the combed frames with its postprocessing. Also, having a filter between Telecide() and Decimate() can destroy the hints.

Thanks for the info. The docs show:To use this filter as a post-processor for Telecide(), use the following script:
Telecide(...,post=1,hints=true)
LeakKernelDeint(...)

So I should remove the Telecide line from the script entirely? I'm assuming LeakKernelDeint does the deinterlacing itself? If that's true there is not mention of the hints parameter in the docs. :confused:

Terranigma
18th February 2007, 21:51
Thanks for the info. The docs show:To use this filter as a post-processor for Telecide(), use the following script:
Telecide(...,post=1,hints=true)
LeakKernelDeint(...)

So I should remove the Telecide line from the script entirely? I'm assuming LeakKernelDeint does the deinterlacing itself? If that's true there is not mention of the hints parameter in the docs. :confused:

telecide is an ivtc filter that can also deinterlace a clip depending on it's settings.
According to your script, you're deinterlacing with 2 different filters; that's a big No No!

What neuron2's trying to say is the hints by telecide is being skipped by decimate since you're using a filter in between telecide and decimate (Hints should be passed onto a filter that can read hints or pass the hints onto another filter). Your script would be better suited being used like this.
global MeGUI_darx = 16
global MeGUI_dary = 9
DGDecode_mpeg2source("E:\work\test.d2v",cpu=4,info=3).ColorMatrix(interlaced=true,hints=true)

AssumeTFF()
#0 is for BFF
#1 is for TFF
Telecide(guide=1,post=4,hints=true)
Decimate(mode=3,threshold=1.0,quality=3)

Spline16Resize(592,336,6,56,-10,-64)

graysky
18th February 2007, 22:10
What neuron2's trying to say is the hints by telecide is being skipped by decimate since you're using a filter in between telecide and decimate (Hints should be passed onto a filter that can read hints or pass the hints onto another filter).

Thanks for the clarification. I actually understood the part about keep telecide and decimate together. What I don't understand is the usage suggestion in the docs. If telecide does the IVTC and deinterlaces if needed, and decimate removes the duplicates frames. How would my script look if I want to IVTC and use LeakKernelDeint to deinterlace?

Maybe I should back up... what is the intended use for LeakKernelDeint and how does it compare to decomb? Also, I read the avisynth docs but there isn't a whole lot about the Spline16Resize. Is it better for low bitrates than the bilinear when downsizing?

Terranigma
18th February 2007, 22:47
Thanks for the clarification. I actually understood the part about keep telecide and decimate together. What I don't understand is the usage suggestion in the docs. If telecide does the IVTC and deinterlaces if needed, and decimate removes the duplicates frames. How would my script look if I want to IVTC and use LeakKernelDeint to deinterlace?

Maybe I should back up... what is the intended use for LeakKernelDeint and how does it compare to decomb? Also, I read the avisynth docs but there isn't a whole lot about the Spline16Resize. Is it better for low bitrates than the bilinear when downsizing?

The intended use for leakkerneldeint is to deinterlace footage. If you don't want to use telecide for deinterlacing, change the post to either 0 or 1.

Telecide's Post options
* post=0: Use this to totally disable postprocessing.
* post=1: Use this to enable the metrics calculation and to display the vmetric values but not perform deinterlacing.
* post=2: Use this to enable deinterlacing. Note that in this mode, the field matching occurs normally and the best matched frame is deinterlaced and delivered.
* post=3: This is the same as post=2 except that the deinterlacing motion map is displayed in white on the deinterlaced frames.
* post=4: This is the same as post=2 except that instead of using the best field match for the frame, the original frame is deinterlaced. You would use this to pass video sequences through when you have a hybrid clip.
* post=5: This is the same as post=4 except that the deinterlacing motion map is displayed in white on the deinterlaced frames.
i'd personally use tdeint over either one of them, or a smart slow bobber.

What version of Avisynth are you using by the way? The Document for Spline16 and Spline36 can be found in the "resize" documents under the "corefilters" folder, though it doesn't give you any info on them.

Here's (http://forum.doom9.org/showthread.php?t=112594&highlight=spline16) why I suggested Spline36 :)

graysky
18th February 2007, 22:58
What version of Avisynth are you using by the way? The Document for Spline16 and Spline36 can be found in the "resize" documents under the "corefilters" folder, though it doesn't give you any info on them.

Yeah, I have 2.5.7 and I did read that page, but as you pointed out, it doesn't give any info on them beyond their syntax. Thanks for the thread you referenced.

The intended use for leakkerneldeint is to deinterlace footage. If you don't want to use telecide for deinterlacing, change the post to either 0 or 1.

OK, thanks for the info. My source is an mpeg-2 from a PVR-250 which dgindex reports as interlaced and which neuron2 told me would be hard interlaced. My understanding is that I have to run an IVTC in my script to undo this. Don't I also need to run a deinterlacer as well?

Inverse Telesync (IVTC) and deinterlacing... what is the difference?

Finally, if I can, I'd like to convert the 30 fps --> 24 fps for the simple reason that my filesize will decrease by 20 %. Isn't this what decimate is for?

Terranigma
18th February 2007, 23:20
Yeah, I have 2.5.7 and I did read that page, but as you pointed out, it doesn't give any info on them beyond their syntax. Thanks for the thread you referenced.



OK, thanks for the info. My source is an mpeg-2 from a PVR-250 which dgindex reports as interlaced and which neuron2 told me would be hard interlaced. My understanding is that I have to run an IVTC in my script to undo this. Don't I also need to run a deinterlacer as well?

Inverse Telesync (IVTC) and deinterlacing... what is the difference?

Finally, if I can, I'd like to convert the 30 fps --> 24 fps for the simple reason that my filesize will decrease by 20 %. Isn't this what decimate is for?
deinterlacing is converting an interlaced video into a progressive video.

IVTC is the process of matching up the even and odd fields of a telecined source.

Upload a small sample of the footage you're trying to process so we can then tell you what should be done. :devil:

graysky
19th February 2007, 00:14
no problem -- thanks for spending some time on this by the way!

You can d/l a 7 meg, 6 sec clip here (http://home.insightbb.com/~pixels/test_encode/test_6_sec.mpg).

Here is the script I wrote.# Set DAR in encoder to 16:9. The following line is for automatic signalling
global MeGUI_darx = 16
global MeGUI_dary = 9
DGDecode_mpeg2source("E:\work\test.d2v",cpu=4,info=3)
ColorMatrix(hints=true)

AssumeTFF()
Telecide(guide=1,post=2,vthresh=35) # IVTC
Decimate(quality=3) # remove dup. frames

Spline36Resize(592,336,6,56,-10,-64)

I figured out the field order and I also think this is 3:2 pull down after serving VDMAssumeTFF().SeparateFields() and noticing that the pattern of frames seems to be 3 same, 2 same, 3 same, 2 same.

If you can also describe the process you used to arrive at decision points you made (i.e. use Telecide(x,y,z) for this reason), that would be great!

Terranigma
19th February 2007, 00:56
no problem -- thanks for spending some time on this by the way!

You can d/l a 7 meg, 6 sec clip here (http://home.insightbb.com/~pixels/test_encode/test_6_sec.mpg).

Here is the script I wrote.# Set DAR in encoder to 16:9. The following line is for automatic signalling
global MeGUI_darx = 16
global MeGUI_dary = 9
DGDecode_mpeg2source("E:\work\test.d2v",cpu=4,info=3)
ColorMatrix(hints=true)

AssumeTFF()
Telecide(guide=0,post=2,hints=true) # IVTC
Decimate(mode=2,cycle=5,quality=3) # remove dup. frames



If you can also describe the process you used to arrive at decision points you made (i.e. use Telecide(x,y,z) for this reason), that would be great!

The script I came up with worked pretty well on your footage to my eyes
mpeg2source("E:\work\test.d2v",cpu=4,info=3).ColorMatrix(interlaced=true,hints=true)
tfm (http://web.missouri.edu/~kes25c/TIVTCv1.zip)(mode=4,pp=1,slow=2,flags=1,hint=true)
tdecimate (http://web.missouri.edu/~kes25c/TIVTCv1.zip)(hybrid=3)
o = last

AssumeTFF().SeparateFields()
dbl = mt_average( SelectEven().EEDI2(field=1,maxd=4),
\ SelectOdd() .EEDI2(field=0,maxd=4), U=3,V=3 )
dblD = mt_makediff(o,dbl,U=3,V=3)
shrpD = mt_makediff(dbl,dbl.removegrain(11),U=3,V=3)
DD = shrpD.repair(dblD,13)

dbl.mt_adddiff(DD,U=3,V=3)
Spline36Resize(592,336,6,56,-10,-64)

The approach I took was first recovering the progressive frames (IVTC), Decimating the Dupes, then used an approach by Didée (highlighted in green there) to deinterlace your source without much loss of detail and residual combing that a normal deinterlacer would create (it's really meant for anti-aliasing :angry: ).

graysky
19th February 2007, 00:59
Wow, 90 % of your script is above me. If you process it with the script I posted, how does it look to you? BTW, after reading through the decomb guide, I have changed it from the version you quoted# Set DAR in encoder to 16:9. The following line is for automatic signalling
global MeGUI_darx = 16
global MeGUI_dary = 9
DGDecode_mpeg2source("E:\work\test.d2v",cpu=4,info=3)
ColorMatrix(hints=true)

AssumeTFF()
Telecide(guide=1,post=2,vthresh=35) # IVTC
Decimate(quality=3) # remove dup. frames

Spline36Resize(592,336,6,56,-10,-64)

Terranigma
19th February 2007, 01:09
Wow, 90 % of your script is above me. If you process it with the script I posted, how does it look to you? BTW, after reading through the decomb guide, I have changed it from the version you quoted# Set DAR in encoder to 16:9. The following line is for automatic signalling
global MeGUI_darx = 16
global MeGUI_dary = 9
DGDecode_mpeg2source("E:\work\test.d2v",cpu=4,info=3)
ColorMatrix(hints=true)

AssumeTFF()
Telecide(guide=1,post=2,vthresh=35) # IVTC
Decimate(quality=3) # remove dup. frames

Spline36Resize(592,336,6,56,-10,-64)

Looks good, but I think this one would work be better

Telecide(guide=1,post=1) # IVTC
Decimate(quality=2) # remove dup. frames
o = last

AssumeTFF().SeparateFields()
dbl = mt_average( SelectEven().EEDI2(field=1,maxd=4),
\ SelectOdd() .EEDI2(field=0,maxd=4), U=3,V=3 )
dblD = mt_makediff(o,dbl,U=3,V=3)
shrpD = mt_makediff(dbl,dbl.removegrain(11),U=3,V=3)
DD = shrpD.repair(dblD,13)

dbl.mt_adddiff(DD,U=3,V=3)
Spline36Resize(592,336,6,56,-10,-64)

open yours in virtualdub, and take a look at frame 113, Look at the guy on the left's fingers. Then try my approach. :D

Edit:
oops! forgot to give you a link for EEDI2 (http://web.missouri.edu/~kes25c/EEDI2v092.zip) and masktools (http://avisynth.org/warpenterprises/files/masktools_25_dll_20060606.zip) :D

graysky
19th February 2007, 01:46
Yeah, I see what you mean. Can you post a link to the original thread by Didée? Also, is that code universal for hybrid material?

Thanks!

Terranigma
19th February 2007, 02:02
Yeah, I see what you mean. Can you post a link to the original thread by Didée? Also, is that code universal for hybrid material?

Thanks!

Sure. The original thread was started by Chainmax (Anti-Aliasing Thread). You can view the thread Here (http://forum.doom9.org/showthread.php?t=118784).
About it being universal, i'm not sure, give it a try.

Just make sure to set the proper field order first. use info() to check the field order of mpeg 2 files.

Also, you can grab the latest version of my favorite smart-bobber there too mcbob, which is also by none other than Didée :D