Log in

View Full Version : how to make Avisynth interfaces to VirtualDub plugins


Wilbert
27th March 2002, 17:15
how to make Avisynth interfaces to VirtualDub plugins ?

Look for example at the following script:

function VD_Xsharpen(clip clip, int "strength", int "threshold")

{ LoadVirtualdubPlugin(VirtualDub_plugin_directory+"\xsharpen.vdf", "_VD_Xsharpen")
return clip. _VD_Xsharpen(threshold,strength) }

The input arguments are first treshold and then strength. But if we open VirtualDub and the Xsharpen filter it is the other way around:
first strength and then below the treshold setting.

My question is why? How do you know the correct order of all the arguments?

dividee
27th March 2002, 20:29
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 that:

VirtualDub.video.filters.Add("unsharp mask (1.3)");
VirtualDub.video.filters.instance[0].Config(5, 32, 0, 0, 0, 0, 0, 0);
The order of the parameters is the one that has to be used in avisynth. To find the role of the parameters, play with them in virtualdub and examine the resulting lines.


Another way is simply looking at the source code of the filter, if available.
There should be a function called "ScriptConfig" with lines such as:

mfd->motionOnly = !!argv[0].asInt();
mfd->Blend = !!argv[1].asInt();
mfd->threshold = argv[2].asInt();
...

If the author choosed meaningful variables names, you're set;
for the above example, it means the first parameters is a "motion only" flag, the second a "blend" flag, the third a "treshold" (and you know the two first parameter are boolean values (thanks to the !!) and the third is an integer

Wilbert
2nd April 2002, 16:03
Thx for your explanation. A related question about the argument "preroll":

LoadVirtualDubPlugin("filename","filtername",preroll)
"(..) for those 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."

For example:

Temporal Cleaner --> preroll = 10
Smart Bob, smart deinterlace , ... --> preroll = 1
others --> preroll = 0

I don't understand anything of this. Why/when does a filter (T. Cleaner for example) need to fill its buffers? Why/when must it update its internal variables? How do you know what value should be used?

Thanks again,

dividee
2nd April 2002, 17:46
Due to the filtering architecture of Virtual Dub, future frames cannot be accessed by a filter. Some filters works around this problem by buffering frames internally and only output the first filtered frame once their buffer is full. These filters have a "lag" in virtual dub. For example, a deinterlacer might need to look at the next frame, and a temporal denoiser a few frames forward. In The "Add filter" dialog of vdub, 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 case you have to guess.
Note that the only filters I think should access future (or previous) frames are Deinterlacer/IVTC and temporal denoiser, but very good filters for those purposes now exists natively for avisynth.

nicksteel
25th December 2011, 17:21
Need to run a virtualdub plugin (MSUColorEnhancement.vdf) in avisynth.

Ran virtualdubmod, added only this plugin and saved .vcf file. Can't figure out how to structure avisynth avs file to use with hcencoder. (Read everything I could find, but it's way over my head!)
---------------------------------------------------

LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")

dgdecode_mpeg2source("C:\Users\Nickster\Desktop\SOTSX\VIDEO_TS\VTS_01_1.d2v",idct=7)

ConvertToRGB32()
VD_MSUColorEnhancement()
ConvertBackToYUY2()

function VD_MSUColorEnhancement()
{ LoadVirtualdubPlugin(C:\Video\HC026\VDPlugins\MSUColorEnhancement.vdf, "_MSUColorEnhancement 1.0b")
return _MSUColorEnhancement 1.0b }
-----------------------------------------------------
# .vcf file from Virtualdubmod
#VirtualDub.RemoveInputStreams();
#VirtualDub.stream[0].SetSource(0x73647561,0);
#VirtualDub.stream[0].DeleteComments(1);
#VirtualDub.stream[0].AdjustChapters(1);
#VirtualDub.stream[0].SetMode(0);
#VirtualDub.stream[0].SetInterleave(1,500,1,0,0);
#VirtualDub.stream[0].SetClipMode(1,1);
#VirtualDub.stream[0].SetConversion(0,0,0,0,0);
#VirtualDub.stream[0].SetVolume();
#VirtualDub.stream[0].SetCompression();
#VirtualDub.stream[0].EnableFilterGraph(0);
#VirtualDub.stream[0].filters.Clear();
#VirtualDub.video.DeleteComments(1);
#VirtualDub.video.AdjustChapters(1);
#VirtualDub.video.SetDepth(24,24);
#VirtualDub.video.SetMode(3);
#VirtualDub.video.SetFrameRate(0,1);
#VirtualDub.video.SetIVTC(0,0,-1,0);
#VirtualDub.video.SetCompression();
#VirtualDub.video.filters.Clear();
#VirtualDub.video.filters.Add("MSUColorEnhancement 1.0b");

Mounir
25th December 2011, 19:23
I think this filter (msu enhancement) for some unknown reason to me can't be used in avisynth, i have opened the vcf and the parameters are empty, only the following line:

VirtualDub.video.filters.Add("MSUColorEnhancement 1.0b");

All msu filters work but not this one, no luck eh ?

IanB
25th December 2011, 23:19
You cannot put spaces in the Avisynth local filtername. It needs to be a valid Avisynth variable name.

The name is used here:- avisynth\src\core\plugins.cpp@1066 fm->env->AddFunction(fm->avisynth_function_name, "c", VirtualdubFilterProxy::Create, fd);The code probably should validate the name, but it does not.


And you need to pass in a clip to operate against.LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")

LoadVirtualdubPlugin("C:\Video\HC026\VDPlugins\MSUColorEnhancement.vdf", "_MSUColorEnhancement")

dgdecode_mpeg2source("C:\Users\Nickster\Desktop\SOTSX\VIDEO_TS\VTS_01_1.d2v",idct=7)

ConvertToRGB32()
VD_MSUColorEnhancement()
ConvertBackToYUY2()

function VD_MSUColorEnhancement(Clip IClip) {
return IClip._MSUColorEnhancement()
}

nicksteel
26th December 2011, 00:12
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")
LoadVirtualdubPlugin(C:\Video\HC026\VDPlugins\MSUColorEnhancement.vdf, "_MSUColorEnhancement")
dgdecode_mpeg2source("C:\Users\Nickster\Desktop\SOTSX\VIDEO_TS\VTS_01_1.d2v",idct=7)

ConvertToRGB32()
VD_MSUColorEnhancement()
ConvertBackToYUY2()

function VD_MSUColorEnhancement(Clip IClip) {
return IClip._MSUColorEnhancement()
}

Error in HCGUI 0.26
error loading Avisynth scrip,Script error expected a , or ) (C:\Users\Nickster\desktop\SOTSX\VIDEO_TS\testavs, line#2, column 23)


And, MERRY CHRISTMAS, guys.

Gavino
26th December 2011, 01:45
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")
LoadVirtualdubPlugin(C:\Video\HC026\VDPlugins\MSUColorEnhancement.vdf, "_MSUColorEnhancement")
...
Error in HCGUI 0.26
error loading Avisynth scrip,Script error expected a , or ) (C:\Users\Nickster\desktop\SOTSX\VIDEO_TS\testavs, line#2, column 23)
You need to put quotes around the name of the .vdf file:
LoadVirtualdubPlugin("C:\Video\HC026\VDPlugins\MSUColorEnhancement.vdf", "_MSUColorEnhancement")