#[repr(C)]pub struct VSSCRIPTAPI {Show 16 fields
pub getApiVersion: unsafe extern "system-unwind" fn() -> c_int,
pub getVSAPI: unsafe extern "system-unwind" fn(version: c_int) -> *const VSAPI,
pub createScript: unsafe extern "system-unwind" fn(core: *mut VSCore) -> *mut VSScript,
pub getCore: unsafe extern "system-unwind" fn(handle: *mut VSScript) -> *mut VSCore,
pub evaluateBuffer: unsafe extern "system-unwind" fn(handle: *mut VSScript, buffer: *const c_char, scriptFilename: *const c_char) -> c_int,
pub evaluateFile: unsafe extern "system-unwind" fn(handle: *mut VSScript, scriptFilename: *const c_char) -> c_int,
pub getError: unsafe extern "system-unwind" fn(handle: *mut VSScript) -> *const c_char,
pub getExitCode: unsafe extern "system-unwind" fn(handle: *mut VSScript) -> c_int,
pub getVariable: unsafe extern "system-unwind" fn(handle: *mut VSScript, name: *const c_char, dst: *mut VSMap) -> c_int,
pub setVariable: unsafe extern "system-unwind" fn(handle: *mut VSScript, vars: *const VSMap) -> c_int,
pub getOutputNode: unsafe extern "system-unwind" fn(handle: *mut VSScript, index: c_int) -> *mut VSNode,
pub getOutputAlphaNode: unsafe extern "system-unwind" fn(handle: *mut VSScript, index: c_int) -> *mut VSNode,
pub getAltOutputMode: unsafe extern "system-unwind" fn(handle: *mut VSScript, index: c_int) -> c_int,
pub freeScript: unsafe extern "system-unwind" fn(handle: *mut VSScript) -> c_int,
pub evalSetWorkingDir: unsafe extern "system-unwind" fn(handle: *mut VSScript, setCWD: c_int) -> c_void,
pub getAvailableOutputNodes: unsafe extern "system-unwind" fn(handle: *mut VSScript, size: c_int, dst: *mut c_int) -> c_int,
}
Expand description
This struct is the way to access VSScript’s public API.
Fields§
§getApiVersion: unsafe extern "system-unwind" fn() -> c_int
Returns the api version provided by vsscript.
getVSAPI: unsafe extern "system-unwind" fn(version: c_int) -> *const VSAPI
Retrieves the VSAPI
struct. Exists mostly as a convenience so
the vapoursynth module doesn’t have to be explicitly loaded.
This could return NULL
if the VapourSynth
library doesn’t
provide the requested version.
createScript: unsafe extern "system-unwind" fn(core: *mut VSCore) -> *mut VSScript
Creates an empty script environment that can be used to evaluate scripts.
Passing a pre-created core can be useful to have custom core creation flags,
log callbacks or plugins pre-loaded. Passing NULL
will automatically create
a new core with default settings.
Takes over ownership of the core regardless of success or failure.
Returns NULL
on error.
getCore: unsafe extern "system-unwind" fn(handle: *mut VSScript) -> *mut VSCore
Retrieves the VapourSynth
core that was created in the script environment.
If a VapourSynth
core has not been created yet, it will be created now,
with the default options (see the Python Reference).
VSScript
retains ownership of the returned core object.
Returns NULL
on error.
Note: The core is valid as long as the environment exists
evaluateBuffer: unsafe extern "system-unwind" fn(handle: *mut VSScript, buffer: *const c_char, scriptFilename: *const c_char) -> c_int
Evaluates a script contained in a C string. Can be called multiple times on the same script environment to successively add more processing.
§Arguments
-
handle
- Pointer to a script environment. -
buffer
- The entire script to evaluate, as a C string. -
scriptFilename
- A name for the script, which will be displayed in error messages. If this isNULL
, the name “<string>” will be used.
The special __file__
variable will be set to scriptFilename
’s absolute path
if this is not NULL
.
Returns non-zero in case of errors. The error message can be retrieved with
getError()
. If the script calls sys.exit(code)
the exit code can be retrieved with getExitCode()
.
The working directory behavior can be changed by calling
evalSetWorkingDir()
before this function.
Note: calling any function other than getError()
and
freeScript()
on a VSScript
object in the error state
will result in undefined behavior.
evaluateFile: unsafe extern "system-unwind" fn(handle: *mut VSScript, scriptFilename: *const c_char) -> c_int
Evaluates a script contained in a file. This is a convenience function which reads the script from a file for you. It will only read the first 16 MiB which should be enough for everyone.
Behaves the same as evaluateBuffer()
.
getError: unsafe extern "system-unwind" fn(handle: *mut VSScript) -> *const c_char
Returns the error message from a script environment, or NULL
, if there is no error.
It is okay to pass NULL
.
VSScript
retains ownership of the pointer and it is only guaranteed
to be valid until the next vsscript operation on the handle.
getExitCode: unsafe extern "system-unwind" fn(handle: *mut VSScript) -> c_int
Returns the exit code if the script calls sys.exit(code)
, or 0,
if the script fails for other reasons or calls sys.exit(0)
.
It is okay to pass NULL
.
getVariable: unsafe extern "system-unwind" fn(handle: *mut VSScript, name: *const c_char, dst: *mut VSMap) -> c_int
Retrieves a variable from the script environment.
If a VapourSynth
core has not been created yet in the script environment,
one will be created now, with the default options (see the Python Reference).
§Arguments
-
name
- Name of the variable to retrieve. -
dst
- Map where the variable’s value will be placed, with the key name.
Returns non-zero on error.
setVariable: unsafe extern "system-unwind" fn(handle: *mut VSScript, vars: *const VSMap) -> c_int
Sets variables in the script environment.
The variables are now available to the script.
If a VapourSynth
core has not been created yet in the script environment,
one will be created now, with the default options (see the Python Reference).
§Arguments
vars
- Map containing the variables to set.
Returns non-zero on error.
getOutputNode: unsafe extern "system-unwind" fn(handle: *mut VSScript, index: c_int) -> *mut VSNode
Retrieves a node from the script environment. A node in the script must have been
marked for output with the requested index
.
The returned node has its reference count incremented by one.
Returns NULL
if there is no node at the requested index.
getOutputAlphaNode: unsafe extern "system-unwind" fn(handle: *mut VSScript, index: c_int) -> *mut VSNode
Retrieves an alpha node from the script environment. A node with associated alpha
in the script must have been marked for output with the requested index
.
The returned node has its reference count incremented by one.
Returns NULL
if there is no alpha node at the requested index.
getAltOutputMode: unsafe extern "system-unwind" fn(handle: *mut VSScript, index: c_int) -> c_int
Retrieves the alternative output mode settings from the script. This value has no fixed meaning but in vspipe and vsvfw it indicates that alternate output formats should be used when multiple ones are available. It is up to the client application to define the exact meaning or simply disregard it completely.
Returns 0 if there is no alt output mode set.
freeScript: unsafe extern "system-unwind" fn(handle: *mut VSScript) -> c_int
Frees a script environment. handle
is no longer usable.
- Cancels any clips set for output in the script environment.
- Clears any variables set in the script environment.
- Clears the error message from the script environment, if there is one.
- Frees the
VapourSynth
core used in the script environment, if there is one. - Since this function frees the
VapourSynth
core, it must be called only after all frame requests are finished and all objects obtained from the script have been freed (frames, nodes, etc).
It is safe to pass NULL
.
evalSetWorkingDir: unsafe extern "system-unwind" fn(handle: *mut VSScript, setCWD: c_int) -> c_void
Set whether or not the working directory is temporarily changed to the same location
as the script file when evaluateFile()
is called. Off by default.
getAvailableOutputNodes: unsafe extern "system-unwind" fn(handle: *mut VSScript, size: c_int, dst: *mut c_int) -> c_int
Write a list of set output index values to dst but at most size values. Always returns the total number of available output index values.