2 months ago
24 kB
[size=5][center]───◈ [b][color=#6E82B8]V[/color][color=#7286B9]a[/color][color=#778BBB]p[/color][color=#7C8FBD]o[/color][color=#8194BF]u[/color][color=#8699C1]r[/color][color=#8B9DC3]s[/color][color=#90A2C5]y[/color][color=#95A7C7]n[/color][color=#9AABC9]t[/color][color=#9FB0CB]h[/color] [color=#A9B9CF]B[/color][color=#AEBED1]a[/color][color=#B3C3D3]s[/color][color=#B8C7D5]i[/color][color=#BDCCD7]c[/color][/center][center][color=#C6D5DB]E[/color][color=#C0D0D8]n[/color][color=#BBCBD6]v[/color][color=#B6C6D4]i[/color][color=#B1C1D2]r[/color][color=#ACBCD0]o[/color][color=#A6B7CE]n[/color][color=#A1B2CC]m[/color][color=#9CADCA]e[/color][color=#97A9C8]n[/color][color=#92A4C6]t[/color] [color=#879AC2]S[/color][color=#8295C0]e[/color][color=#7D90BE]t[/color][color=#788BBC]u[/color][color=#7386BA]p[/color][/b] ◈───[/center]   [/size]


Vapoursynth is a filter library for video processing designed to provide a flexible and powerful way to manipulate video . In other words, it's a video manipulation system which is widely used for improving video quality by applying "Filter Plugins & Scripts". It uses Python Scripting to process a filter function .There are countless types of filtering which you can use accordingly to improve your video.  Such as : [url=https://slow.pics/c/CiekpbLe]Rescaling[/url], [url=https://slow.pics/c/0kTkzdlO]AntiAliasing[/url], [url=https://slow.pics/c/hIz8oPmC]Denoising[/url], [url=https://slow.pics/c/bOzs1nGp]Debanding[/url], [url=https://slow.pics/c/YZ6PS8R2]Dehaloing[/url], [url=https://slow.pics/c/BqVyIRWn]Masking[/url]  etc.

[color=#4da3b6][b]Who is this guide for?[/b][/color]
[color=#ffe563][b]⟹[/b][/color] An encoder who wants to setup the necessary tools to have a flexible encoding experience, which will also provide an opportunity to improve a video source before encoding .

[color=#4da3b6][b]This guide will include : [/b][/color]
[color=#ffe563][b]✔[/b][/color] Software, plugins & scripts installation.
[color=#ffe563][b]✔[/b][/color] How to preview VapourSynth scripts in Visual Studio Code.
[color=#ffe563][b]✔[/b][/color] How to output your video script using x264 or x265.
[color=#ffe563][b]✔[/b][/color] General troubleshooting + Some common queries

[b]Lets start. If you need help related to this guide then please comment below.[/b]

[center][size=5]◈ [b][color=#C0C0C0]I[/color][color=#BABBBD]n[/color][color=#B5B7BB]s[/color][color=#B0B3B8]t[/color][color=#ABAFB6]r[/color][color=#A5ABB3]u[/color][color=#A0A7B1]c[/color][color=#9BA3AE]t[/color][color=#969FAC]i[/color][color=#909BA9]o[/color][color=#8B97A7]n[/color][color=#8693A4]s[/color][/b] ◈[/size][/center]
[color=#4da3b6][b]1) Python Installation :[/b][/color] 
[spoiler][color=#ffe563][b]1 )[/b][/color] [url=https://www.python.org/downloads/release/python-3112/]Download[/url] Python 3.11.2 windows installer (64bit) file and [b][color=#C4F3FF]run it as Admin.[/color][/b]

[color=#ffe563][b]2 )[/b][/color] Select [b][color=#C4F3FF]"Add python.exe to PATH"[/color][/b] -> Click on [b][color=#C4F3FF]"Customize Installation"[/color][/b]


[color=#ffe563][b]3 )[/b][/color] Make sure [b][color=#C4F3FF]"pip"[/color][/b] is already checked and click on [b][color=#C4F3FF]Next[/color][/b].


[color=#ffe563][b]4 )[/b][/color] Select [b][color=#C4F3FF]"Install for all users"[/color][/b] and press Install.


Now, Your Python is ready so we will be able to Install VapourSynth.

[color=#ffe563][b]5 )[/b][/color] Before doing that lets [b][color=#C4F3FF]install Git[/color][/b] , which we will need in section 3 & 4.
[url=https://git-scm.com/download/win]Download[/url] git setup installer and [b][color=#C4F3FF]"Run it as admin"[/color][/b] . In our case, it's not necessary to make any changes in the installer. So keep clicking Next until it's finished installing .

Lets Now move to VapourSynth .


2) Vapoursynth Installation :
[/b][/color] [spoiler][color=#ffe563][b]1 )[/b][/color] [url=https://github.com/vapoursynth/vapoursynth/releases/tag/R62]Download[/url] VapourSynth64-R62.exe  and [b][color=#C4F3FF]"run it as Admin"[/color][/b]. 

[color=#ffe563][b]2 )[/b][/color] Select [b][color=#C4F3FF]"Install for all users"[/color][/b] . After that click Next.

[color=#ffe563][b]3 )[/b][/color] Necessary options should already be Ticked by default . So keep Pressing [b][color=#C4F3FF]Next[/color][/b] and it will get installed properly .
[b][color=#C4F3FF]Now, VapourSynth is installed in your system with its core plugins and functions. Lets install our Previewer so we can test it visually.[/color][/b]
3) Previewer Setup in Visual Studio Code :[/b][/color] [spoiler]
[color=#ffe563][b]1 )[/b][/color] Go to the VS Code [url=https://code.visualstudio.com/download]Download[/url] page. Select and download [b][color=#C4F3FF]System Installer x64.[/color][/b]


[color=#ffe563][b]2 )[/b][/color] After it's been downloaded [b][color=#C4F3FF]"run it as Admin"[/color][/b] and install it . While installing [b][color=#C4F3FF]uncheck[/color][/b] this option:


[color=#ffe563][b]3 )[/b][/color] Now, let's install [b][color=#C4F3FF]VapourSynth Preview[/color][/b] which will be used to display our script later. To install, Open [b][color=#C4F3FF]Command Prompt[/color][/b] or [b][color=#C4F3FF]PowerShell[/color][/b] as [b][color=#C4F3FF]"Admin"[/color][/b] and run the commands below.
[color=#ab8aff][quote=1st Input Command]pip install git+https://github.com/Irrational-Encoding-Wizardry/vs-preview[/quote][/color]
[color=#ab8aff][quote=2nd Input Command]vsrepo install akarin libp2p -b "C:\Program Files\VapourSynth\plugins"[/quote][/color]

[color=#ffe563][b]4 )[/b][/color] After that , Open [b][color=#C4F3FF]VS Code[/color][/b] and install [b][color=#C4F3FF]"Python Debugger extension"[/color][/b] .


[color=#ffe563][b]5 )[/b][/color] Now, Let's create our first test Script and try to preview it visually. [b][color=#C4F3FF]Create a new folder[/color][/b] anywhere which will store the current project files. [b][color=#C4F3FF]Open that folder in VS Code[/color][/b]. For now, I'll create and open a folder named "example".



[color=#ffe563][b]6 )[/b][/color] Trust the authors.


[color=#ffe563][b]7 )[/b][/color] Create a new file with [b][color=#C4F3FF]"vpy"[/color][/b] extension and open it. For now, I'll just create a file named script.vpy and open it.


[color=#ffe563][b]8 )[/b][/color] Let's follow the steps below to bind [b][color=#C4F3FF]"vpy"[/color][/b] files as [b][color=#C4F3FF]Python[/color][/b] files. After that we can enjoy the interactive python environment inside [b][color=#C4F3FF]"vpy"[/color][/b] files.





[color=#ffe563][b]9 )[/b][/color] Now that we've binded [b][color=#C4F3FF]"vpy"[/color][/b] as Python we can write codes with Auto Completion and helpful suggestions in the future. ([b][color=#64F5BB]NOTE :[/color][/b] vpy files are your vapoursynth script files where you will import your video, filter it and store the results.)

[color=#ffe563][b]10 )[/b][/color] Write or copy the code below which creates a blank 1920x1080 clip .

import vapoursynth as vs

core = vs.core

blank_clip = core.std.BlankClip(width=1920, height=1080, color=[0,255,0])


[color=#ffe563][b]11 )[/b][/color] Now, we need to deploy [b][color=#C4F3FF]VapourSynth Preview(VS Preview)[/color][/b] inside this folder to easily preview our code. To do that, [b][color=#C4F3FF]Press "CTRL + SHIFT + P"[/color][/b] -> Search & Click [b][color=#C4F3FF]"Create New Terminal"[/color][/b]


[color=#ffe563][b]12 )[/b][/color] Inside the terminal, input [b][color=#C4F3FF]"vspreview --vscode-setup"[/color][/b] and [b][color=#C4F3FF]Press ENTER[/color][/b]. After the command gets executed you will be able to preview vpy scripts that are inside this folder by Pressing "F5" on the keyboard. So, [b][color=#C4F3FF]Press "F5" to preview script.vpy[/color][/b].


[color=#ffe563][b]13 )[/b][/color] After pressing "F5" if you see a blank green frame like below , then CONGRATS🎉 you've successfully installed a basic functional vs environment.


[b][color=#64F5BB]NOTE :[/color][/b] Everytime you [b][color=#C4F3FF]open a different folder in VS Code[/color][/b], you need to execute [b][color=#C4F3FF]"vspreview --vscode-setup"[/color][/b] command inside your folder, [b][color=#C4F3FF]otherwise Pressing F5 won't display your script which are inside the folder[/color][/b].

Now, let's move to the next part .

4) Plugins & Scripts :
[color=#ffe563][b]1 )[/b][/color] [b]What are [color=#C2A4F5]Plugins[/color] and [color=#A7F5A2]Scripts:[/color][/b]
[b][color=#B663FF]Plugins(.dll file) :-[/color][/b] They are the core/main filters . They have to be stored inside the following folder : [quote][color=#d09dfc]C:\ProgramFiles\Vapoursynth\plugins[/color][/quote]

[b][color=#A7F5A2]Scripts/Modules(.py file)[/color][/b]  :- To put it simply, they are a combination of multiple functions which are powered by [b][color=#C2A4F5]Plugins(.dll)[/color][/b] and other [b][color=#A7F5A2]Scripts(.py)[/color][/b]. Their prime usefulness is that they can turn "a long complicated procedure with multiple lines of code" into "an easy to use reusable 1 line of code". These Scripts are written in Python. They are also called [b][color=#A7F5A2]modules[/color][/b] and [b][color=#A7F5A2]packages[/color][/b]. They have to be stored inside the following folder :

[b][color=#64F5BB]NOTE :[/color][/b] In the python location XX represents your python version.
[color=#ffe563][b]2 ) [/b][/color][b]Installing [color=#C2A4F5]Plugins[/color] and [color=#A7F5A2]Scripts[/color] : [/b]
[b][color=#63D2EB]▣ Using VSRepo :-[/color][/b] VSRepo is a package repository for VapourSynth plugins and scripts. It should be already functional in your system as it comes with VapourSynth installer. You can find most of the useful plugins and scripts right inside it. But most of the time they will be outdated, specially script packages inside vsrepo are mostly outdated. But VSRepo is a really good starting point to install VapourSynth Plugins So we have to learn how to use it. Let's see how it works :

[color=#ffe563][b]> [/b][/color] At first , Open [b][color=#C4F3FF]"Command Prompt"[/color][/b] or [b][color=#C4F3FF]"PowerShell"[/color][/b] as [b][color=#C4F3FF]Admin[/color][/b].
[color=#ffe563][b]> [/b][/color] Execute the following command.
[quote=Input]vsrepo install ffms2 lsmas muvsfunc vsutil -b "C:\Program Files\VapourSynth\plugins" -s "C:\Program Files\Python3[color=red]XX[/color]\Lib\site-packages"[/quote]
This command is telling vsrepo to install [b][color=#C2A4F5]"ffms2" and "lsmas"[/color][/b] plugin into the plugins folder and [b][color=#A7F5A2]"muvsfunc" and "vsutil"[/color][/b] script into the site-packages folder. It's also going to install all the plugin and script [b][color=#C4F3FF]dependencies/requirements[/color][/b] which are required to use them.

[b][color=#64F5BB]Note :[/color][/b] Before running the command above, make sure .py files are getting launched by Python and not something else.


[color=#ffe563][b]> [/b][/color] This vsrepo procedure is just an initial starting point but its not that useful if you want to keep up with the latest trends as vsrepo database is rarely updated.

[b][color=#63D2EB]▣ Using git (Proper way) :-[/color][/b]

[b][color=#B663FF]Scripts Installation:[/color][/b]

VapourSynth Developer Communities are hyperactive. They consistently maintain their packages by updating,fixing,adding new functions & features. Most of the time filter "scripts" found in vsrepo are not updated, it even doesn't contain every script that are useful. Thats why we must to learn how to install or download scripts & plugins through git, which is considered to be the proper way. [b][color=#C4F3FF]The developer(author/creator)[/color][/b]  mainly provide their plugin/script by uploading them on [b][color=#C4F3FF]git[/color][/b].  So their git page will be our main source. There are [b][color=#C4F3FF]2 types[/color][/b] of script filters,

[b][color=#64F5BB]1. Standalone Script :[/color][/b] It's a single (.py) script. It doesn't have any files or folders other than a single .py file. To be able to use these scripts ,  we can just download and place them inside [b][color=#C4F3FF]"C:\ProgramFiles\Python3[/color][color=red]XX[/color][color=#C4F3FF]\Lib\site-packages"[/color][/b] folder.  [b]Example[/b] : [url=https://github.com/HomeOfVapourSynthEvolution/havsfunc]havsfunc[/url].

[b][color=#64F5BB]2 . Script Packages :[/color][/b] It will contain multiple .py files and folders. We can use [b][color=#C4F3FF]pip[/color][/b] and [b][color=#C4F3FF]git[/color][/b] to install the python script package from their git page.

[color=#ffe563][b]> [/b][/color]Lets try to install 2 script packages. I'll choose [b][color=#A7F5A2]vstools[/color][/b] and [b][color=#A7F5A2]awsmfunc[/color][/b] for examples.

[color=#ffe563][b]1 )[/b][/color] At first, locate the git page by [b][color=#C4F3FF]Google-ing[/color][/b] the name of the "script" (EX: to find vstools search '[b]vstools vapoursynth[/b]'). After we are inside its git page we need to copy it's link. We can do it like this :


2 . After that we need to perform [b][color=#C4F3FF]pip[/color][/b] and [b][color=#C4F3FF]git[/color][/b] command with the link we've just collected. Open the [b][color=#C4F3FF]"Command Prompt"[/color][/b] or [b][color=#C4F3FF]"PowerShell"[/color][/b] as [b][color=#C4F3FF]admin[/color][/b] and input your command like this : [b][color=#C4F3FF]"pip install git+git-link"[/color][/b]

for [b][color=#A7F5A2]vstools[/color][/b] :

[quote]pip install git+https://github.com/Irrational-Encoding-Wizardry/vs-tools.git[/quote]

Now vs-tools is installed in your system and its directory should be inside "C:\Program Files\Python3XX\Lib\site-packages" folder.

3 . Lets repeat the process and install [b][color=#A7F5A2]awsmfunc[/color][/b].
[quote]pip install git+https://github.com/OpusGang/awsmfunc.git[/quote]
Now awsmfunc should be installed along with its dependency python scripts. Thats it. Now we've learned to install scripts.

[b][color=#B663FF]Plugins Installation:[/color][/b]

[color=#ffe563][b]> [/b][/color]Plugin installation is just copy paste work. Google your required plugin's git page and find the latest release, download the [b][color=#C2A4F5]plugin(.dll)[/color][/b] file and place it inside [b][color=#C4F3FF]"C:\Program Files\VapourSynth\plugins"[/color][/b] folder.
[color=#ffe563][b]> [/b][/color]A huge number of plugins are listed in https://vsdb.top/ with their [b][color=#C4F3FF]github link[/color][/b]. So you can use that website as a source to find plugin's git page, but its safe not to download it from vsdb directly as they are rarely updated as well. 
Usage Example :[/color][/b]
Now that we've figured out how to install scripts and plugins. Lets test another ultra simple script, but this time we'll use an actual video and a external script we've just installed. In this simple example, we'll, import [b][color=#C4F3FF]a  1080p Movie[/color][/b] ->  [b][color=#C4F3FF]Crop its black bars[/color][/b] -> [b][color=#C4F3FF]Fix 1 px dirty lines[/color][/b] Heres how we can do it :

[color=#ffe563][b]> [/b][/color]Create a new [b][color=#C4F3FF]vpy[/color][/b] file , type the following codes inside it and press [b][color=#C4F3FF]"F5"[/color][/b] .


[quote=code]import vapoursynth as vs
from awsmfunc import bbmod

core = vs.core

clip = core.lsmas.LWLibavSource(r"Path/to/your/movie/mkv")
crop = core.std.Crop(clip, top=138, bottom=138) #Assuming it has 138px top and bottom black bars
dirt_fix = bbmod(crop, top=1, bottom=1) #Assuming it has 1px top and bottom dirty lines


If it gets displayed without any error then congrats. You've successfully created your vapoursynth working environment.

Now lets learn how we can ouput our script using x264,x265 .
5) Script output (x264,x265) :
[/b][/color][spoiler][url=https://drive.google.com/drive/folders/1XPGskBD5IdYY5lON-I0JoyY3tqDt_pJM?usp=share_link]Click here[/url] to download x264,x265.
x264 source : https://github.com/jpsdr/x264/releases
x265 source : https://github.com/DJATOM/x265-aMod/releases

Steps to follow :

[color=#ffe563][b]1 )[/b][/color] At first download  x264.exe, x265.exe.

[color=#ffe563][b]2 )[/b][/color] Place x264,x265.exe to [b][color=#C4F3FF]"C:\Program Files\VapourSynth\core\"[/color][/b] folder  (Because this folder is already on PATH). If you want to keep them somewhere else make sure you add that location to [b][color=#C4F3FF]"PATH"[/color][/b] . If you do that , you wont have to write the program location again and again .

[color=#ffe563][b]3 )[/b][/color] Open the Command Prompt as admin input your command like this and run it:
[quote=x264]vspipe -c y4m "Path\to\your\video\script.vpy" - | x264 --crf 16.5 --preset placebo --profile high --level 4.1 --me umh --aq-mode 3 --vbv-maxrate 62500 --vbv-bufsize 78125 --merange 32 --bframes 16 --no-mbtree --rc-lookahead 60 --no-dct-decimate --output "Path\to\your\output.264" --demuxer y4m -[/quote]
[quote=x265]vspipe -c y4m "Path\to\your\video\script.vpy" - | x265 --crf 18 --preset slow --output-depth 10 --profile main10 --level-idc 4.1 --high-tier --aq-mode 3 --vbv-bufsize 50000 --vbv-maxrate 50000 --bframes 8 --colorprim bt709 --colormatrix bt709 --transfer bt709 --no-sao --output "Path\to\your\output.hevc" --y4m -[/quote]
Now it will start encoding and the output will be saved inside raw [b][color=#C4F3FF]'.264'[/color][/b] , [b][color=#C4F3FF]'.hevc'[/color][/b] file . After the encode is finished you can put them inside [b][color=#C4F3FF]'mkv'[/color][/b] container using MKVToolNix .

[b][color=#64F5BB]NOTE :[/color][/b]Don't use powershell to encode through vspipe.

6) Basic Troubleshooting : 
[/b][/color][spoiler]At the beginning of your Vapoursynth filtering journey , you might face a lot of errors. Most of the time that happens because of a missing python module(script), Plugin(.dll) dependency or because of mis-typing a python syntax. So we have to learn how to Identify the problem based on the error and solve it.

[b][color=#64F5BB]▣ Missing Plugin :[/color][/b] If a plugin dependency is missing , it should show an error like this:


It means vapoursynth core was unable to find a plugin(.dll) which has a attribute named [b][color=red]"f3kdb"[/color][/b] because it doesn't exist in our plugins folder. In this case [color=red]f[/color]lash[color=red]3[/color]kyuu_[color=red]d[/color]e[color=red]b[/color]and.dll was missing. So now we just have to look for it in the internet,download it and place it inside vs plugins folder.

[b][color=#64F5BB]▣ Missing Python Module/Script :[/color][/b] If a script is missing, recognizing whats missing won't be an issue. It will show an Import error with the name of whats missing. Example: If vskernels is missing it will thow an error saying [color=red]"No Module Named: vskernels"[/color]. After learning whats missing, just follow the "Scripts Installation" section of this guide and install it.

[b][color=#64F5BB]▣ Invalid Syntax :[/color][/b] There could be hundred types of syntax mistakes one can do .Theres no simplifying it .Im including this point to make you acknowledge the possibility ,that our error could be a syntax issue . 

[b][color=#C4F3FF]If you are stuck with an error please comment below.[/color][/b]

7) Common Queries :
[b][color=#C4F3FF]1 . Do I need to go through this complicated installation process frequently?[/color][/b]
[spoiler]=> No! Its just a 1 time thing, but you should update your installed packages once in a while.

2 . Do I need to know Python to use Vapoursynth?[/color][/b]
[spoiler]=> You don't need to know moderate python. Entry level basic knowledge would suffice and it's very easy to learn. To have a smooth learning experience, go to youtube and learn these:- "Python basic data types, how to import and use a function". Its very easy and won't take much time. 

3 . Do I need to know Avisynth to learn Vapoursynth?[/color][/b]
[spoiler]=>It's not a requirement. Prior Avisynth knowledge might be helpful to an extent. But it shouldn't matter that much if you were a light avisynth user. In my case, it only helped me recognizing some filter names and their basic parameters.[/spoiler]
More Guides :- https://zpaste.net/p/f0p81
Don't hesitate to Comment or PM if you have any confusions, get stuck somewhere or find any flaws . I'll help you as best as I can.
[color=#ffe563][b]1 )[/b][/color] Updated to Python 3.10.5 from 3.9.10 , Vapoursynth R59 from R57, VSPreview Setsugen's fork from Akarin's fork  ! + Thanks to LuffyD.Monkey for helping me find a deficiency !  [2022-06-13]
[color=#ffe563][b]2 )[/b][/color] Version Update (Python 3.11.2, VapourSynth R62) + Made it more easier to read + Changed some filtering example comparisons. [2023-04-06]


[center][b]A Guide written by [color=#D900FF]Tajwar.[/color][/b][/center]