» AviSynth is a powerful video FrameServer for Win32.

AviSynth Links:
»Learn to script
»Discussion fora
»Project page
»External filters

» You can add pages to this website immediately. No login required.
Edit this document

» AboutAviSynth



Section 4: Importing filters from VirtualDub

( Diese Seite in flag-germany.gif Deutsch )

Q4.1: Where can I download the latest version of scripts which import filters from VirtualDub ?

A: The AviSynth scripts are on the ShareFunctions page, or you can download a package called vdub_filtersv15.zip from [1] or [2].

Q4.2: Which filters are imported ?

A: Most filters. Read the corresponding documentation.

Q4.3: Do these scripts work in RGB-space or in YUV-space ?

A: Only in RGB-space (RGB32).

Q4.4: How do I make such a script ?

A: Example script (this VirtualDub filter can be downloaded from [Donalds homepage]):

Smart Bob by Donald Graft:

function VD_SmartBob(clip ''clip'', bool ''show_motion'', int ''threshold'', bool ''motion_map_denoising'')
  LoadVirtualdubPlugin("d:\bob.vdf", "_VD_SmartBob", 1)
  return clip.SeparateFields._VD_SmartBob(clip.GetParity?1:0,
    \  default(show_motion,false)?1:0, default(threshold,10),
    \  default(motion_map_denoising,true)?1:0)

The VirtualDub plugin is imported with the command "LoadVirtualdubPlugin". The first argument gives the path of the plugin, the second argument the name for the plugin that will be used in the script and the third argument is called the preroll.

The preroll should be set to at least the number of frames the filter needs to pre-process to fill its buffers and/or updates its internal variables. This last argument is used in some filters like: SmartBob?, SmartDeinterlace?, TemporalCleaner? and others. The reason is that due to filtering architecture of Virtual Dub the future frames can't be accessed by a filter. Dividee reports: "In the "Add filter" dialog of VirtualDub, some filters have a "Lag:" value in their description. I think this is the value that must be used as preroll. Unfortunately, this indication is not always present. In those cases you have to guess." Of course you can always ask the creator of the filter.

The first step is to find out the sequence of the arguments in the last line where the clip is returned. Configure the script in VirtualDub and select "Save processing Settings" in the File Menu or press Ctrl+S. Open the created .vcf file with a text editor and you should see lines like this:

VirtualDub.video.filters.Add("smart bob (1.1 beta 2)");

VirtualDub.video.filters.instance[0].Config(1, 0, 10, 1);

The order of the arguments is the one that has to be used in AviSynth. To find the role of the arguments, play with them in VirtualDub and examine the resulting lines.

The second step is to test the filter and to compare it with the VirtualDub filter itself. For the programming itself you can learn a lot by looking at the script which are already contained in vdub_filters.avs.

Example script which uses the function VD_SmartBob:

ConvertToRGB32()  # only when necessary (but doesn't hurt)
VD_SmartBob(false, 10, true)
ConvertBackToYUY2()  # only when necessary

Back to AviSynthFaq

SourceForge Logo


Edit this document | View document history
Document last modified Sun, 04 Jul 2004 15:28:40