Removing Interlacing Before Internet Distribution


If you happened to edit your video interlaced, you will definitely want to remove this interlacing before encoding it for the internet. Interlacing looks terrible on progressive displays like computer monitors and it makes good looking compression difficult.

There are many ways to remove interlacing. However, as your video has been edited together, some of these options are less successful than they would be before you started editing. So let's look at some possible techniques.

OK, so we just
IVTC, right?

Usually the best way to remove interlacing in anime is to use Inverse Telecine (IVTC). This matches up the fields in order to restore the progressive frames. These fields are usually in a pattern, so finding and combining them is usually not that difficult. However, your video has been edited. This makes things very tough indeed. Imagine one pattern of telecine being faded into another pattern of telecine... that pattern now becomes very difficult to find. Footage that is sped up will also have completely lost some fields, making it even harder to find the pattern.

IVTC also includes decimation. If you've done lots of tight editing, beat matching, flashes and all sort of other video trickery, it may be ruined by the decimation process as the footage is reduced from 29.97fps to 23.976fps.

So you can see now the basic problem that we have in removing interlacing with edited videos. Add to this the numerous problems that you can find in sources (hybrids, field blending etc etc) and it becomes a real mess.

So, what can you do?

There are several approaches to the problem, each with various success. Of the following options, only options 1, 4, 5 and 6 are appropriate for PAL footage. All of them are possible for NTSC footage but the first 3 are less likely to be a good choice and you should experiment with different strategies until you find something that works well for you.

Before you begin: Get the correct colourspace

It is likely that at this point you have an avi that has been exported losslessly from your editing program - probably in an RGB colourspace. For pretty much all the filters on this page you will need to convert this to YV12 (the exceptions to this rule will say what you need to convert it to instead). To do this conversion make sure you avisynth script looks something like this:
AVISource("youramv.avi")
ConvertToYV12(interlaced=true)


1) Try to IVTC anyway (rarely works well)

It may be that your video is edited together in such a simplistic way that IVTC will be just as good now as it would have been working on the original source. It's not very likely, but it's possible. If you are going to use this method, it's best to not use pattern matching so a basic script like this will do:
For NTSC:
Telecide(order=1)        #1 for Top Field First or Telecide(order=0) for Bottom.
Decimate(cycle=5)
For PAL:

Telecide(order=1,guide=2)      #1 for Top Field First or Telecide(order=0) for Bottom.

2) Use Decomb but treat as mostly FILM  (unlikely to work really well)

It's possible that your editing is still fairly basic and that you only really have to do full frame deinterlacing on certain parts - most of it can have fields recovered. If you think this is the case, you may want to try a method that will blend the pure interlaced fields together.
Telecide(order=1)    
Decimate(cycle=5, mode=3, threshold=1.0, quality=3)
Remember, this is still a decimation method so quick editing will suffer if you use this method.

3) Use decomb but treat as mostly NTSC. (not a bad solution)

If you have used a lot of quick editing, techniques like this can still work ok for removing interlacing. Again, field matching may not work so well and if you think that the majority of this video is just being full frame deinterlaced because there aren't many fields that match to make progressive frames, they you will be better off using one of the methods below.
Telecide(order=1)     
Decimate(mode=1, threshold=1.0, quality=3)
Test out this method but make sure you compare it to other methods too.


4) Full Frame Deinterlace (most likely solution)

Not always the prettiest option but certainly one of the more reliable techniques. If you have lots of complex editing and not much film footage in your video, these are the options you will probably want to try first:

FieldDeinterlace() - this is the Avisynth Version of the old virtualdub Smart Deinterlacer. You will want to tweak the thresholds of this manually to fit your source if you use it. The numerous parameters are described in the Decomb 5 Reference Manual. I've never really found this deinterlacer to give me particularly satisfactory results but different sources require different methods so you should experiment. Each source is different so any of these deinterlacers could give the best results.

SmoothDeinterlace(tff=true, doublerate=false) - this is an updated version of the old Area Based Deinterlacer and I think it's pretty decent at what it does. You need to specify field order and it will only accept YUY2 or RGB32 footage. If you have exported to huffyuv in RGB mode then you can skip the first line here:
ConvertToYUY2(interlaced=true)
SmoothDeinterlace(tff=true, doublerate=false)
KernelDeint(order=1, threshold=10) - This is a nice new deinterlacing approach. Order is just like the same setting in Telecide. 'Threshold' detects motion areas for deinterlacing - if too many areas are being deinterlaced then increase the threshold; if too few then reduce it. As with all Donald Graft filters, the settings are well documented and can be found in the start menu.
TomsMoComp(1,5,1) - This deinterlacer uses both adaptive and motion compensated deinterlacing and is generally considered to be a pretty worthy all-rounder and is the deinterlacer everything else is compared to. It's not perfect, no deinterlacer is, but it is good at what it does. The commands are given as numbers in order. 1 specifies this is Top Field First (0 would be BFF). 5 is the search effort (which is the value recommended) and 1 turns on the vertical filter. If you get a lot of noise then try setting the last number to 0 to turn off the vertical filter. This deinterlacer has some other interesting modes too, which you may wish to investigate in the documentation.
TomsMoComp is a very popular reliable full-frame deinterlacer so should be the first choice of people who can't be bothered to test all the other deinterlacers out :)

5) Ditch/Interpolate One Field (good solution)

All of the option above try and remove interlacing by trying to combine fields in different ways or trying to look only for areas that are interlaced and try to interpolate those.... well, it's all very well but the easiest way to remove interlacing is to simply scrap one of the fields.

SeparateFields()
SelectOdd()
This produces footage at half the full vertical resolution, so if your source was 720x480 it would now be 720x240. Although this basically assures that you will not have any interlacing you have lost 50% of the image. You can resize this to anything you like afterwards, but the resizer won't be able to restore the information that was in the other field.

Of course, it may be that you don't need much of a vertical resolution - if you are encoding something that has a 16:9 aspect ratio then a height of 240 isn't all that bad, provided you resize the width to fix the aspect ratio.

Still, it's less than ideal. However, there have been other solutions that work on this principle that can offer more pleasing results in terms of picture definition. The first one of these techniques is called Bobbing. This is where each field is separated and resized to full height. This deinterlaces well but gives a shimmering effect and twice as many frames a second. Thankfully, there are smart bobbers out there that can deal with this effect and try to give as good an image as possible. Bobber try and keep the definition by bobbing only moving areas. However, this also means that some may leave you with residual interlacing if they are not strong/successful enough.

Note:  The bobber commands here are all configured to NOT double the frame rate. Frame rate doubling gives better results but is also harder to compress.
DGbob(order=1,mode=0) - Order is just like with Telecide. Mode=0 will keep the frame rate the same as the source although it works best at double framerate (mode=1) you may not want to edit with that. For tweaking read the DGBob Help documentation in the amvapp start menu directory.

ConvertToYUY2(interlaced=true).SSTomsMoComp("tff") - tff obviously for Top Field First, replace with "bff" as required. This is a 29.97fps bob that uses a mix of supersampling and TomsMoComp. Works pretty well imo.

KernelBob(4).Decimate(2) - Bob deinterlacer that takes advantage of kerneldeint's processing. The number is the threshold used - see the KernelDeint readme.

TMCkernelbob(th=7,tff=true).Decimate(2) Another bob deinterlacer which uses both TomsMoComp and KernelDeint for constructing the frame. th is threshold (deafult 7) and tff is Top Field First - true or false.
The other way to deal with the one field approach is to try and interpolate the footage. Of course, this can be attempted by a resizer but there is a filter that is designed precisely for this use called SangNom. It has the advantage of containing inbuilt anti-aliasing and can do a pretty decent job:
SangNom(order=1,aa=32) - This filter interpolates fields and is very powerful when dealing with pure interlaced material. Order means field order just like Telecide, aa means Anti-Aliasing and will try to smooth out those lines when interpolating making it particularly useful for anime. Can be very pretty. The main downfall with this filter is that horizontal lines can often come out too thin or have odd interpolation so you should make sure your amv doesnt suffer from this problem.

6) Blending the fields together

This option compresses badly, makes all your motion look ghosted and generally isn't a great idea. It does remove interlacing well... just in a really bad way.

To do this simply use  Blur(0,1)

If you like it then go ahead and use it, but don't come crying to me when you realise that your video is really hard to compress and similarly difficult to watch.


Hopefully somewhere on this page you will find a solution that works well for you. Deinterlacing is never a perfect art form and some sources require all sorts of different techniques.

Once you have a script with deinterlacing, you will want to check out how to improve the visual quality of your video.