VapourSynth介绍

VapourSynth是现代的AviSynth。

安装

参考官方文档

python

官网下载python36Windows x86-64 executable installer安装,保证python目录添加到环境变量Path中。打开cmd检查安装是否成功

1
2
C:\Users\Win7>python -V
Python 3.6.6

VapourSynth

官网下载地址VapourSynth-R44.exe安装,安装程序会自动检查python环境。打开cmd检查安装是否成功

1
2
3
4
5
6
7
8
9
10
11
C:\Users\Win7>python
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD6
4)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from vapoursynth import core
>>> print(core.version())
VapourSynth Video Processing Library
Copyright (c) 2012-2017 Fredrik Mellbin
Core R38
API R3.5
Options: -

VapourSynth Editor

官方下载地址VapourSynthEditor-r18-64bit.7z,解压即可使用。如果遇到缺少vc++运行时的错误提示,到网页查找安装。

VapourSynth 插件

ffms2

地址

fillborders

地址

更多插件

https://github.com/search?q=vapoursynth

插件的加载

两种方式,一种是自动加载,加载路径参考官方文档。另一种就是在脚本中加载,具体参考下面的例子

使用

ffmsindex

用ffms2处理mkv视频时,我们先用ffmsindex为视频文件做index,ffmsindex在ffms2解压文件价中。

1
2
3
C:\Users\Win7\Desktop\workshop>C:\Users\Win7\Desktop\StaxRip-x64-1.7.0.0-stable\
Apps\Plugins\both\ffms2\ffmsindex.exe 01002.mkv
Indexing, please wait... 7%

编写vpy

.vpy是VapourSynth用来处理视频的脚本文件,其实就是python代码。我们可以用VapourSynth Editor写这些脚本,按F5可以预览效果。

下面的两段代码分别是做测试视频时和做比较视频时用的两段代码

1
2
3
4
5
6
7
8
9
10
11
12
import vapoursynth as vs
core = vs.get_core()
# 加载非标准位置的插件
core.std.LoadPlugin(r"C:\Users\Win7\Desktop\StaxRip-x64-1.7.0.0-stable\Apps\Plugins\both\ffms2\ffms2.dll")
clip = core.ffms2.Source(r"C:\Users\Win7\Desktop\workshop\01002.mkv")
# 切黑边
clip = core.std.CropRel(clip, 0, 0, 22, 20)
# 处理dirty line
clip = core.fb.FillBorders(clip, left=1, top=1, right=1, bottom=0, mode="fillmargins")
# 测试视频时,每个10000帧取1000,跳过前2000帧的办法
clip = core.std.SelectEvery(clip[2000::], cycle=10000, offsets=range(1000))
clip.set_output()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import vapoursynth as vs
core = vs.get_core()
core.std.LoadPlugin(r"C:\Users\Win7\Desktop\StaxRip-x64-1.7.0.0-stable\Apps\Plugins\both\ffms2\ffms2.dll")
clip = core.ffms2.Source(r"C:\Users\Win7\Desktop\workshop\01002.mkv")
clip = core.std.CropRel(clip, 0, 0, 22, 20)
clip = core.fb.FillBorders(clip, left=1, top=1, right=1, bottom=0, mode="fillmargins")
clip = core.std.SelectEvery(clip[5000:], cycle=20000, offsets=range(1000))
# text显示帧信息和自定义标签
clip = clip.text.FrameProps(props=["_PictType"]).text.Text(text="SOURCE")
clip2 = core.ffms2.Source(r"C:\Users\Win7\Desktop\workshop\01002_new.mkv")
clip2 = clip2.text.FrameProps(props=["_PictType"]).text.Text(text="CRF16")
# 将两个视频交替显示
clip = core.std.Interleave(clips=[clip, clip2], mismatch=1)
clip.set_output()

效果

pic1