Making your footage Progressive

Hopefully by this point you will know (or at least have a good idea) whether your source is Telecined, Hybrid, Field-Blended or Pure Interlaced.
Armed with this knowledge I can show the different ways of handling this footage. If, on the other hand, you read the Analyzing your Footage page and couldn't decide which type of interlacing your source had then you may want to try each method one by one and see what looks best to you.

Methodology

The information contained on this page are general rules of thumb and like all rules there are exceptions. When reading this document you should try to understand why certain options are being used so that you can modify these depending on your own source footage. There are different solutions to different problems and although I have tried to cover numerous possibilities it is very likely that you may find better solutions yourself so don't be afraid to experiment.

For most of our efforts at restoring progressive frames, we will be using two plugins: TIVTC and TDeint. TIVTC is an inverse telecine plugin which we will be using (replacing Decomb from the old version of this guide). TDeint is an excellant deinterlacing plugin, which uses some interesting deinterlacing techniques which work quite well for anime. I highly recommend that you become familiar with these plugins by reading the documentation on them which is available in your start menu (if you installed the AMVApp).

TIVTC uses a function called TFM() to do the field matching. This function has a LOT of settings that you can tweak. I'm not going to cover all of those settings in this guide, because I would just be restating what is already written in the TFM readme file. I highly recommend that you look over it to get a feel for what all of the various options can do.

After TFM is used, we will have some duplicate frames. To remove these duplicates, we need to use a function called TDecimate(). This will change the framerate of the video from 29.97 fps to 23.976 fps. If you are using PAL footage though, you don't need to use TDecimate.


Before You Begin

Before you do anything on this page, you need to decide whether you are planning to edit directly from the AviSynth files, or if you plan to make clips. If this is your first time using this guide, you should skip ahead to this page which gives a thorough explaination of each method. After you have decided how you will be editing, then come back here and expand the appropriate section below.

collapse control I plan to create AVI clips (methods 1 or 3)

collapse control Telecined Footage
Note: If you are using editing method 3 ("bait-and-switch" method), you will need to make a minor change to the scripts below. Whenever You see the TDecimate() command, you will notice that it contains the parameter mode=1. You need to change this to mode=0. This is extremely important and only applies to those who use method 3.

The simple stuff - or so we hope. The TIVTC functions should be able to deal with this sort of footage very easily by using Inverse Telecine. This will take your footage and restore the original progressive frames. With NTSC footage this will also restore the framerate to 23.976fps whereas PAL will keep the its framerate of 25fps. TDeint is used as a postprocessor to deinterlace any frames that couldn't be properly matched by TIVTC.

For NTSC footage you you make a script like this:
MPEG2Source ("C:\yourfolder\blah.d2v")
TFM(slow=2)
TDecimate(mode=1)

The slow parameter in TFM() is simply telling it to use the slowest and most accurate field matching. The mode=1 parameter is telling Tdecimate to use a particular decimation mode which is more suitable for animated material.

If you have PAL footage, simply omit the TDecimate() line. PAL footage does not need to have it's framerate decimated. However, if you have PAL footage, it is far more likely that you have full field blended footage, which is explained further down this page. Situations where you would use TFM on PAL footage are quite rare.


Better post-processing:

The simple script above will work pretty well, but I think we can do better. First though, let me explain what the post-processing is. Sometimes, TFM is not able to restore a progressive frame, and it will have to simply deinterlace the frame. However, I think TFM's built in deinterlacers kinda suck. Fortunately, TFM has an advanced feature that lets you utilize any deinterlacer that you want! With this feature, we are able to use TDeint, which is in my humble opinion, the greatest deinterlacer for anime in existance. Here is a script that you can use, along with my favorite TDeint settings:

MPEG2Source ("C:\yourfolder\blah.d2v")
deint = TDeint(mode=2, mtnmode=3, blim=100)
TFM(cthresh=4, slow=2, clip2=deint)
TDecimate(mode=1)

A number of new parameters have been used here, but I am not going to go into the specifics of what they all do. If you are curious then I recommend that you check out the TFM and TDEINT readme files. And again, if you have PAL footage, omit the TDecimate() line.


collapse control Hybrid Footage
This stuff isn't much more complicated than telecined footage, but you'll need to make a decision on the nature of your hybrid footage - is it more basic FILM or more VIDEO? This will govern how the thing is Decimated. Note that Hybrid Sources are basically an NTSC phenomenon so there's no PAL option here.

Mostly FILM:
You simply use the same script you would use for Telecined footage that was shown above. However, there is a problem. The VIDEO (29.97fps) sections of your footage will now become jerky. If your footage doesnt have many of these sections, or if you might not even use any of that footage, then you don't even need to worry.

Mostly 29.97 fps:
Just do it exactly the same as above, but don't include the TDecimate() command. Just like the PAL script. This method will give you 29.97fps footage. If you plan to mix it with other sources that use a framerate of 23.976, you will need to follow it up with AssumeFPS("ntsc_film"). Again though, this method has a problem. This will cause all of the FILM (23.976fps) sections of your footage to be jerky. It probably wont be too noticable though, but it can be a problem.

The best way to deal with Hybrid Footage:
Now, no matter whether you choose the method for mostly FILM, or mostly interlaced, either your 23.976fps scenes or your 29.97fps scenes are going to end up with some jerky sections. Wouldn't it be great if there was a way to get BOTH the 23.976 and 29.97 fps scenes without any jerkiness? Well, fortunately there is. It's quite simple, but requires a little extra work. All we need to do is make two avisynth scripts. One for the 23.976 fps scenes, and another one for the 29.97 fps scenes. Then when you edit your video, you can use whichever script displays the particular scene you need the best.
For your first script, you simply need to use the script recommended above for Telecined Footage.

For your second script, you need to determine whether the 29.97 fps scenes are interlaced or progressive. The way to do this is by looking at the 29.97 fps sections in VirtualDubMod and see if there is any interlacing visible.

If it's progressive, you simply need a script like this:
MPEG2Source("C:\yourfolder\blah.d2v")
AssumeFPS("ntsc_film")
Since the 29.97 fps scenes are already progressive, we simply change the framerate to match the Telecined footage.

If it's interlaced, you need a script like this:
MPEG2Source("C:\yourfolder\blah.d2v")
TDeint()
AssumeFPS("ntsc_film")
Here, we add a deinterlacer before changing the framerate. You can actually use any deinterlacer you want, and there are more listed below in the section on Pure Interlaced Footage.

collapse control Field Blended Footage

If you have half field blended or full field blended footage, no solution will ever be satisfactory and you will really want to experiment as much as possible to find a solution you are happy with. Full deinterlacing may work well on some particular sources so you should refer to the section on pure interlacing for some good approaches.

For half-blended stuff, like most older GAINAX series, you usually want to just try IVTC, and just accept the blends as a fact of life. Plain deinterlacing may be another option.

If you have a full field blended source, which is usually the case with PAL footage, you will probably just deinterlace. Another option you have with PAL footage is a function called MRestore. MRestore should ONLY be tried if you have PAL footage with a framerate of 25 fps. MRestore will attempt to convert the material back to its original framerate of 23.976 fps while removing blended frames. MRestore can be used like so:

MPEG2Source("C:\yourfolder\blah.d2v")
TDeint(mode=1)
Mrestore()
MRestore may often look worse than simply deinterlacing though, but it doesn't hurt to give it a shot and see if you like how it turns out.



collapse control Pure Interlaced Footage
When you have a source where looking for progressive frames is mostly futile, it is often best to just attempt to deinterlace the source. There are many different ways to deinterlace things and, like many things, the best method will depend on your source.
TDeint() - Tdeint is a deinterlacer that uses motion adaptation and all kinds of interesting interpolation tricks. This is a really excellent deinterlacer and worth trying.

At the default settings, this does a pretty nice job at deinterlacing by interpolating the fields, but this can leave jagged lines in the video. I also highly recommend you try this filter with the following settings: TDeint(mode=2, mtnmode=3, blim=100)

This filter has a lot of different options and modes which cause it to deinterlace in different ways. I highly recommend you check out the documentation on it and experiment to see what works best for your particular source.

TomsMoComp(1,5,1) - This deinterlacer uses both adaptive and motion compensated deinterlacing and is generally considered to be a pretty worthy all-rounder. 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.

SangNom(order=1,aa=32) - This filter interpolates fields and is very powerful when dealing with pure interlaced material. Order sets the field order, and aa means Anti-Aliasing and will try to smooth out those lines when interpolating making it particularly useful for anime.

collapse control I plan to edit the AviSynth files directly (method 2)

collapse control Telecined Footage
The simple stuff - or so we hope. The TIVTC functions should be able to deal with this sort of footage very easily by using Inverse Telecine. This will take your footage and restore the original progressive frames. With NTSC footage this will also restore the framerate to 23.976fps whereas PAL will keep the its framerate of 25fps. TDeint is used as a postprocessor to deinterlace any frames that couldn't be properly matched by TIVTC.



First, the normal method: For NTSC footage you you make a script like this:
MPEG2Source ("C:\yourfolder\blah.d2v")
TFM()
TDecimate()

If you have PAL footage, simply omit the TDecimate() line. PAL footage does not need to have it's framerate decimated. However, if you have PAL footage, it is far more likely that you have full field blended footage, which is explained further down this page. Situations where you would use TFM on PAL footage are quite rare.

Better post-processing:

The simple script above will work pretty well, but I think we can do better. First though, let me explain what the post-processing is. Sometimes, TFM is not able to restore a progressive frame, and it will have to simply deinterlace the frame. However, I think TFM's built in deinterlacers kinda suck. Fortunately, TFM has an advanced feature that lets you utilize any deinterlacer that you want! With this feature, we are able to use TDeint, which is in my humble opinion, the greatest deinterlacer for anime in existance. Here is a script that you can use, along with my favorite TDeint settings:

MPEG2Source ("C:\yourfolder\blah.d2v")
deint = TDeint(mode=2, mtnmode=3, blim=100)
TFM(pp=0, cthresh=4, clip2=deint) #pp=0 while editing, change to pp=6 before exporting
TDecimate()

There is one important caveat with this though--this deinterlacing method is very slow. This is not suitable for editing at all. There is a little trick that you can use though. Just include the parameter pp=0 in TFM, like I did here. This tells it not to do any post-processing at all. Then, after you finish editing but before you export your video, you can change it to pp=6 (or just remove the pp parameter altogether).

And again, if you have PAL footage, omit the TDecimate() line.


collapse control 2-Pass IVTC (Advanced)

The 2-pass IVTC method--Better and faster, but more complex

Ok, now I'm going to show you a two-pass IVTC method that will significantly speed up your avisynth scripts while at the same time allowing for a slightly better quality IVTC method. However, be warned this is an advanced technique and requires a bit of extra time to set up.

Before we get started, I'll give you a quick overview of what we are going to do. When you perform IVTC by using the TFM and TDecimate commands, it uses up processing power trying to match the fields together and deciding which frames to decimate. This causes everything to go quite a bit slower, which can make editing slower and more difficult than it needs to be. TFM and Tdecimate can both save all of their calculations into files though! This allows us to perform the IVTC before we start editing, and then when you edit, everything will be just as fast and snappy as if you weren't doing any IVTC at all!

First, you need to make a script like this:

MPEG2Source ("C:\yourfolder\blah.d2v")
TFM(slow=2, output="C:\yourfolder\something.tfm")
TDecimate(mode=1, output="C:\yourfolder\something.dec")
Crop(0,0,4,2)

Please notice the output parameter that is present in both TFM and TDecimate. It specifies a filename to which its decisions will be saved. Please change the filenames to something meaningful to you, but make sure not to use the same filename as another file. If you are preparing multiple scripts, make sure to use different filenames in each one! You will probably also notice the crop function. This reduces the video to an insanely small size, and is there for the sole purpose of speeding up the encode we are about to do...

Open up the script in VirtualDubMod. Since we cropped the video down to such a small size, it will be too small for you to really see. Just go to the Video menu, and set it to Direct Stream Copy. Now go to File > Save As, and select a place to save the avi to. You don't need to bother selecting a codec to use, because this file will require very little space. If you have multiple scripts to process, you might find it useful to use the Job Control (as was discussed in the VirtualDubMod Guide).

After the encode finishes, close VirtualDubMod. If you don't close it, avisynth might not finish writing to the files. Feel free to delete the avi file you just saved. We won't be needing it. You should now have new files with the filenames you specified in your script. If not, something must have went wrong, and you should double-check the steps you took. Now, we need to go back to the avisynth script and make some modifications.

Now, you change your script to look like this:

MPEG2Source ("C:\yourfolder\blah.d2v")
TFM(input="C:\yourfolder\something.tfm")
TDecimate(input="C:\yourfolder\something.dec")

Notice that we have changed the output commands to input. This is extremely important.

And thats it! This method might seem a little complicated at first, but after you do it once or twice, you'll see that its quite easy, and aside from waiting on VirtualDubMod to process the file, it doesn't take much longer to do than the other method.


Can we use the better post-processing with this 2-pass method?

Yes we can, but it complicates things even further. If you are up to it, here is the script that you will need for the first pass:

MPEG2Source ("C:\yourfolder\blah.d2v")
TFM(cthresh=4, slow=2, clip2=deint, output="C:\yourfolder\something.tfm")
TDecimate(mode=1, output="C:\yourfolder\something.dec")
Crop(0,0,4,2)

Then after you do the stuff in VirtualDubMod and have your files, you change your script to this:

MPEG2Source ("C:\yourfolder\blah.d2v")
deint = TDeint(mode=2, mtnmode=3, blim=100)
TFM(pp=0, clip2=deint, input="C:\yourfolder\something.tfm") #set pp=6 after editing
TDecimate(input="C:\yourfolder\something.dec")

Like I said above, this deinterlacing method is too slow to be used while you are editing, even with this 2-pass method. So if you want to use this type of deinterlacing, then you need to set pp=0 while you are editing, and then change it to pp=6 when you finish editing.


collapse control Hybrid Footage
This stuff isn't much more complicated than Telecined footage, but you'll need to make a decision on the nature of your hybrid footage - is it more basic FILM or more VIDEO? This will govern how the thing is Decimated. Note that Hybrid Sources basically are an NTSC phenomenon so there's no PAL option here.

Mostly FILM:
You simply use the same script you would use for Telecined footage that was shown above. However, there is a problem. The VIDEO (29.97fps) sections of your footage will now become jerky. If your footage doesnt have many of these sections, or if you might not even use any of that footage, then you don't even need to worry.

Mostly VIDEO:
Just do it exactly the same as above, but don't include the TDecimate() command. Just like the PAL script. This method will give you 29.97fps footage. If you plan to mix it with other sources that use a framerate of 23.976, you will need to follow it up with AssumeFPS("ntsc_film"). Again though, this method has a problem. This will cause all of the FILM (23.976fps) sections of your footage to be jerky. It probably wont be too noticable though, but it can be a problem.

The best way to deal with Hybrid Footage:
Now, no matter whether you choose the method for mostly FILM, or mostly VIDEO, either your 23.976fps scenes or your 29.97fps scenes are going to end up with blended frames. Wouldn't it be great if there was a way to get BOTH the 23.976 and 29.97 fps scenes without any blended frames? Well, fortunately there is. It's quite simple, but requires a little extra work. All we need to do is make two avisynth scripts. One for the 23.976 fps scenes, and another one for the 29.97 fps scenes. Then when you edit your video, you can use whichever script displays the particular scene you need the best.
For your first script, you simply need to use one of the scripts recommended above for Telecined Footage.

For your second script, you need to determine whether the 29.97 fps scenes are interlaced or progressive. The way to do this is by looking at them in VirtualDubMod and see if there is any interlacing visible.

If it's progressive, you simply need a script like this:
MPEG2Source("C:\yourfolder\blah.d2v")
AssumeFPS("ntsc_film")
Since the 29.97 fps scenes are already progressive, we simply change the framerate to match the Telecined footage.

If it's interlaced, you need a script like this:
MPEG2Source("C:\yourfolder\blah.d2v")
LeakKernelDeint(order=1, threshold=10) #order=0 for bottom field first
AssumeFPS("ntsc_film")
Here, we add a deinterlacer before changing the framerate. You can actually use any deinterlacer you want, and there are more listed below in the section on Pure Interlaced Footage. I have chosen this deinterlacer though, because it is fast, and the speed of your scripts is an important concern when editing from AVS files.

collapse control Field Blended Footage

If you have half field blended or full field blended footage, no solution will ever be satisfactory and you will really want to experiment as much as possible to find a solution you are happy with. Full deinterlacing may work well on some particular sources so you should refer to the section on pure interlacing for some good approaches.

For half-blended stuff, like most older GAINAX series, you usually want to just try IVTC, and just accept the blends as a fact of life. Plain deinterlacing may be another option. If you have a full field blended source, which is usually the case with PAL footage, you will probably just deinterlace.



collapse control Pure Interlaced Footage
When you have a source where looking for progressive frames is mostly futile, it is often best to just attempt to deinterlace the source. There are many different ways to deinterlace things and, like many things, the best method will depend on your source.
LeakKernelDeint(order=1, threshold=10) - This is a pretty nice deinterlacer, and I highly recommend it for editing directly from AVS files, because it is quite fast. This filter requires that you manually specify the field order. You should know this from back on the analyzing your footage page.

TDeint() - Tdeint is a deinterlacer that uses motion adaptation and all kinds of interesting interpolation tricks. This is a really excellent deinterlacer and worth trying. This filter should automatically detect the field order, assuming it follows an MPEG2Source command, but you can also specify it manually with the order parameter.

At the default settings, this does a pretty nice job at deinterlacing by interpolating the fields, but this can leave jagged lines in the video. This filter has a lot of different options and modes which cause it to deinterlace in different ways, so I highly recommend you check out the documentation on it and experiment to see what works best for your particular source.

TomsMoComp(1,5,1) - This deinterlacer uses both adaptive and motion compensated deinterlacing and is generally considered to be a pretty worthy all-rounder. 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.

SangNom(order=1,aa=32) - This filter interpolates fields and is very powerful when dealing with pure interlaced material. Order sets the field order just like with most of the other deinterlacers, aa means Anti-Aliasing and will try to smooth out those lines when interpolating making it particularly useful for anime. Can be very pretty.


Dealing with the new FPS

After you have successfully made your footage progressive (in the sections above) you need to think about what effect this change has on things. This all depends on the new framerate.

23.976fps Footage

You have done IVTC on NTSC material and now have progressive frames at 23.976fps. This is good, particularly when editing with programs such as Vegas which support 23.976fps projects.

Be warned that Adobe Premiere can't handle 23.976fps without screwing up and yes that includes some versions of Premiere Pro as well. 23.98fps is NOT the same as 23.976 and you will get things mistimed and miscalculated. Some other editing programs like Magix also may not properly support 29.976 fps.

If you are using Premiere you basically have two options
1) Convert to 24fps and edit with that or
2) Convert to 29.97fps, have sped up footage and produce progressive NTSC video.
If you want to edit the video at 24fps then you will need to read this page on how.

If you want to just edit it as progressive 29.97fps then add AssumeFPS("ntsc_video") after your have done your IVTC filtering.

29.97fps Footage

Your interlacing removal has left you with a 29.97fps source. You can go straight ahead and edit this as NTSC. It does not have a field order (set rendering to "no fields" in your editing program) but it can be considered either top field or bottom field by any playback device so it is good for converting to DV or MPEG2 or anything you like for conventions. It's also fine for making internet distribution encodes as the frames are progressive.

25fps

If you have progressive 25fps footage then you can quite simply edit with the regular PAL profiles in your editing application. Remember that field rendering should be set to "no fields" if you now have progressive frames and that you can create DV and mpeg2 files with any field order you like as it will be look the same.

xx.xxfps

If you have a framerate that is not one of the above then you should check your settings and re-read this page - you may be trying to do something silly like Decimate PAL footage or do IVTC on a source that has already been put (incorrectly?) through Force FILM in DGIndex.