Log in

View Full Version : ZIVTC - Looking for feedback on anime ivtc function


Zarxrax
26th February 2006, 23:51
Edit: With the release of TDeint 1.0 RC3, this function is now obsolete. This function also was found to cause some problems in certain situations, so you shouldn't use it anymore. Now, you can effectively do the same thing as this function (but better) as follows:

deinted = tdeint(mode=2)
tfm(clip2=deinted)

Of course there are lots of settings that would need to be tweaked, but thats the basis of it.


Here is a function I have been working on and tweaking over the past few weeks. It is designed to combine the best qualities of both TIVTC and TDeint+BlendBob. It's quite a simple function though, and not difficult to understand.

First, lets see the advantages and disadvantages of each method on its own:

TIVTC:
+Fast
+Very powerful, lots of matching modes
-It can fail quite often on small details, requiring postprocessing of the frame
-The postprocessing looks like crap

TDeint+BlendBob:
+Easy to use and just works most of the time.
+Visually identical to correct TIVTC output.
-Slow
-Doesn't have as many matching modes as TIVTC, so it can fail on some parts, notably at scene changes or bad edits, causing blended frames.


ZIVTC
My function works by using TFM to perform field matching, and then uses TDeint+BlendBob on only the frames that need to be postprocessed. This results in a speed almost as fast as just using TIVTC (if the source is fairly clean). Because the output of TDeint+BlendBob is nearly identical to the output of TIVTC, you can set cthresh to a very low setting in order to ensure no interlaced frames slip through. When frames are postprocessed unnecessarily, you don't have to worry about the frame looking crappy.


#ZIVTC 1.1 created by Zarxrax (3/08/2006)
#Based on MatchBob by RaistlinMajere
#Required plugins: TIVTC, TDeint, BlendBob
#Purpose: To achieve nice and near-effortless IVTC of anime.
#
#Parameters: Order sets the field order of the clip. 0 is bottom field first, 1 is top field first. Default is -1 (autodetect).
# Mode sets the field matching mode in TFM. Try changing this if there are field matching problems. Default 1. See TFM documentation for description of each mode.
# cthresh sets combed frame detection. Lower values will catch more combed frames, but are slower. Recommended value 2-6. Default 4.
# pp=false will disable postprocessing. This is only useful if you need fast speed temporarily (such as when doing video editing).
# Use display=true to see which frames are being detected as combed.
#
#Example Usage: MPEG2Source("video.d2v").ZIVTC().Tdecimate(mode=1)
#

function ZIVTC(clip c, int "order", int "mode", bool "pp", int "cthresh", bool "display") {
odr = default(order,-1)
mod = default(mode,1)
ppr = default(pp,true)
cth = default(cthresh,4)
dpl = default(display,false)

pproc = (ppr==true) ? 2 : 0
error = BlankClip(c).ConvertToYV12().Subtitle("Error: ZIVTC requires YV12 colorspace.").Subtitle(align=4,"Use ConvertToYV12(interlaced=true)")
c = c.IsYV12 ? c : error
deint = c.TDeint(order=odr, mode=1, mtnmode=3).BlendBob()
c.TFM(order=odr, mode=mod, pp=pproc, cthresh=cth, slow=2, clip2=deint, display=dpl)
}


Mode is probably the most important setting. If you notice blended frames around scene changes or some such, try setting mode to 2 or 3 or something.

Changlog:
Version 1.1 - March 08, 2006
- Removed the extra TFM(). It seems it was unnecessary and caused problems in some situations. This should result in a small speed boost.
- Added pp setting to enable/disable postprocessing.
- No longer uses global variables.
- Checks if the input is YV12, and display an error if it isn't.

Version 1.0 - February 26, 2006
- Original Release

Chainmax
27th February 2006, 22:27
Sounds good, I'll try this along with TIVTC and TDeint+BlendBob and post the results.

MOmonster
1st March 2006, 10:43
Yes, itīs a nice idea.
Could you please upload a short sample that tfm doesnīt handle so good like your function. I life in a pal country and sources for tfm are really seldom, but for this cases tfm works allready really nice.

Chainmax
1st March 2006, 12:39
Here you go (http://www.31012.com/~azulftp/X-Men%20-%201x01%20-%20IVTC%2001%20(HUFF).01.avi). Could you please try ZIVTC and MVBob+BlendBob on it and post the results here?

Zarxrax
1st March 2006, 18:59
Chainmax: Wow, that source is really messed up. I have no problem removing the interlacing, but it appears that many frames are already DEINTERLACED. Its like telecine was done on an already badly deinterlaced source! I dont think there would be any way to fix this.

MOmonster: I can't think of any specific spots where TFM would fail at right now, but I know it does fail quite often. I have never seen a source that it would get 100% perfect. For 99% of the time, TFM does work perfectly, but its that other 1% of the time thats the problem. It has 2 problems. 1) it mainly misses small, minor motion, such as when a character in the distance is speaking. 2) When it deinterlaces a frame, its usually quite obvious, and if it deinterlaces frames that dont need deinterlacing (which sometimes happens), then you get ugly frames there.
Now if you spend some time really tweaking the settings, or if you make override files with YATTA or something, then you can get a perfect IVTC. But this costs time and effort. ZIVTC will do the job without all of this time and effort!

Chainmax
1st March 2006, 19:03
That's a capture from a commercial VHS I bought from Amazon. The only way to process them with decent results is to use TMPG's manual IVTC and I was wondering wether ZIVTC or MVBob+BlendBob could give good results on it.

Zarxrax
1st March 2006, 19:18
Chainmax: It's odd, Blendbob causes an access violation on this clip! I have never seen this problem before O_o

Edit: It seems blenbob just fails to make sure the source is in the correct colorspace.
Here is the clip with ZIVTC(cthresh=1).Decimate(mode=1)
http://zarxrax.kicks-ass.net/xmen-zivtc.avi

As you will notice there isn't any combing now... but the deinterlacing that already exists really kills the clip.

I couldn't get mvbob to work, it seems maybe the function was designed for an older version of mvtools, or something?

Chainmax
2nd March 2006, 15:04
It looks quite good, although not as good as the manually IVTCed version. About MVBob: I have no idea. Try this instead:

TDeint(1,1,mtnmode=3)
BlendBob()
TDecimate(mode=1)

Zarxrax
2nd March 2006, 21:12
That would give almost the exact same output as my function. Mine would just be quicker.

MOmonster
3rd March 2006, 10:28
@Zarxrax
Thanks for the information. Itīs maybe just to seldom that I can use tfm. I keep your function in my mind for the next Ivtc source I get.:)

@Chainmax
Yes, the source is really messed up. Iīm not able to have a closer look on it now, but like Zarxrax allready said, the allready existing deinterlaced parts are really bad.

Chainmax
3rd March 2006, 14:02
Zarxrax: I see. Damn, manual IVTCing sucks :(.