Log in

View Full Version : Question about DeInterlacing in Avisynth


iparout
17th October 2003, 01:07
Hi.

I have the following question. Say I have a movie which is NOT INTERLACED, however a part of it, say from frame 10000 up to 10100 is INTERLACED. Is it possible to create an avs file which will apply the deinterlace filter only to the part of the movie that is INTERLACED (frames 10000 - 10100), without applying the filter to the rest of the movie ? Creating 3 different avs files, one for the interlaced part, one for the part (0,10000) and the third for the part (10101,0) does not suit me because I have to have the entire film in a single avs file so as for DivX 5.0.5 Pro to properly calculate and adjust the bitrate during the 2-pass encoding. I tried to use the command FieldDeinterlace(10000,10100), however it gives an error probably because it’s not a valid syntax for this command.

Thanks in advance.

P.S. : To what it’s worth, I am using Gknot 0.28.5, however I believe that my question has to do with the avisynth script itself, that;a why I posted it here.

stickboy
17th October 2003, 02:54
Originally posted by iparout
Is it possible to create an avs file which will apply the deinterlace filter only to the part of the movie that is INTERLACED (frames 10000 - 10100), without applying the filter to the rest of the movie ?Sure.

Method 1:
ApplyRange(10000, 10100, "SomeDeinterlaceFilter", <filter arguments>)
Method 2:seg1 = Trim(0, 9999)
seg2 = Trim(10000, 10100).SomeDeinterlaceFilter(<filter arguments>)
seg3 = Trim(10101, 0)

seg1 + seg2 + seg3

iparout
17th October 2003, 12:30
Hi and thanks for your help.

I created the following command :



ApplyRange(10000, 10100, FieldDeinterlace()) however it doesn't look like it's valid.

Can you please tell me where I'm wrong. The Deinterlace filter I want to apply is FieldDeinterlace()

Thank you.

Guest
17th October 2003, 15:10
You can also use FD's manual override capability to specify treatment for different frame ranges.

iparout
17th October 2003, 16:30
Originally posted by neuron2
You can also use FD's manual override capability to specify treatment for different frame ranges.

Can you please specify that a little more, cause I am a newbie when it comes to Avisynth.

Thanks.

Guest
18th October 2003, 03:14
Originally posted by iparout
Can you please specify that a little more, cause I am a newbie when it comes to Avisynth. Excellent! That will make it a useful learning opportunity for you.

Make a file called "fd.ovr" and put this in it:

0,100 -
101,200 +
201,500 -

This specifies frames 100 to 200 to be deinterlaced. You can adjust it as needed for your clip. Then make your Avisynth script like this:

fielddeinterlace(..., ovr="fd.ovr")

Finally, serve your script into your target application, e.g., VirtualDub.

iparout
18th October 2003, 03:53
Thank you very much. I'm definately gonna try it. ;)

iparout
18th October 2003, 13:50
Just out of curiosity, what is wrong with the following ApplyRange command ? Where is the mistake in the syntax ? ApplyRange(10000, 10100, FieldDeinterlace()) VDub says the command is not valid.

Guest
18th October 2003, 18:15
Originally posted by iparout
Just out of curiosity, what is wrong with the following ApplyRange command ? Where is the mistake in the syntax ? ApplyRange(10000, 10100, FieldDeinterlace()) VDub says the command is not valid. You've already been told the syntax by stickboy. Is there something unclear about it?

ApplyRange(10000, 10100, "FieldDeinterlace", ...)

stickboy
18th October 2003, 21:56
If you want to call FieldDeinterlace() (i.e., with no arguments), then you can't use ApplyRange with it directly.

Here are three workarounds:

1. Use Method #2 in my previous post. (This is equivalent to my JDL_ApplyRange (http://www.avisynth.org/stickboy/) function.)

2. Since FieldDeinterlace does accept arguments, pass the default value for the first parameter:ApplyRange(10000, 10100, "FieldDeinterlace", true)3. Use a wrapper function (http://forum.doom9.org/showthread.php?s=&postid=336896#post336896).

iparout
19th October 2003, 00:57
Thanks for the input, I'll try that... Also, one last question. I've been using the FieldDeinterlace() filter (no arguments) for a couple years now and I am wondering if there are any deinterlace filters out there that will yield better results ? What is the optimal filter solution as far as deinterlacing goes ?

Thanks in advance for any feedback.

Guest
19th October 2003, 03:23
Originally posted by iparout
I am wondering if there are any deinterlace filters out there that will yield better results ? What is the optimal filter solution as far as deinterlacing goes ? There's no single most optimal filter. The optimality of any solution depends upon your specific application and your aesthetic tastes. For example, all deinterlacers produce artifacts, but the kind of artifacting depends upon the algorithm used. People have different opinions about which kinds of artifacts are the most objectionable. And it depends upon your specific clip and its characteristics. There is no shortcut for becoming familiar with the available deinterlacers and applying them as needed for any specific application.

FD is adequate and has features not found in other deinterlacers. KernelDeint() tries to improve interpolation in moving areas. TomsMoComp() has earned a loyal following.

As processors get faster, some interesting motion-compensated approaches will become practical for software filters, so you may see some dramatic changes in the future.

iparout
19th October 2003, 11:28
Originally posted by neuron2
There's no single most optimal filter. The optimality of any solution depends upon your specific application and your aesthetic tastes. For example, all deinterlacers produce artifacts, but the kind of artifacting depends upon the algorithm used. People have different opinions about which kinds of artifacts are the most objectionable. And it depends upon your specific clip and its characteristics. There is no shortcut for becoming familiar with the available deinterlacers and applying them as needed for any specific application.

FD is adequate and has features not found in other deinterlacers. KernelDeint() tries to improve interpolation in moving areas. TomsMoComp() has earned a loyal following.

As processors get faster, some interesting motion-compensated approaches will become practical for software filters, so you may see some dramatic changes in the future.

Thank you very muchs for your input.

Mug Funky
20th October 2003, 17:25
here's a nice, but very very slow deinterlacer for pure interlaced viddy. it won't touch progressive frames that it's run on except in special cases.



function FunkyDeInt (clip c)

{
c3=c.horizontalreduceby2().converttoyuy2(interlaced=true)

c2=subtract(c3.separatefields().selecteven(), c3.pointresize(c3.width,c3.height/2)).greyscale()
c2=subtract(c2,c2.deleteframe(0))

c2=layer(c2,c2.levels(0,1,255,255,0),op="lighten",level=255)
c2=c2.undot().blur(1).blur(1).levels(132,2,137,0,255).pointresize(c.width,c.height)

layer(c.converttorgb32(),mask(c.tomsmocomp(0,8,0).converttorgb32(),c2.converttorgb32()),op="add",level=255)\
.generalconvolution(0,"0 1 0 0 2 0 0 1 0").generalconvolution(0,"0 -2 0 0 7 0 0 -2 0")

converttoyv12()
#c2

}


for it to work you need undot and tomsmocomp installed. it works by making a simple motion mask, and comparing it with the mask from the next frame (necessary to ignore rainbow shimmer and horizontal static lines, which otherwise would be deinterlaced).

i've only found 2 cases where it leaves artifacts.
1. the input is very grainy - to the point where there's enough difference between lines caused by noise that the motion mask will deinterlace it. this will cause a shimmer in otherwise static scenes. playing with the code values will affect this.

2. very bright (224-255 luma range) very fast moving things. normally it doesn't matter, but you can occasionally see some greyish bits around the edges. this is due to defficiencies in layer's math operations. i'd love a simple "add" that actually adds values together.

edit... just splitting a long line so the screen doesn't go hella wide... sorry.

edit edit... changed script slightly because of stupid error. now grainy video doesn't shimmer nearly as much.