Plugins
(some reformatting) |
Raffriff42 (Talk | contribs) (formatting, links, phrasing) |
||
Line 1: | Line 1: | ||
− | = | + | <div style="max-width:62em" > |
− | With these functions you can add external filters to AviSynth. | + | With these functions you can add external filters (DLLs) to the AviSynth script environment. |
− | + | __TOC__ | |
===LoadPlugin=== | ===LoadPlugin=== | ||
− | Loads one or more | + | Loads one or more standard (C++) AviSynth plugins. |
+ | <div {{BoxWidthIndent|38|1}} > | ||
+ | LoadPlugin ("filename" [, ...]) | ||
+ | </div> | ||
+ | *{{FuncArg|filename}} is the path of the '''.DLL''' file(s). | ||
− | |||
===LoadCPlugin=== | ===LoadCPlugin=== | ||
− | Loads so called AviSynth C-plugins | + | Loads so-called AviSynth ''C-plugins''. C-plugins are created in pure C (unlike ordinary Avisynth plugins which are created with MS C++), use a special ''C API'', and must be loaded with '''LoadCPlugin'''. |
− | + | <div {{BoxWidthIndent|38|1}} > | |
LoadCPlugin ("filename" [, ...]) | LoadCPlugin ("filename" [, ...]) | ||
Load_Stdcall_Plugin ("filename" [, ...]) | Load_Stdcall_Plugin ("filename" [, ...]) | ||
+ | </div> | ||
+ | *{{FuncArg|filename}} is the path of the '''.DLL''' file(s). | ||
+ | *The plugin's documentation should advise you if '''LoadCPlugin''' is needed.<br> | ||
+ | *'''Load_Stdcall_Plugin''' is merely an ''alias'' or alternate name. | ||
− | |||
===LoadVirtualDubPlugin === | ===LoadVirtualDubPlugin === | ||
− | + | Loads a plugin written for [[VirtualDub]]. These are distributed as special DLLs with the file extension '''.VDF'''. | |
− | + | <div {{BoxWidthIndent|38|1}} > | |
− | + | ||
LoadVirtualDubPlugin ("filename", "filtername", preroll) | LoadVirtualDubPlugin ("filename", "filtername", preroll) | ||
+ | </div> | ||
+ | *{{FuncArg|filename}} is the path of the '''.VDF''' file. | ||
+ | *{{FuncArg|filtername}} is the name given to the plugin function after loading in AviSynth. | ||
+ | *Some filters' output depends on previous frames; for these, {{FuncArg|preroll}} should be set to a suitable number. | ||
+ | *VirtualDub filters support only [[RGB32]]. | ||
+ | *Usage example ([http://trevlac.us/colorCorrection/ ColorTools]) – see [http://forum.doom9.org/showthread.php?t=72634 '''here'''] (doom9). | ||
+ | *See [[FAQ_using_virtualdub_plugins|FAQ using Virtualdub plugins]] for more information. | ||
− | |||
===LoadVFAPIPlugin=== | ===LoadVFAPIPlugin=== | ||
− | + | Loads [[Vfapi|VFAPI]] plugins (''eg'', [[TMPGEnc]] import plugins). | |
− | + | <div {{BoxWidthIndent|38|1}} > | |
LoadVFAPIPlugin ("filename", "filtername") | LoadVFAPIPlugin ("filename", "filtername") | ||
+ | </div> | ||
+ | *{{FuncArg|filename}} is the path of the '''.DLL''' file. | ||
+ | *{{FuncArg|filtername}} is the name given to the plugin function after loading in AviSynth. | ||
+ | *The plugin's documentation should advise you if '''LoadVFAPIPlugin''' is needed. | ||
+ | </div> | ||
+ | === Plugin Autoload and Name Precedence === | ||
+ | <div style="max-width:62em" > | ||
+ | It is possible to put all plugins and script files with [[User_defined_script_functions|user-defined functions]] or (global) [[Script_variables|variables]] in an ''autoload directory'', from which all files with the extension '''.AVSI''' and '''.DLL''' are loaded [[The_script_execution_model/Sequence_of_events|at startup]], then unloaded and reloaded dynamically as the script needs them. | ||
− | + | '''.AVSI''' scripts in this directory should only contain function definitions and global variables; they should not have a main processing section (else strange errors may occur). It also is not recommended to put other files in that directory. | |
− | + | The directory is stored in the registry. You can use double-clicking a .REG-file with the following lines to set the path (of course inserting your actual path): | |
− | + | <div {{BoxWidthIndent|38|1}} > | |
− | + | ||
− | + | ||
− | The directory is stored in the registry | + | |
− | + | ||
REGEDIT4 | REGEDIT4 | ||
[HKEY_LOCAL_MACHINE\SOFTWARE\Avisynth] | [HKEY_LOCAL_MACHINE\SOFTWARE\Avisynth] | ||
"plugindir2_5"="c:\\program files\\avisynth 2.5\\plugins" | "plugindir2_5"="c:\\program files\\avisynth 2.5\\plugins" | ||
− | + | </div> | |
The order in which function names take precedence is as follows: | The order in which function names take precedence is as follows: | ||
− | # | + | # User-defined function (always have the highest priority) |
− | # | + | # Plugin (external) function (higher priority than built-in) |
− | # | + | # Built-in (internal) function |
− | Inside those groups the function loaded | + | Inside those groups the function loaded ''last'' takes precedence; there is no error in a namespace conflict.<br> |
+ | It follows that there is no harm in loading the same plugin more than once.{{Dubious|Talk:Plugins#Loading_same_plugin_more_than_once}} | ||
+ | </div> | ||
+ | === Plugin Autoload and Conflicting Function Names === | ||
+ | <div style="max-width:62em" > | ||
+ | A problem that may arise when multiple plugins have functions with the same name. You won't know which function will be called in your script, as this will depend on loading order. To call a particular function in this situation, AviSynth's <tt>DLLName_function()</tt> feature automatically creates ''prefix aliases''; so for example, '''foo.dll''''s <tt>bar()</tt> function may be called as <tt>foo_bar()</tt>. This works both for auto-loaded plugins and for plugins loaded with [[LoadPlugin]]. | ||
− | + | Suppose you have the plugins '''mpeg2dec.dll''' and '''mpeg2dec3.dll''' in your autoload directory;<br> | |
− | + | if you want to load a '''.d2v''' file with '''mpeg2dec.dll''' (which outputs [[YUY2]]): | |
− | + | <div {{BoxWidthIndent|38|1}} > | |
− | + | # using mpeg2source from [[External_plugins_old#Source_Filters|mpeg2dec.dll]] | |
− | ''' | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | # using mpeg2source from mpeg2dec.dll | + | |
mpeg2dec_mpeg2source("F:\From_hell\from_hell.d2v") | mpeg2dec_mpeg2source("F:\From_hell\from_hell.d2v") | ||
+ | </div> | ||
+ | or with '''mpeg2dec3.dll''' (which outputs [[YV12]]): | ||
+ | <div {{BoxWidthIndent|38|1}} > | ||
+ | # using mpeg2source from [[External_plugins_old#Source_Filters|mpeg2dec3.dll]] | ||
+ | mpeg2dec3_mpeg2source("F:\From_hell\from_hell.d2v") | ||
+ | </div> | ||
+ | </div> | ||
− | |||
− | |||
− | |||
− | |||
---- | ---- |
Revision as of 19:04, 12 March 2016
With these functions you can add external filters (DLLs) to the AviSynth script environment.
Contents |
LoadPlugin
Loads one or more standard (C++) AviSynth plugins.
LoadPlugin ("filename" [, ...])
- filename is the path of the .DLL file(s).
LoadCPlugin
Loads so-called AviSynth C-plugins. C-plugins are created in pure C (unlike ordinary Avisynth plugins which are created with MS C++), use a special C API, and must be loaded with LoadCPlugin.
LoadCPlugin ("filename" [, ...]) Load_Stdcall_Plugin ("filename" [, ...])
- filename is the path of the .DLL file(s).
- The plugin's documentation should advise you if LoadCPlugin is needed.
- Load_Stdcall_Plugin is merely an alias or alternate name.
LoadVirtualDubPlugin
Loads a plugin written for VirtualDub. These are distributed as special DLLs with the file extension .VDF.
LoadVirtualDubPlugin ("filename", "filtername", preroll)
- filename is the path of the .VDF file.
- filtername is the name given to the plugin function after loading in AviSynth.
- Some filters' output depends on previous frames; for these, preroll should be set to a suitable number.
- VirtualDub filters support only RGB32.
- Usage example (ColorTools) – see here (doom9).
- See FAQ using Virtualdub plugins for more information.
LoadVFAPIPlugin
Loads VFAPI plugins (eg, TMPGEnc import plugins).
LoadVFAPIPlugin ("filename", "filtername")
- filename is the path of the .DLL file.
- filtername is the name given to the plugin function after loading in AviSynth.
- The plugin's documentation should advise you if LoadVFAPIPlugin is needed.
Plugin Autoload and Name Precedence
It is possible to put all plugins and script files with user-defined functions or (global) variables in an autoload directory, from which all files with the extension .AVSI and .DLL are loaded at startup, then unloaded and reloaded dynamically as the script needs them.
.AVSI scripts in this directory should only contain function definitions and global variables; they should not have a main processing section (else strange errors may occur). It also is not recommended to put other files in that directory.
The directory is stored in the registry. You can use double-clicking a .REG-file with the following lines to set the path (of course inserting your actual path):
REGEDIT4 [HKEY_LOCAL_MACHINE\SOFTWARE\Avisynth] "plugindir2_5"="c:\\program files\\avisynth 2.5\\plugins"
The order in which function names take precedence is as follows:
- User-defined function (always have the highest priority)
- Plugin (external) function (higher priority than built-in)
- Built-in (internal) function
Inside those groups the function loaded last takes precedence; there is no error in a namespace conflict.
It follows that there is no harm in loading the same plugin more than once.[dubious – discuss]
Plugin Autoload and Conflicting Function Names
A problem that may arise when multiple plugins have functions with the same name. You won't know which function will be called in your script, as this will depend on loading order. To call a particular function in this situation, AviSynth's DLLName_function() feature automatically creates prefix aliases; so for example, foo.dll's bar() function may be called as foo_bar(). This works both for auto-loaded plugins and for plugins loaded with LoadPlugin.
Suppose you have the plugins mpeg2dec.dll and mpeg2dec3.dll in your autoload directory;
if you want to load a .d2v file with mpeg2dec.dll (which outputs YUY2):
# using mpeg2source from mpeg2dec.dll mpeg2dec_mpeg2source("F:\From_hell\from_hell.d2v")
or with mpeg2dec3.dll (which outputs YV12):
# using mpeg2source from mpeg2dec3.dll mpeg2dec3_mpeg2source("F:\From_hell\from_hell.d2v")
Back to AviSynth Syntax.