AviSynth Primer
AviSynth is a scripting engine, built to process video, that acts as what's known as a "frameserver". You create a plain text file with the extension .avs, type in a series of instructions for said engine to complete, open the script in an appropriate piece of software, and out the other end pops video. Frames of video are served by AviSynth to the calling application only when they're requested, a fact that plays in our favor; frames never requested are never generated, which lets script writers do some very useful things. But I digress.I'm going to try and get you up to speed quickly, so hang on, we're diving in headfirst. Get your test footage ready, ideally a short clip (twenty or thirty seconds is fine), and dump it into C:\UpscaleTutorial. Then open dvupscale.avs in Notepad, and we'll go through it line by line:
SetMTmode(5,0)
Right off the bat we have something not (yet) available in vanilla AviSynth. This function is provided by the modified avisynth.dll we installed earlier. SetMTmode turns on temporal multi-threading (multiple frames are processed at once, instead of multiple pieces of a single frame), and must be the very first line in any script where you wish to use it. Anything above it and you'll end up running single threaded, which will slow processing down immensely when using such complex scripts and plugins as ours.The two arguments passed in are the mode and the number of threads, respectively. Mode 1 is the fastest, 6 the slowest. In prior versions of this tutorial, I instructed readers to do something potentially unstable, and use mode 2 right away, instead of mode 5, which is safest for use with source filters. My apologies for the negligence.
Setting the number of threads to zero will automatically use as many threads as there are processors detected in the system (cores, that is, not just physical sockets). The number of threads can't be changed later in the script, but the mode can, and we'll do that presently.
AVISource("testclip.avi")
AssumeBFF()
SetMTmode(2)
ConvertToYV12(interlaced=true)
SimpleSlugUpscale()
AssumeBFF() describes the field order, or "parity", of our interlaced footage. Since the clip you're using is DV, it will be bottom field first in both NTSC and PAL formats. Mind you, the SimpleSlugUpscale script accepts either field order, so if you have top field first footage you want to process just use AssumeTFF() instead of AssumeBFF(). It also supports progressive footage by way of the 'prog' parameter, so if you don't need to deinterlace just add prog=true in between SimpleSlugUpscale's parentheses.
Explicitly declaring the field order is good practice, since many plugins will ask AviSynth for that information when processing clips.
After the field order is set we finally put on some speed, switching to mode 2 with SetMTmode. Mode 1 is faster, but isn't compatible with all of the plugins used by TempGaussMC.
Then we have a colorspace conversion. A discussion of color space is outside the scope of this tutorial, it will suffice to say that your video must be in the proper format for the deinterlacer in use. SimpleSlugUpscale allows many different deinterlacers, but by default I use TempGaussMC, which requires YV12 color, so with ConvertToYV12() we convert our clip. Make sure to set interlaced true, otherwise the conversion will be done incorrectly.
Up through version 0.7h of SimpleSlug, I took care of this step automatically. When designing 0.8, however, it struck me as a good idea to allow people to use their favorite deinterlacers. It was a trivial change, but some deinterlacers will work with YUY2 and RGB color, so I didn't want to force a potentially unnecessary conversion.
Finally there's my script, SimpleSlugUpscale(). Simple because there are only a few options of vital importance (prog, widein and size), Slug because the deinterlacing script it makes use of by default, that TempGaussMC thing we downloaded earlier, runs at a fraction of the speed you'll get from most others. The extra time required comes with the reward of the most stable footage you've likely ever seen, and shallow diagonal lines smoother than I ever thought were possible from interlaced origins.
The only thing you may want to do is pass a couple of arguments into SimpleSlugUpscale. The defaults will deinterlace the video very well and scale to 1280x720, but they run a bit slowly for just trying things out. I'd recommend changing that last line to
SimpleSlugUpscale(qual="low",size="480sq")
Almost done! A quick trip through VirtualDub and we'll have our finished product.
