Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.22 KB | None | 0 0
  1. [quote=stargaze][size=5][color=#007dc6][b]1. Introduction to Vapoursynth[/b][/color][/size]
  2.  
  3. [size=3][color=#007dc6][b]1.1 What is Vapoursynth?[/b][/color][/size]
  4.  
  5. [url=http://www.vapoursynth.com/]VapourSynth[/url] (VS) is an application for video manipulation, just like Avisynth. It has a core library written in C++ and a Python module to allow video scripts to be created.
  6.  
  7. [url=https://bitbucket.org/mystery_keeper/vapoursynth-editor]VapourSynth Editor[/url] (VSE) is the script editor which is commonly used, with syntax completion and fast preview support.
  8.  
  9. Vapoursynth scripts are written in python. The main difference compared to Avisynth is the assignment of variables. You have to specify the variable names each time you’re doing something:
  10. [pre]variable = doSomething()
  11. [/pre]You will have more things to write but it will be clearer to which variable you're assigning the operation.
  12.  
  13. [size=3][color=#007dc6][b]1.2 Installation of VapourSynth[/b][/color][/size]
  14.  
  15. The prefered way to install VS is to get the needed packages from the repositories of your distribution, for its simplicity. However, I will here detail how to compile them if you want to have the latest versions which may not be available from your package manager. The initial instructions are taken from [url=http://www.l33tmeatwad.com/vapoursynth101/software-setup]here[/url]. For Arch-based system users, you should be able to compile everything from AUR.
  16. [spoiler]
  17. [color=#007dc6]1.2.1 Preparation[/color]
  18.  
  19. In the following, we will make the installation in ~/apps. Make sure this directory exists or change it if you like.
  20.  
  21. [*]Ubuntu:
  22. Check to see if the "site-packages" directory exists:
  23. [pre]if test -d /usr/local/lib/python3.6/site-packages; then echo "exists"; else echo "doesn't exist"; fi
  24. [/pre]If it does, moving all the files to dist-packages and deleting the directory is recommended.
  25. Create a link to the "dist-packages" directory:
  26. [pre]sudo ln -s /usr/local/lib/python3.6/dist-packages /usr/local/lib/python3.6/site-packages
  27. [/pre][*]Fedora:
  28. Create now a link for the plugins install directory to the VS one:
  29. [pre]sudo ln -s /usr/lib64/vapoursynth /usr/local/lib/vapoursynth
  30. [/pre][color=#994d00]For Fedora users, in the following when running ./configure for ffmpeg, l-smash, vapoursynth, x264 and zimg, add --prefix=/usr.[/color]
  31.  
  32. [color=#007dc6]1.2.2 Dependencies for VS and its plugins[/color]
  33.  
  34. > [b]Required packages from the repositories of your distribution:[/b]
  35.  
  36. [*]Ubuntu:
  37. [pre]sudo apt-get install build-essential git yasm libass-dev python3-pip python3-dev cython3 autoconf libtool libmagick++-dev qt5-default libfftw3-dev
  38. [/pre][*]Fedora:
  39. [pre]sudo dnf install automake gcc gcc-c++ yasm libass-devel python3-devel libtool ImageMagick-c++-devel qt-devel fftw-devel redhat-rpm-config qt5-qtbase-devel
  40. sudo pip3 install cython
  41. [/pre]> [b]L-SMASH[/b]
  42. [pre]cd ~/apps
  43. git clone https://github.com/l-smash/l-smash.git
  44. ./configure --enable-shared
  45. make lib
  46. sudo make install-lib
  47. [/pre]> [b]x264[/b]
  48. [pre]cd ~/apps
  49. git clone git://git.videolan.org/x264.git
  50. cd x264
  51. ./configure --enable-shared
  52. make
  53. sudo make install
  54. [/pre]> [b]ffmpeg[/b]
  55. [pre]cd ~/apps
  56. git clone https://github.com/ffmpeg/ffmpeg.git
  57. cd ffmpeg
  58. ./configure --enable-gpl --enable-libx264 --enable-avresample --enable-shared
  59. make
  60. sudo make install
  61. [/pre]> [b]zimg[/b]
  62. [pre]cd ~/apps
  63. git clone https://github.com/sekrit-twc/zimg.git
  64. cd zimg
  65. ./autogen.sh
  66. ./configure
  67. make
  68. sudo make install
  69. [/pre]
  70. [color=#007dc6]1.2.3 VapourSynth[/color]
  71.  
  72. > [b]Installation[/b]
  73. [pre]cd ~/apps
  74. git clone https://github.com/vapoursynth/vapoursynth.git
  75. ./autogen.sh
  76. ./configure
  77. make
  78. sudo make install[/pre]
  79. > [b]Now try it out:[/b]
  80. [pre]vspipe --version
  81. [/pre]Possible errors:
  82.  
  83. [*]"vspipe: error while loading shared libraries: libvapoursynth-script.so.0: cannot open shared object file: No such file or directory”.
  84. This is caused by the non-standard location of libvapoursynth-script.so.0. Your dynamic loader is not configured to look in /usr/local/lib. One way to work around this error is to set the LD_LIBRARY_PATH environment variable. Open ~/.bashrc and add:
  85. [pre]export LD_LIBRARY_PATH=/usr/local/lib
  86. [/pre]Then reload ~/.bashrc with:
  87. [pre]. ~/.bashrc
  88. [/pre][*]“Failed to initialize VapourSynth environment”.
  89. This is caused by the non-standard location of the Python module, vapoursynth.so. Your Python is not configured to look in /usr/local/lib/python3.x/site-packages. One way to work around this error is to set the PYTHONPATH environment variable. Open ~/.bashrc and add (replace “x” with the correct number, you probably have python 3.6):
  90. [pre]export PYTHONPATH=/usr/local/lib/python3.x/site-packages
  91. [/pre]Then reload ~/.bashrc with:
  92. [pre]. ~/.bashrc
  93. [/pre][color=#007dc6]1.2.4 VapourSynth Editor[/color]
  94.  
  95. > [b]Installation[/b]
  96. [pre]cd ~/apps
  97. git clone https://bitbucket.org/mystery_keeper/vapoursynth-editor.git
  98. cd vapoursynth-editor/pro
  99. qmake pro.pro #NOTE: Fedora uses qmake-qt5.
  100. make
  101. sudo ln -s ~/apps/vapoursynth-editor/build/release-64bit-gcc/vsedit /usr/bin/vsedit
  102. [/pre]> [b]Add VapourSynth-Editor to application menu[/b] (Optional, for gnome):
  103. [pre]sudo ln -s $HOME/apps/VapourSynth-Editor/vsedit.ico /usr/share/icons/vsedit.ico
  104. sudo gedit ~/.local/share/applications/vsedit.desktop
  105. [/pre]Enter the following, save, then close gedit:
  106. [pre][Desktop Entry]
  107. Type=Application
  108. Name=VapourSynth-Editor
  109. Comment=
  110. Icon=/usr/share/icons/vsedit.ico
  111. Exec=/usr/bin/vsedit
  112. Terminal=false
  113. Categories=VapourSynth;
  114. [/pre][/spoiler]
  115. [size=3][color=#007dc6][b]1.3 Installation of plugins[/b][/color][/size]
  116. [spoiler]
  117. Let's take FFMS2, that you will need, as example.
  118.  
  119. > [b]Download the source[/b]:[pre]git clone https://github.com/FFMS/ffms2.git
  120. [/pre]> [b]Browse to the source directory:[/b][pre]cd ffms2
  121. [/pre]> [b]Next you need to find what files were included to assist with compiling the source:[/b][pre]ls
  122. [/pre]You will be looking for one or more of the following files: autogen.sh, configure, CMakeLists.txt, or waf.
  123.  
  124. > [b]FFMS2 has autogen.sh so you would compile and install by doing the following:[/b][pre]./autogen.sh
  125. ./configure
  126. make
  127. sudo make install
  128. [/pre]> [b]Pay attention to where the install places the file, most plugins will install to /usr/local/lib instead of the VS plugins directory. If this is the case you will need to create a symbolic link in the VS plugins folder by doing the following:[/b]
  129.  
  130. [*]Ubuntu:
  131. [pre]sudo ln -s /usr/local/lib/ffms2.so /usr/local/lib/vapoursynth/libffms2.so
  132. [/pre][*]Fedora:
  133. [pre]sudo ln -s /usr/lib64/libffms2.so /usr/lib64/vapoursynth/libffms2.so
  134. [/pre]Follow the same procedure for each plugin you want to install.
  135. [/spoiler]
  136. [size=3][color=#007dc6][b]1.4 Scripts[/b][/color][/size]
  137.  
  138. Most Avisynth functions have been ported by a couple of developers/contributers. Their scripts usually rely on each other’s. Here are the scripts you can have a look at and their respective functions:
  139.  
  140. [url=https://github.com/HomeOfVapourSynthEvolution/havsfunc]havsfunc[/url]
  141. [spoiler]
  142. Main functions:
  143. [quote]daa
  144. santiag
  145. FixChromaBleedingMod
  146. Deblock_QED
  147. DeHalo_alpha
  148. YAHR
  149. HQDering mod
  150. QTGMC
  151. srestore
  152. ivtc_txt60mc
  153. logoNR
  154. Vinverse
  155. Vinverse2
  156. LUTDeCrawl
  157. LUTDeRainbow
  158. Stab
  159. GrainStabilizeMC
  160. MCTemporalDenoise
  161. SMDegrain
  162. STPresso
  163. SigmoidInverse, SigmoidDirect
  164. GrainFactory3
  165. InterFrame
  166. SmoothLevels
  167. FastLineDarken 1.4x MT MOD
  168. Toon
  169. LSFmod
  170. TemporalDegrain
  171. aaf[/quote]
  172. Utility functions:
  173. [quote]AverageFrames
  174. Bob
  175. ChangeFPS
  176. Clamp
  177. KNLMeansCL
  178. Overlay
  179. Padding
  180. Resize
  181. SCDetect
  182. Weave
  183. ContraSharpening
  184. MinBlur
  185. sbr
  186. DitherLumaRebuild
  187. mt_expand_multi
  188. mt_inpand_multi
  189. mt_inflate_multi
  190. mt_deflate_multi[/quote][/spoiler]
  191. [url=https://github.com/WolframRhodium/muvsfunc]muvsfunc[/url]
  192. [spoiler]
  193. [quote]LDMerge
  194. Compare (2)
  195. ExInpand
  196. InDeflate
  197. MultiRemoveGrain
  198. GradFun3
  199. AnimeMask (2)
  200. PolygonExInpand
  201. Luma
  202. ediaa
  203. nnedi3aa
  204. maa
  205. SharpAAMcmod
  206. TEdge
  207. Sort
  208. Soothe_mod
  209. TemporalSoften
  210. FixTelecinedFades
  211. TCannyHelper
  212. MergeChroma
  213. firniture
  214. BoxFilter
  215. SmoothGrad
  216. DeFilter
  217. scale (using the old expression in havsfunc)
  218. ColorBarsHD
  219. SeeSaw
  220. abcxyz
  221. Sharpen
  222. Blur
  223. BlindDeHalo3
  224. dfttestMC
  225. TurnLeft
  226. TurnRight
  227. BalanceBorders
  228. DisplayHistogram
  229. GuidedFilter (Color)
  230. GMSD
  231. SSIM
  232. SSIM_downsample
  233. LocalStatisticsMatching
  234. LocalStatistics
  235. TextSub16
  236. TMinBlur
  237. mdering
  238. BMAFilter[/quote][/spoiler]
  239. [url=https://github.com/HomeOfVapourSynthEvolution/mvsfunc]mvsfunc[/url]
  240. [spoiler]
  241. Main functions:
  242. [quote]Depth
  243. ToRGB
  244. ToYUV
  245. BM3D
  246. VFRSplice[/quote]
  247. Runtime functions:
  248. [quote]PlaneStatistics
  249. PlaneCompare
  250. ShowAverage
  251. FilterIf
  252. FilterCombed[/quote]
  253. Utility functions:
  254. [quote]Min
  255. Max
  256. Avg
  257. MinFilter
  258. MaxFilter
  259. LimitFilter
  260. PointPower
  261. CheckMatrix
  262. postfix2infix[/quote]
  263. Frame property functions:
  264. [quote]SetColorSpace
  265. AssumeFrame
  266. AssumeTFF
  267. AssumeBFF
  268. AssumeField
  269. AssumeCombed[/quote]
  270. Helper functions:
  271. [quote]CheckVersion
  272. GetMatrix
  273. zDepth
  274. PlaneAverage
  275. GetPlane
  276. GrayScale
  277. Preview[/quote][/spoiler]
  278. [url=https://github.com/Irrational-Encoding-Wizardry/fvsfunc]fvsfunc[/url]
  279. [spoiler][quote]GradFun3mod
  280. DescaleM (DebilinearM, DebicubicM etc.)
  281. Downscale444
  282. JIVTC
  283. OverlayInter
  284. AutoDeblock
  285. ReplaceFrames (ReplaceFramesSimple)
  286. maa
  287. TemporalDegrain
  288. DescaleAA
  289. InsertSign[/quote][/spoiler]
  290. [url=https://gist.github.com/kageru/d71e44d9a83376d6b35a85122d427eb5]kagefunc[/url]
  291. [spoiler][quote]inverse_scale
  292. inverse_scale_clip_array
  293. clip_to_plane_array
  294. plane_array_to_clip
  295. generate_mask
  296. apply_mask
  297. apply_mask_to_area
  298. getY
  299. generate_keyframes
  300. adaptive_grain
  301. conditional_resize
  302. retinex_edgemask
  303. kirsch
  304. fast_sobel
  305. get_descale_filter
  306. hardsubmask
  307. hardsubmask_fades
  308. crossfade
  309. hybriddenoise
  310. insert_clip
  311. get_subsampling
  312. iterate
  313. is16bit
  314. getw
  315. shiftl
  316. fit_subsampling
  317. mask_detail[/quote][/spoiler]
  318. [url=https://gist.github.com/4re/bba3f65469acfe0ec08a]vshelpers of 4re[/url]
  319. [spoiler][quote]clamp
  320. m4
  321. build_mask
  322. mt_lut
  323. mt_lutxy
  324. logic
  325. get_luma
  326. merge_chroma
  327. rsoften
  328. fit
  329. move
  330. get_decoder
  331. subtract
  332. starmask[/quote][/spoiler]
  333. I additionally created avisynth's ports of functions you will probably need and other utility functions in my [url=https://awesome-hd.me/forums.php?action=viewthread&threadid=23395&post=1#post183689]sgvsfunc script[/url].
  334. [spoiler]
  335. Filtering functions:
  336. [quote]FixRowBrightness
  337. FixColumnBrightness
  338. FixRowBrightnessProtect2
  339. FixColumnBrightnessProtect2
  340. FixBrightnessProtect2
  341. bbmod
  342. BlackBorders
  343. CropResize
  344. CropResizeReader
  345. DebandReader
  346. LumaMaskMerge
  347. RGBMaskMerge[/quote]
  348. Utility functions:
  349. [quote]SelectRangeEvery
  350. FrameInfo
  351. DelFrameProp
  352. InterleaveDir
  353. ExtractFramesReader
  354. ReplaceFrames
  355. Overlay
  356. mt_lut
  357. GetPlane
  358. scale[/quote][/spoiler]
  359. You can install the aforementioned scripts. You will also need to install [url=https://github.com/dubhater/vapoursynth-adjust]Adjust[/url] which is a requirement for havsfunc.
  360.  
  361. To install a python script for VS, just download the .py file from github and copy it into your python packages directory:
  362.  
  363. [*]Ubuntu: /usr/local/lib/python3.6/dist-packages
  364. [*]Fedora & Arch: /usr/lib64/python3.6/site-packages
  365.  
  366. [size=3][color=#007dc6][b]1.5 Initialisation of a script[/b][/color][/size]
  367.  
  368. [color=#007dc6]1.5.1 Basics[/color]
  369.  
  370. Open VSE. The first step when creating a script is to initialise VS. Write the following always in the first line:
  371. [pre]import vapoursynth as vs
  372. from vapoursynth import core
  373. [/pre]The second line can alternatively be:
  374. [pre]core = vs.get_core()
  375. [/pre]And the following always in the last line of your script:
  376. [pre]last.set_output()
  377. [/pre]where “last” should contain the clip you want to encode.
  378.  
  379. [color=#007dc6]1.5.2 Loading plugins[/color]
  380.  
  381. Plugins will be automatically loaded once installed. You can rely on “core” to call them:
  382. [pre]variable = core.pluginname.function(clip)
  383. [/pre]For example:
  384. [pre]src = core.ffms2.Source('/path/to/source.mkv')
  385. [/pre][color=#007dc6]1.5.3 Loading scripts[/color]
  386.  
  387. Scripts are loaded manually. Import them at the beginning of your script. You may give them names. For example:
  388. [pre]import fvsfunc as fvf
  389. import mvsfunc as mvf
  390. import kagefunc as kgf
  391. import havsfunc as haf
  392. import muvsfunc as muvf
  393. import sgvsfunc as sgf
  394. [/pre]You can finally call them in your script:
  395. [pre]variable = scriptname.function(clip)
  396. [/pre]For example to call QTGMC:
  397. [pre]out = haf.QTGMC(src)
  398. [/pre][/quote]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement