Log in

View Full Version : I've cracked the secret of the perfect deinterlacer for non-linear field behavior


Katie Boundary
3rd July 2022, 01:42
Deinterlacers have been driving me crazy for years. Video with various kinds of pathological non-linear field behavior, plus TFM's poor interlacing-detection algorithm, necessitated the development of a deinterlacer with the following characteristics:

- Every frame includes data from a top field and a bottom field
- No possibility of residual interlacing or interlacing-like artifacts
- No excessive blurring or aliasing
- Ghosting is acknowledged as a necessary price to pay for certain types of content to look correct

To my knowledge, no one has ever made a deinterlacer like this.

I tried TFM(pp=0).blur(0,1).sharpen(0,1), but this produced interlacing-like artifacts along some edges. I tried TFM(pp=0).resize(720,240).resize(720,480), but this destroyed too much data and yielded too much blurring and aliasing. Then I just sort of gave up for several months, or maybe years.

Then a few minutes ago, when I wasn't even doing anything video-related, the solution hit me:

Tfm(mode=0,pp=0,micmatching=0)

converttorgb(interlaced=true).blur(0,1).sharpen(0,1).converttoyv24()

a=nnedi3()

yadifmod2(edeint=a)

Go ahead and throw this at something really gnarly like the Gargoyles opening credits. The image quality is great with no interlacing-like artifacts, retrograde field behavior, or anything.

Katie Boundary
4th July 2022, 03:04
Here's a double-rate version, for when you need every field to be represented at least once:


a=Tfm(field=1,mode=0,pp=0,micmatching=0)
b=Tfm(field=0,mode=0,pp=0,micmatching=0)

c=interleave(a,b).converttorgb(interlaced=true).blur(0,1).sharpen(0,1).converttoyv24()

d=c.selecteven().nnedi3(field=1)
e=c.selectodd().nnedi3(field=0)

f=c.selecteven().yadifmod2(field=1,edeint=d)
g=c.selectodd().yadifmod2(field=0,edeint=e)

interleave(f,g)

Reel.Deel
4th July 2022, 03:56
converttorgb(interlaced=true).blur(0,1).sharpen(0,1).converttoyv24()

So a convoluted vinverse?


BTW, basically this is just good old "Blur(1.0).Sharpen(1.0)" ... but done correctly. ;)

# Vinverse: a small, but effective Function against (residual) combing, by Didée



Here's a double-rate version...

Not sure what is going on here but again, it seems highly convoluted. Can you post a sample to showcase your method?

Katie Boundary
5th July 2022, 02:34
converttorgb(interlaced=true).blur(0,1).sharpen(0,1).converttoyv24()

So a convoluted vinverse?

A what?

EDIT: after reading Didee's script... this is a hell of a lot less convoluted than his/her method.

Mounir
5th July 2022, 14:27
Do you have the Gargoyles opening credits video sample so we can see the end result ?

hello_hello
9th July 2022, 20:04
I've mentioned before that metric=1 for TFM can do better at detecting combing than the default for some sources. TFM's combing detection is generally pretty good though.

I've also mentioned before that bossing TFM around unnecessarily (restricting it) is probably going to cause problems at times. When I tried similar TFM de-interlacing methods previously, I'm sure it created occasional duplicate/dropped frames where there shouldn't be any, as it did for the video I was playing with when I stumbled on this thread.

For the attached sample, the first ten seconds or so are the gnarly part. After that I think any de-interlacing method would produce good results, at least in respect to smoothness of motion. I don't think combing detection would be a challenge either, although repairing it is probably a job for QTGMC.

A file with a name such as "TFM & QTGMC same rate" would' mean:

Deint = QTGMC(FPSDivisor = 2)
TFM(clip2 = Deint)

In the zip file (nothing profound, just some quick test encodes I tried)

Source mpeg2.ts
Katie double rate.mkv
Katie single rate.mkv
QTGMC double rate.mkv
TDeint & QTGMC double rate.mkv
TFM & NNEDI3 VFR.mkv
TFM & QTGMC same rate.mkv
TFM & QTGMC VFR.mkv

samples.zip (https://files.videohelp.com/u/210984/samples.zip) (77 MB)