User API¶
The user-facing API is used primarily within VapourSynth scripts to register nodes for preview.
Functions:¶
set_output
¶
set_output(
node: VideoNode,
index: int = ...,
/,
*,
alpha: VideoNode | Literal[True] | None = ...,
framedurs: Sequence[SupportsFloat] | None = None,
hdr: bool | None = None,
**kwargs: Any,
) -> None
set_output(
node: VideoNode,
name: str | bool | None = ...,
/,
*,
alpha: VideoNode | Literal[True] | None = ...,
framedurs: Sequence[SupportsFloat] | None = None,
hdr: bool | None = None,
**kwargs: Any,
) -> None
set_output(
node: VideoNode,
index: int = ...,
name: str | bool | None = ...,
/,
alpha: VideoNode | Literal[True] | None = ...,
*,
framedurs: Sequence[SupportsFloat] | None = None,
hdr: bool | None = None,
**kwargs: Any,
) -> None
set_output(
node: AudioNode, index: int = ..., /, *, downmix: bool | None = None, **kwargs: Any
) -> None
set_output(
node: AudioNode,
name: str | bool | None = ...,
/,
*,
downmix: bool | None = None,
**kwargs: Any,
) -> None
set_output(
node: AudioNode,
index: int = ...,
name: str | bool | None = ...,
/,
*,
downmix: bool | None = None,
**kwargs: Any,
) -> None
set_output(
node: VideoNodeIterable | AudioNodeIterable | RawNodeIterable,
index: int | Sequence[int] = ...,
/,
**kwargs: Any,
) -> None
Register one or more VapourSynth nodes as outputs for preview.
This function sets the output(s) and registers metadata for tab naming in vsview. If no index is provided, outputs are assigned to the next available indices.
Examples:
set_output(clip) # Auto-index, auto-name ("clip")
set_output(clip, 0) # Index 0, auto-name
set_output(clip, 0, "My Clip") # Index 0, explicit name
set_output(clip, "Source") # Auto-index, explicit name
set_output([clip1, clip2]) # Multiple outputs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
OutputNode
|
A VideoNode, AudioNode, or iterable of nodes to output. |
required |
index_or_name
|
int | Sequence[int] | str | bool | None
|
Either:
|
None
|
name
|
str | bool | None
|
Explicit name override. If provided when index_or_name is an int, this sets the display name for the output. |
None
|
alpha
|
VideoNode | Literal[True] | None
|
Optional alpha channel VideoNode or if True, fetch the |
None
|
framedurs
|
Sequence[SupportsFloat] | None
|
Optional sequence of frame durations in seconds for VFR clips (only for VideoNode outputs). |
None
|
hdr
|
bool | None
|
Optional boolean override for the HDR detection for VideoNode outputs.
If passing |
None
|
downmix
|
bool | None
|
if None (default), follows the global settings downmix of vsview if previewed through vsview. Otherwise True or False forces the behavior. |
None
|
**kwargs
|
Any
|
Additional metadata for custom configuration of this output. |
{}
|
Source code in src/vsview/api/output.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
catch_output
¶
catch_output[**P, N: OutputNode](
*,
index: int | Sequence[int] = ...,
name: str | bool | None = ...,
alpha: VideoNode | Literal[True] | None = ...,
framedurs: Sequence[SupportsFloat] | None = ...,
hdr: bool | None = ...,
downmix: bool | None = ...,
**kwargs: Any,
) -> Callable[[Callable[P, N]], Callable[P, N]]
Decorator variant of set_output().
Calls the decorated function and registers its return value as an output.
Examples:
@catch_output
def source() -> vs.VideNode:
return vs.core.bs.BestSource("video.mkv")
@catch_output(name="Filtered", alpha=True)
def filtered() -> vs.VideNode:
src = vs.core.bs.BestSource("image.png")
return src.std.BoxBlur()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[P, N] | None
|
The function to decorate (populated automatically when used as a bare decorator). |
None
|
index
|
int | Sequence[int] | None
|
An int or sequence of ints specifying output indices |
None
|
name
|
str | bool | None
|
Explicit name override. If not provided, the function name is used. |
None
|
alpha
|
VideoNode | Literal[True] | None
|
Optional alpha channel VideoNode or if True, fetch the |
None
|
framedurs
|
Sequence[SupportsFloat] | None
|
Optional sequence of frame durations in seconds for VFR clips (only for VideoNode outputs). |
None
|
hdr
|
bool | None
|
Optional boolean override for the HDR detection for VideoNode outputs. |
None
|
downmix
|
bool | None
|
If None (default), follows the global settings downmix of vsview if previewed through vsview. Otherwise True or False forces the behavior. |
None
|
**kwargs
|
Any
|
Additional metadata passed to VSView plugins for custom configuration of this output. |
{}
|
Returns:
| Type | Description |
|---|---|
Callable[P, N] | Callable[[Callable[P, N]], Callable[P, N]]
|
The decorated function (its original return type is preserved). |
Source code in src/vsview/api/output.py
get_reload_count
¶
get_reload_count() -> int | None
Return how many times the current script has been reloaded in VSView (0 if initial load or None outside preview).
get_state
¶
get_state() -> MutableMapping[Any, Any] | None
Return the persistent state dictionary shared across script reloads, or None if outside VSView.
Note
Objects stored in this dictionary survive script reloads within the same workspace.
- DO NOT store VapourSynth clips, frames, or script closures capturing 'globals()'.
- DO store heavy external resources (e.g. PyTorch models, ONNX sessions, lookup tables).
Source code in src/vsview/api/info.py
get_cached
¶
Get a cached value from the persistent state, or compute and cache it if not present.
If running outside VSView, the loader is called directly without caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to look up or store in the persistent state. |
required |
loader
|
Callable[P, R]
|
A callable to produce the value if key is not found. |
required |
*args
|
P.args
|
Positional arguments forwarded to loader. |
()
|
**kwargs
|
P.kwargs
|
Keyword arguments forwarded to loader. |
{}
|
Returns:
| Type | Description |
|---|---|
R
|
The cached or newly computed value. |
Source code in src/vsview/api/info.py
register_on_workspace_destroy
¶
register_on_workspace_destroy[**P, R](
cb: Callable[P, R], *args: P.args, **kwargs: P.kwargs
) -> Callable[P, R]
Register a callback to run once when the workspace closes (ignored on reload).
Use for resources persisting across reloads (e.g., via get_cached).
Duplicate registrations with identical arguments are ignored, when all arguments can be hashed.
Note
Functions defined inside the script create new objects on each reload
and will execute with cleared globals at close.
Use register_on_unload for per-run resources instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cb
|
Callable[P, R]
|
Callable to invoke on workspace close. |
required |
*args
|
P.args
|
Positional arguments forwarded to |
()
|
**kwargs
|
P.kwargs
|
Keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
Callable[P, R]
|
The registered callback (allows use as a decorator). |
Source code in src/vsview/api/info.py
register_on_unload
¶
register_on_unload[**P, R](
cb: Callable[P, R], *args: P.args, **kwargs: P.kwargs
) -> Callable[P, R]
Register a one-time callback to run when the current script run is released (before the next reload or on workspace close).
Use for resources created fresh on each run. The callback is removed after execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cb
|
Callable[P, R]
|
Callable to invoke on release. |
required |
*args
|
P.args
|
Positional arguments forwarded to |
()
|
**kwargs
|
P.kwargs
|
Keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
Callable[P, R]
|
The registered callback (allows use as a decorator). |