### Install and Upload Wheels with Twine Source: https://vapoursynth.com/doc/packaging.html Install the twine utility and upload your built distribution files to PyPI. You will be prompted for your PyPI credentials. ```bash pip install twine twine upload dist/* ``` -------------------------------- ### Install VapourSynth from GitHub Source: https://vapoursynth.com/doc/_sources/installation.rst.txt Install VapourSynth directly from its GitHub repository using pip. This avoids the need to clone the repository manually. ```bash pip install git+https://github.com/vapoursynth/vapoursynth.git ``` -------------------------------- ### Install Plugin with VSRepo Source: https://vapoursynth.com/doc/installation.html Use the VSRepo script on Windows to install plugins and scripts. Replace with the target. ```bash vsrepo.py install ``` -------------------------------- ### Example: Averaging Two Clips with 10-bit Output Source: https://vapoursynth.com/doc/_sources/functions/video/lut2.rst.txt This example shows how to average two clips and output a 10-bit video using a custom function. ```APIDOC ## Example: Averaging Two Clips with 10-bit Output ### Description This example demonstrates averaging two clips with a specified 10-bit output bit depth using a custom function. ### Code ```python def f(x, y): return (x*4 + y)//2 Lut2(clipa=clipa8bit, clipb=clipb10bit, function=f, bits=10) ``` ``` -------------------------------- ### Test VapourSynth Installation Source: https://vapoursynth.com/doc/_sources/installation.rst.txt Run this Python code in a command line after installation to verify VapourSynth is working and to see its version and configuration. ```python from vapoursynth import core print(str(core)) ``` -------------------------------- ### Project Structure Example Source: https://vapoursynth.com/doc/_sources/packaging.rst.txt A typical project layout for a VapourSynth plugin using Hatchling and Meson. ```text path/to/your/project ├── src | └── MyPlugin | ├── myplugin.cpp | └── myplugin.h ├── .gitattributes ├── .gitignore ├── LICENSE ├── hatch_build.py ├── meson.build ├── pyproject.toml └── README.md ``` -------------------------------- ### Install Plugin or Script with VSRepo Source: https://vapoursynth.com/doc/_sources/installation.rst.txt Use the vsrepo.py script to install plugins and scripts on Windows. Replace with the actual name. ```bash vsrepo.py install ``` -------------------------------- ### SelectEvery Examples Source: https://vapoursynth.com/doc/_sources/functions/video/selectevery.rst.txt Examples demonstrating various use cases of the SelectEvery function, including selecting even/odd frames, decimation, and duplicating frames. ```APIDOC ## Examples Return even numbered frames, starting with 0:: SelectEvery(clip=clip, cycle=2, offsets=0) Return odd numbered frames, starting with 1:: SelectEvery(clip=clip, cycle=2, offsets=1) Fixed pattern 1 in 5 decimation, first frame in every cycle removed:: SelectEvery(clip=clip, cycle=5, offsets=[1, 2, 3, 4]) Duplicate every fourth frame:: SelectEvery(clip=clip, cycle=4, offsets=[0, 1, 2, 3, 3]) ``` -------------------------------- ### Install VapourSynth via Homebrew Source: https://vapoursynth.com/doc/_sources/installation.rst.txt Use this command to install VapourSynth on macOS using the Homebrew package manager. ```bash brew install vapoursynth ``` -------------------------------- ### register_policy Source: https://vapoursynth.com/doc/_sources/pythonreference.rst.txt Installs a custom EnvironmentPolicy. This function should be called before VapourSynth is first used and only works if no other policy is installed. ```APIDOC ## register_policy(policy) ### Description This function is intended for use by custom Script-Runners and Editors. It installs your custom :class:`EnvironmentPolicy`. This function only works if no other policy has been installed. ### Parameters #### Path Parameters - **policy** (:class:`EnvironmentPolicy`) - Required - The custom policy to register. ``` -------------------------------- ### Install VapourSynth via Nix/NixOS Source: https://vapoursynth.com/doc/_sources/installation.rst.txt Use these commands to install VapourSynth on Nix or NixOS. Note that the derivation may be broken on macOS and newer versions are typically only available on the unstable branch. ```bash nixpkgs#vapoursynth ``` ```bash nixpkgs#python3Packages.vapoursynth ``` -------------------------------- ### Build Wheel with `build` Source: https://vapoursynth.com/doc/_sources/packaging.rst.txt Installs the `build` package and then uses it to create a distribution wheel for your project. The resulting wheel will be placed in the `dist/` directory. ```bash pip install build python -m build ``` -------------------------------- ### FreezeFrames Example Source: https://vapoursynth.com/doc/_sources/functions/video/freezeframes.rst.txt This example demonstrates how to use FreezeFrames to replace multiple frame ranges with different replacement frames. Ensure that the frame ranges do not overlap. ```python core.std.FreezeFrames(input, first=[0, 100, 231], last=[15, 112, 300], replacement=[8, 50, 2]) ``` -------------------------------- ### Correct Path Specification Examples Source: https://vapoursynth.com/doc/_sources/functions/general/loadallplugins.rst.txt Shows correct ways to specify paths for the LoadAllPlugins function, including using forward slashes, raw strings, or double backslashes for Windows paths. ```python LoadPlugin(path='c:/plugins') ``` ```python LoadPlugin(path=r'c:\plugins') ``` ```python LoadPlugin(path='c:\\plugins\\') ``` -------------------------------- ### Example: Averaging Two Clips Source: https://vapoursynth.com/doc/_sources/functions/video/lut2.rst.txt This example demonstrates how to average the pixel values of two clips using the Lut2 function with a pre-defined lookup table. ```APIDOC ## Example: Averaging Two Clips ### Description This example shows how to create a lookup table to average two clips. ### Code ```python lut = [] for y in range(2 ** clipy.format.bits_per_sample): for x in range(2 ** clipx.format.bits_per_sample): lut.append((x + y)//2) Lut2(clipa=clipa, clipb=clipb, lut=lut) ``` ``` -------------------------------- ### Subsampling Calculation Example Source: https://vapoursynth.com/doc/_sources/api/vapoursynth4.h.rst.txt Demonstrates how to calculate the width of UV planes using the log2 subsampling factor. ```c uv_width = y_width >> subSamplingW; ``` -------------------------------- ### AudioMix Examples Source: https://vapoursynth.com/doc/_sources/functions/audio/audiomix.rst.txt Examples demonstrating common use cases for the AudioMix function, including downmixing stereo to mono, downmixing 5.1 audio, and copying stereo audio to a 5.1 output while zeroing unused channels. ```APIDOC ## AudioMix Examples ### Downmix stereo audio to mono ```python AudioMix(clips=clip, matrix=[0.5, 0.5], channels_out=[vs.FRONT_CENTER]) ``` ### Downmix 5.1 audio ```python AudioMix(clips=clip, matrix=[1, 0, 0.7071, 0, 0.7071, 0, 0, 1, 0.7071, 0, 0, 0.7071], channels_out=[vs.FRONT_LEFT, vs.FRONT_RIGHT]) ``` ### Copy stereo audio to 5.1 and zero the other channels ```python AudioMix(clips=c, matrix=[1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], channels_out=[vs.FRONT_LEFT, vs.FRONT_RIGHT, vs.FRONT_CENTER, vs.LOW_FREQUENCY, vs.BACK_LEFT, vs.BACK_RIGHT]) ``` ``` -------------------------------- ### Load and Gain Audio Clip Source: https://vapoursynth.com/doc/_sources/gettingstarted.rst.txt Use AudioSource to load an audio file and std.AudioGain to increase its volume. Ensure BestSource is installed and auto-loaded. ```python from vapoursynth import core clip = core.bs.AudioSource(source='filename.mkv') clip = core.std.AudioGain(clip,gain=2.0) clip.set_output() ``` -------------------------------- ### Expr Examples Source: https://vapoursynth.com/doc/functions/video/expr.html Practical examples demonstrating the usage of the Expr filter for common video processing tasks, such as averaging color planes and handling different input formats. ```APIDOC ## Expr Examples ### Averaging Y planes of 3 YUV clips (same format) This example averages the Y planes of three clips (`clipa`, `clipb`, `clipc`) and passes through the UV planes unchanged. ```python std.Expr(clips=[clipa, clipb, clipc], expr=["x y + z + 3 /", "", ""]) ``` ### Averaging Y planes of 3 YUV clips (different formats) This example averages the Y planes of three clips with different bit depths and formats, adjusting the expression accordingly. ```python std.Expr(clips=[clipa16bit, clipb10bit, clipa8bit], expr=["x y 64 * + z 256 * + 3 /", ""]) ``` ### Setting Output Format This example demonstrates setting a specific output format (`vs.YUV420P16`) when the resulting values might be illegal in the input clip's format. Note that UV planes might contain junk if direct copy isn't possible. ```python std.Expr(clips=[clipa10bit, clipb16bit, clipa8bit], expr=["x 64 * y + z 256 * + 3 /", ""], format=vs.YUV420P16) ``` ``` -------------------------------- ### Upload Wheel with `twine` Source: https://vapoursynth.com/doc/_sources/packaging.rst.txt Installs the `twine` package and uses it to upload your built distribution archives (wheels and source distributions) to PyPI. You will be prompted for your PyPI credentials. ```bash pip install twine twine upload dist/* ``` -------------------------------- ### Unsharp Mask Example with MakeFullDiff Source: https://vapoursynth.com/doc/_sources/functions/video/makefulldiff.rst.txt Demonstrates how to use MakeFullDiff to create a difference clip for sharpening. This involves blurring the clip, calculating the difference, and then merging it back. ```python blur_clip = core.std.Convolution(clip, matrix=[1, 2, 1, 2, 4, 2, 1, 2, 1]) diff_clip = core.std.MakeFullDiff(clip, blur_clip) sharpened_clip = core.std.MergeFullDiff(clip, diff_clip) ``` -------------------------------- ### core() Source: https://vapoursynth.com/doc/pythonreference.html Gets the singleton Core object. If it is the first time the function is called, the Core will be instantiated with the default options. This is the preferred way to reference the core. ```APIDOC ## core() ### Description Gets the singleton Core object. If it is the first time the function is called, the Core will be instantiated with the default options. This is the preferred way to reference the core. ### Method N/A (Function call) ### Endpoint N/A ``` -------------------------------- ### Load and Flip Video Clip Source: https://vapoursynth.com/doc/_sources/gettingstarted.rst.txt Use VideoSource to load a video file and std.FlipHorizontal to flip it horizontally. Ensure BestSource is installed and auto-loaded. ```python from vapoursynth import core clip = core.bs.VideoSource(source='filename.mkv') clip = core.std.FlipHorizontal(clip) clip.set_output() ``` -------------------------------- ### Unsharp Masking with MergeDiff Source: https://vapoursynth.com/doc/functions/video/mergediff.html This example demonstrates how to perform unsharp masking using Convolution, MakeDiff, and MergeDiff. It processes only the luma plane. ```python blur_clip = core.std.Convolution(clip, matrix=[1, 2, 1, 2, 4, 2, 1, 2, 1], planes=[0]) diff_clip = core.std.MakeDiff(clip, blur_clip, planes=[0]) sharpened_clip = core.std.MergeDiff(clip, diff_clip, planes=[0]) ``` -------------------------------- ### Get Core Information Source: https://vapoursynth.com/doc/api/vapoursynth4.h.html Retrieves information about the VapourSynth core. Use VSCoreInfo or VSCoreInfo2 as appropriate. ```c void getCoreInfo(VSCore *core, VSCoreInfo *info) ``` ```c void getCoreInfo(VSCore *core, VSCoreInfo2 *info) ``` -------------------------------- ### Load and Gain Audio Clip Source: https://vapoursynth.com/doc/gettingstarted.html This script loads an audio file using BestSource, applies a 2x gain to all channels, and sets it for output. Ensure BestSource is installed and auto-loaded. ```python from vapoursynth import core # Get an instance of the core clip = core.bs.AudioSource(source='filename.mkv') # Load an audio track in mkv file clip = core.std.AudioGain(clip,gain=2.0) # Gain all channels 2x clip.set_output() # Set the audio clip to be accessible for output ``` -------------------------------- ### Initialize Local Class Source: https://vapoursynth.com/doc/_sources/pythonreference.rst.txt Use the Local class to store variables that depend on the currently active core. This example shows basic initialization and assignment. ```python l = Local() l.test = 1 ``` -------------------------------- ### Instantiate and Access Core Object Source: https://vapoursynth.com/doc/pythonreference.html Use the `core` attribute to get the singleton Core object. This is the preferred method for referencing the core, which will be instantiated with default options on its first call. ```python from vapoursynth import core # Access the core object print(core.api_version) ``` -------------------------------- ### Swap Left and Right Audio Channels (Stereo) Source: https://vapoursynth.com/doc/_sources/functions/audio/shufflechannels.rst.txt Swap the left and right audio channels in a stereo clip. This example demonstrates one ordering of input and output channels. ```python ShuffleChannels(clips=clip, channels_in=[vs.FRONT_RIGHT, vs.FRONT_LEFT], channels_out=[vs.FRONT_LEFT, vs.FRONT_RIGHT]) ``` -------------------------------- ### Example: Removing a Property Source: https://vapoursynth.com/doc/_sources/functions/video/modifyframe.rst.txt This example shows how to remove a property, specifically 'FrameNumber', from a frame using ModifyFrame. ```APIDOC ## Example: Removing a Property ### Description How to remove a property. ### Code ```python def remove_property(n, f): fout = f.copy() del fout.props['FrameNumber'] return fout ... ModifyFrame(clip=clip, clips=clip, selector=remove_property) ``` ``` -------------------------------- ### register_policy Source: https://vapoursynth.com/doc/pythonreference.html Installs a custom EnvironmentPolicy. This function is intended for use by custom Script-Runners and Editors and only works if no other policy is installed. ```APIDOC ## register_policy(_policy_) ### Description This function is intended for use by custom Script-Runners and Editors. It installs your custom `EnvironmentPolicy`. This function only works if no other policy has been installed. If no policy is installed, the first environment-sensitive call will automatically register an internal policy. ### Parameters * **_policy_**: The custom `EnvironmentPolicy` to install. ``` -------------------------------- ### Meson Build Setup and Compile Source: https://vapoursynth.com/doc/_sources/packaging.rst.txt This Python snippet demonstrates setting up a Meson build environment with Visual Studio integration on Windows and then compiling the project. It's part of a larger build process for Python packages that include compiled extensions. ```python build_data["tag"] = f"py3-none-{next(tags.platform_tags())}" subprocess.run([sys.executable, "-m", "mesonbuild.mesonmain", "setup", "build", "--vsenv"], check=True) subprocess.run([sys.executable, "-m", "mesonbuild.mesonmain", "compile", "-C", "build"], check=True) ``` -------------------------------- ### Build VapourSynth Documentation Source: https://vapoursynth.com/doc/installation.html Build the HTML documentation for VapourSynth using its Makefile. Navigate to the doc/ directory first. ```bash $ make -C doc/ html ``` -------------------------------- ### Build HTML Documentation Source: https://vapoursynth.com/doc/_sources/installation.rst.txt Build the HTML documentation for VapourSynth. This command should be run from the VapourSynth source directory. ```bash make -C doc/ html ``` -------------------------------- ### Example: Transferring Properties Between Clips Source: https://vapoursynth.com/doc/_sources/functions/video/modifyframe.rst.txt This example illustrates how to copy specific properties from one clip to another within the ModifyFrame function. ```APIDOC ## Example: Transferring Properties Between Clips ### Description An example of how to copy certain properties from one clip to another (clip1 and clip2 have the same format). ### Code ```python def transfer_property(n, f): fout = f[1].copy() fout.props['FrameNumber'] = f[0].props['FrameNumber'] fout.props['_Combed'] = f[0].props['_Combed'] return fout ... ModifyFrame(clip=clip1, clips=[clip1, clip2], selector=transfer_property) ``` ``` -------------------------------- ### Example: Setting FrameNumber Property Source: https://vapoursynth.com/doc/_sources/functions/video/modifyframe.rst.txt This example demonstrates how to use ModifyFrame to set the 'FrameNumber' property of a frame to the current frame number. ```APIDOC ## Example: Setting FrameNumber Property ### Description How to set the property FrameNumber to the current frame number. ### Code ```python def set_frame_number(n, f): fout = f.copy() fout.props['FrameNumber'] = n return fout ... ModifyFrame(clip=clip, clips=clip, selector=set_frame_number) ``` ``` -------------------------------- ### List Available Plugins and Scripts with VSRepo Source: https://vapoursynth.com/doc/_sources/installation.rst.txt Use the vsrepo.py script to list all available plugins and scripts. This is useful for discovering available packages. ```bash vsrepo.py available ``` -------------------------------- ### VSInitPlugin Source: https://vapoursynth.com/doc/_sources/api/vapoursynth4.h.rst.txt The plugin's entry point, called VapourSynthPluginInit2. It's responsible for configuring the plugin and registering its filters. ```APIDOC ## VSInitPlugin ### Description A plugin's entry point. It must be called ``VapourSynthPluginInit2``. This function is called after the core loads the shared library. Its purpose is to configure the plugin and to register the filters the plugin wants to export. ### Parameters #### Parameters - **plugin** (VSPlugin_ *) - Pointer to the plugin object to be initialized. - **vspapi** (const VSPLUGINAPI_ *) - Pointer to a VSPLUGINAPI_ struct with a subset of the VapourSynth API used for initializing plugins. ### Usage The proper way to do things is to call configPlugin_ and then registerFunction_ for each function to export. ``` -------------------------------- ### List Available Plugins with VSRepo Source: https://vapoursynth.com/doc/installation.html Use VSRepo to list all available plugins and scripts. This command is useful for discovering available packages. ```bash vsrepo.py available ``` -------------------------------- ### Set Frame Property Example Source: https://vapoursynth.com/doc/_sources/functions/video/setframeprop.rst.txt This example demonstrates how to set the '_FieldBased' property to 'top field first' (value 2) for all frames in a clip. ```python clip = c.std.SetFrameProp(clip, prop="_FieldBased", intval=2) ``` -------------------------------- ### void getCoreInfo(VSCore *core, VSCoreInfo *info) Source: https://vapoursynth.com/doc/api/vapoursynth4.h.html Retrieves information about the VapourSynth core and populates the provided VSCoreInfo structure. ```APIDOC ## void getCoreInfo(VSCore *core, VSCoreInfo *info) ### Description Returns information about the VapourSynth core. ### Parameters #### Path Parameters - **core** (VSCore *) - Required - Pointer to the VapourSynth core. - **info** (VSCoreInfo *) - Required - Pointer to the VSCoreInfo structure to be populated. ``` -------------------------------- ### SetFieldBased Example Source: https://vapoursynth.com/doc/_sources/functions/video/setfieldbased.rst.txt Use SetFieldBased to treat progressive video encoded as interlaced as frame-based for improved resizing quality. This example sets the clip to be frame-based (value 0) before resizing. ```python clip = core.bs.VideoSource("rule6.mkv") clip = core.std.SetFieldBased(clip, 0) clip = clip.resize.Bilinear(clip, width=320, height=240) ``` -------------------------------- ### void getCoreInfo(VSCore *core, VSCoreInfo2 *info) Source: https://vapoursynth.com/doc/api/vapoursynth4.h.html Retrieves extended information about the VapourSynth core and populates the provided VSCoreInfo2 structure. ```APIDOC ## void getCoreInfo(VSCore *core, VSCoreInfo2 *info) ### Description Returns information about the VapourSynth core. ### Parameters #### Path Parameters - **core** (VSCore *) - Required - Pointer to the VapourSynth core. - **info** (VSCoreInfo2 *) - Required - Pointer to the VSCoreInfo2 structure to be populated. ``` -------------------------------- ### Write a specific frame range to a raw file Source: https://vapoursynth.com/doc/_sources/output.rst.txt Specify the start and end frames for output using --start and --end options, saving the result to a raw video file. ```bash vspipe --start 5 --end 100 script.vpy output.raw ``` -------------------------------- ### getPluginFunctionByName Source: https://vapoursynth.com/doc/api/vapoursynth4.h.html Get a function belonging to a plugin by its name. ```APIDOC ## getPluginFunctionByName ### Description Get a function belonging to a plugin by its name. ### Parameters - **name** (const char *) - The name of the function. - **plugin** (VSPlugin *) - A pointer to the plugin. ### Returns - (VSPluginFunction *) - A pointer to the VSPluginFunction, or NULL if not found. ``` -------------------------------- ### VSLogHandle *addLogHandler(VSLogHandler handler, VSLogHandlerFree free, void *userData, VSCore *core) Source: https://vapoursynth.com/doc/api/vapoursynth4.h.html Installs a custom handler for VapourSynth messages. This handler is specific to a VSCore instance and returns a unique handle. If no handler is installed, messages may be cached and delivered later. ```APIDOC ## VSLogHandle *addLogHandler(VSLogHandler handler, VSLogHandlerFree free, void *userData, VSCore *core) ### Description Installs a custom handler for the various error messages VapourSynth emits. The message handler is per VSCore instance. Returns a unique handle. If no log handler is installed up to a few hundred messages are cached and will be delivered as soon as a log handler is attached. This behavior exists mostly so that warnings when auto-loading plugins (default behavior) won’t disappear- ### Parameters #### Path Parameters - **handler** (VSLogHandler) - Required - Custom message handler function pointer. If NULL, the default handler is restored. - **free** (VSLogHandlerFree) - Required - Function pointer called when the handler is removed. - **userData** (void *) - Required - Pointer passed to the message handler. - **core** (VSCore *) - Required - Pointer to the VapourSynth core. ``` -------------------------------- ### Create VapourSynth Core Source: https://vapoursynth.com/doc/api/vapoursynth4.h.html Creates a VapourSynth processing core. Use 0 for default flags. Multiple cores can be created but are rarely needed. ```c VSCore *createCore(int flags) ``` -------------------------------- ### Get API Version Source: https://vapoursynth.com/doc/api/vapoursynth4.h.html Returns the highest VAPOURSYNTH_API_VERSION supported by the library. ```c int getAPIVersion() ``` -------------------------------- ### Frame Dimensions and Length Source: https://vapoursynth.com/doc/_sources/api/vapoursynth4.h.rst.txt Functions for getting the width, height, and length of frames. ```APIDOC ## getFrameWidth ### Description Returns the width of a *plane* of a given video frame, in pixels. The width depends on the plane number because of the possible chroma subsampling. ### Parameters * **f** (const VSFrame_ *) * **plane** (int) ### Returns The width of the plane in pixels. Returns 0 for audio frames. ``` ```APIDOC ## getFrameHeight ### Description Returns the height of a *plane* of a given video frame, in pixels. The height depends on the plane number because of the possible chroma subsampling. ### Parameters * **f** (const VSFrame_ *) * **plane** (int) ### Returns The height of the plane in pixels. Returns 0 for audio frames. ``` ```APIDOC ## getFrameLength ### Description Returns the number of audio samples in a frame. ### Parameters * **f** (const VSFrame_ *) ### Returns The number of audio samples. Always returns 1 for video frames. ``` -------------------------------- ### Plugin Initialization Functions Source: https://vapoursynth.com/doc/api/vapoursynth4.h.html Functions for initializing and managing VapourSynth plugins. ```APIDOC ## Plugin Initialization Functions ### VSInitPlugin This function is used to initialize a VapourSynth plugin. ### VSFilterGetFrame This function is called by VapourSynth to get a frame from a filter. ### VSFilterFree This function is called by VapourSynth to free resources associated with a filter. ``` -------------------------------- ### has_policy Source: https://vapoursynth.com/doc/_sources/pythonreference.rst.txt This function is intended for subclassing by custom Script-Runners and Editors. This function checks if a :class:`EnvironmentPolicy` has been installed. ```APIDOC ## has_policy() ### Description This function is intended for subclassing by custom Script-Runners and Editors. This function checks if a :class:`EnvironmentPolicy` has been installed. Added: R50 ``` -------------------------------- ### Activate Virtual Environment (Windows) Source: https://vapoursynth.com/doc/packaging.html Activate the created virtual environment on Windows systems. ```bash .venv\Scripts\activate ``` -------------------------------- ### Activate Virtual Environment (Linux/macOS) Source: https://vapoursynth.com/doc/packaging.html Activate the created virtual environment on Linux or macOS systems. ```bash source .venv/bin/activate ``` -------------------------------- ### EnvironmentData Class Source: https://vapoursynth.com/doc/_sources/pythonreference.rst.txt Internal class that stores the context sensitive data that VapourSynth needs. It is an opaque object whose attributes you cannot access directly. A normal user has no way of getting an instance of this object. You can only encounter EnvironmentData-objects if you work with EnvironmentPolicies. This object is weak-referenciable meaning you can get a callback if the environment-data object is actually being freed (i.e. no other object holds an instance to the environment data.) ```APIDOC ## EnvironmentData ### Description Internal class that stores the context sensitive data that VapourSynth needs. It is an opaque object whose attributes you cannot access directly. A normal user has no way of getting an instance of this object. You can only encounter EnvironmentData-objects if you work with EnvironmentPolicies. This object is weak-referenciable meaning you can get a callback if the environment-data object is actually being freed (i.e. no other object holds an instance to the environment data.) Added: R50 ``` -------------------------------- ### Core Methods Source: https://vapoursynth.com/doc/genindex.html Methods for interacting with the VapourSynth core. ```APIDOC ## Core Methods ### get_video_format() Retrieves the video format information. ### log_message() Logs a message through the core. ### plugins() Returns a list of loaded plugins. ### query_video_format() Queries for a specific video format. ### remove_log_handler() Removes a log handler. ### rule6() Applies rule 6 processing. ``` -------------------------------- ### Get Current Environment ID Source: https://vapoursynth.com/doc/pythonreference.html Retrieve the ID of the current vsscript-Environment. Returns -1 if not running within an environment. ```python env_id ``` -------------------------------- ### LoadAllPlugins Source: https://vapoursynth.com/doc/_sources/functions/general/loadallplugins.rst.txt Loads all native VapourSynth plugins found in the specified path. Plugins that fail to load are silently skipped. ```APIDOC ## LoadAllPlugins ### Description Loads all native VapourSynth plugins found in the specified *path*. Plugins that fail to load are silently skipped. ### Function Signature `LoadAllPlugins(string path)` ### Parameters #### Path Parameters - **path** (string) - Required - The directory path to search for plugins. ``` -------------------------------- ### SetFrameProps: Set Field Order Source: https://vapoursynth.com/doc/_sources/functions/video/setframeprops.rst.txt Example of setting the field order property to top field first using SetFrameProps. ```python clip = c.std.SetFrameProps(clip, _FieldBased=2) ``` -------------------------------- ### Get Current VapourSynth Environment Source: https://vapoursynth.com/doc/pythonreference.html Retrieves the current VapourSynth environment instance. This is useful for introspecting or managing active environments. ```python env = get_current_environment() ``` -------------------------------- ### getCore Source: https://vapoursynth.com/doc/_sources/api/vsscript4.h.rst.txt Retrieves the VapourSynth core associated with a script environment. If not yet created, it will be initialized with default settings. ```APIDOC ## getCore ### Description 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 :doc:`../pythonreference`). VSScript retains ownership of the returned core object. Returns NULL on error. ### Method `VSCore *getCore(VSScript *handle)` ``` -------------------------------- ### Get Frame Asynchronously Source: https://vapoursynth.com/doc/_sources/pythonreference.rst.txt Returns a Future-object that will resolve to a VideoFrame. This allows for concurrent frame rendering and handling potential exceptions. ```python clip.get_frame_async(n) ``` -------------------------------- ### Expr Usage Examples Source: https://vapoursynth.com/doc/_sources/functions/video/expr.rst.txt Demonstrates practical applications of the Expr function, including averaging planes and handling different input formats. ```APIDOC ## Expr Examples ### Averaging Y planes of 3 YUV clips (same format) ```python std.Expr(clips=[clipa, clipb, clipc], expr=["x y + z + 3 /", "", ""]) ``` ### Averaging Y planes of 3 YUV clips (different formats) ```python std.Expr(clips=[clipa16bit, clipb10bit, clipa8bit], expr=["x y 64 * + z 256 * + 3 /", ""]) ``` ### Setting output format for incompatible values ```python std.Expr(clips=[clipa10bit, clipb16bit, clipa8bit], expr=["x 64 * y + z 256 * + 3 /", ""], format=vs.YUV420P16) ``` ``` -------------------------------- ### Create New Audio Frame Source: https://vapoursynth.com/doc/_sources/api/vapoursynth4.h.rst.txt Creates a new uninitialized audio frame with a specified format and number of samples. Properties can optionally be copied from another frame. Passing invalid arguments is a fatal error. ```c VSFrame_ *newAudioFrame(const VSAudioFormat *format, int numSamples, const VSFrame *propSrc, VSCore *core) ``` -------------------------------- ### Get Frame from VideoNode Source: https://vapoursynth.com/doc/_sources/pythonreference.rst.txt Retrieves a specific VideoFrame from a VideoNode at a given position. Ensure the VideoNode is valid and the frame index exists. ```python clip.get_frame(n) ``` -------------------------------- ### Core Class Source: https://vapoursynth.com/doc/pythonreference.html The Core class uses a singleton pattern. Use the _core_ attribute to obtain an instance. All loaded plugins are exposed as attributes of the core object. These attributes in turn hold the functions contained in the plugin. Use _plugins()_ to obtain a full list of all currently loaded plugins you may call this way. ```APIDOC ## class Core ### Description The _Core_ class uses a singleton pattern. Use the _core_ attribute to obtain an instance. All loaded plugins are exposed as attributes of the core object. These attributes in turn hold the functions contained in the plugin. Use _plugins()_ to obtain a full list of all currently loaded plugins you may call this way. ### Attributes - **num_threads** (int) - The number of concurrent threads used by the core. Can be set to change the number. Setting to a value less than one makes it default to the number of hardware threads. - **max_cache_size** (int) - Set the upper framebuffer cache size after which memory is aggressively freed. The value is in megabytes. - **used_cache_size** (int) - The size of the core’s current cache. The value is in bytes. - **core_version** (VapourSynthVersion) - Returns the core version as VapourSynthVersion tuple. - **api_version** (VapourSynthAPIVersion) - Returns the api version as VapourSynthAPIVersion tuple. ### Methods - **clear_cache()**: Frees all memory used by internal caches. Useful when suspending or switching between multiple core instances. - **plugins()**: Containing all loaded plugins. - **get_video_format(_id_)**: Retrieve a Format object corresponding to the specified id. Returns None if the _id_ is invalid. - **query_video_format(_color_family_ , _sample_type_ , _bits_per_sample_ , _subsampling_w_ , _subsampling_h_)**: Retrieve a Format object corresponding to the format information, Invalid formats throw an exception. - **create_video_frame(_format_ , _width_ , _height_)**: Creates a new frame with uninitialized planes with the given dimensions and format. This function is safe to call within a frame callback. - **add_log_handler(_handler_func_)**: Installs a custom handler for the various error messages VapourSynth emits. The message handler is currently global, i.e. per process, not per VSCore instance. Returns a LogHandle object. _handler_func_ is a callback function of the form _func(MessageType, message)_. - **remove_log_handler(_handle_)**: Removes a custom handler. - **log_message(_message_type_ , _message_)**: Send a message through VapourSynth’s logging framework. - **rule6()**: Illegal behavior detection. ``` -------------------------------- ### get_include() Source: https://vapoursynth.com/doc/pythonreference.html Returns the full path to the VapourSynth headers. ```APIDOC ## get_include() ### Description Returns the full path to the VapourSynth headers. ### Method N/A (Function call) ### Endpoint N/A ``` -------------------------------- ### CoreInfo Source: https://vapoursynth.com/doc/_sources/functions/video/text/coreinfo.rst.txt Prints information about the VapourSynth core, such as version and memory use. If no *clip* is supplied, a default blank one is used. This is a convenience function for *Text*. ```APIDOC ## CoreInfo ### Description Prints information about the VapourSynth core, such as version and memory use. If no *clip* is supplied, a default blank one is used. This is a convenience function for *Text*. ### Function Signature `CoreInfo([vnode clip=std.BlankClip(), int alignment=7, int scale=1])` ### Parameters #### Path Parameters - **clip** (vnode) - Optional - The clip to use. Defaults to `std.BlankClip()`. - **alignment** (int) - Optional - Alignment setting. Defaults to 7. - **scale** (int) - Optional - Scale setting. Defaults to 1. ``` -------------------------------- ### Argument Declaration Example 2 Source: https://vapoursynth.com/doc/api/vapoursynth4.h.html Declares 'blah' as a vnode and accepts all remaining arguments of any type. This format is used for the 'args' parameter in registerFunction. ```text blah:vnode;any ``` -------------------------------- ### Swap U and V Planes in YUV Source: https://vapoursynth.com/doc/_sources/functions/video/shuffleplanes.rst.txt This example demonstrates how to swap the U and V planes in a YUV clip by rearranging the plane indices. ```python ShufflePlanes(clips=clip, planes=[0, 2, 1], colorfamily=vs.YUV) ``` -------------------------------- ### pyproject.toml Configuration Source: https://vapoursynth.com/doc/_sources/packaging.rst.txt Defines build system requirements, project metadata, and Hatchling build targets for a VapourSynth plugin wheel. ```toml [build-system] requires = ["hatchling", "packaging", "meson"] build-backend = "hatchling.build" [project] name = "MyPlugin" version = "1.0" description = "MyPlugin description" requires-python = ">=3.12" readme = "README.md" license = "MIT" license-files = ["LICENSE"] authors = [{ name = "Name", email = "name@email.com" }] maintainers = [{ name = "YourName", email = "name@email.com" }] dependencies = ["vapoursynth>=74"] [tool.hatch.build.targets.wheel] include = ["vapoursynth/plugins"] artifacts = [ "vapoursynth/plugins/*.dylib", "vapoursynth/plugins/*.so", "vapoursynth/plugins/*.dll", ] [tool.hatch.build.targets.wheel.hooks.custom] path = "hatch_build.py" ``` -------------------------------- ### Set output format for incompatible results Source: https://vapoursynth.com/doc/functions/video/expr.html This example sets a specific output format (vs.YUV420P16) because the resulting values from the expression are illegal in the input 10-bit clip. The UV planes will contain junk as a direct copy is not possible with the specified output format. ```python std.Expr(clips=[clipa10bit,clipb16bit,clipa8bit], expr=["x 64 * y + z 256 * + 3 /", ""], format=vs.YUV420P16) ``` -------------------------------- ### Remove Frame Property Source: https://vapoursynth.com/doc/_sources/functions/video/modifyframe.rst.txt This example demonstrates how to remove a specific property, such as 'FrameNumber', from a frame. The frame must be copied before attempting to delete properties. ```python def remove_property(n, f): fout = f.copy() del fout.props['FrameNumber'] return fout ```