-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.vpy
91 lines (78 loc) · 4.31 KB
/
script.vpy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import vapoursynth as vs
core = vs.get_core()
video = core.ffms2.Source('J:/rainbow.webm')
# Any pre-processing to video should be performed here
pre = video[0] + video
# super clip
super = core.mv.Super(video, hpad=0, vpad=0, pel=1, chroma=True, rfilter=0)
# mmap
anal = core.mv.Analyse(super=super, blksize=4, search=3, searchparam=2, chroma=False, truemotion=False)
anal = core.mv.Recalculate(super, anal, 32, 0, 4, search=3, searchparam=2, chroma=False, truemotion=False)
mmask = core.mv.Mask(clip=video, vectors=anal, ml=1, time=0, thscd1=0, thscd2=255)
#mmask2 = core.mv.Mask(clip=video, vectors=anal, ml=2, time=0, thscd1=400, thscd2=130)
mmask = core.std.Binarize(mmask,threshold=255,v0=0,v1=255,planes=[0])
#mmask2 = core.std.Binarize(mmask2,threshold=255,v0=0,v1=255,planes=[0])
mmask = core.std.ShufflePlanes(mmask, [0,0,0], vs.YUV)
#mmask2 = core.std.ShufflePlanes(mmask2, [0,0,0], vs.YUV)
mmask = core.resize.Bilinear(mmask,format=vs.YUV420P8)
#mmask2 = core.resize.Bilinear(mmask2,format=vs.YUV420P8)
# mcmap
comp = core.mv.Compensate(clip=video, super=super, vectors=anal)#,time=0)#, thsad=32)
#precomp = comp[0] + comp
mcmask = core.std.MakeDiff(video, comp, 0)
above = core.std.Binarize(mcmask,threshold=127+16,v0=0,v1=255,planes=[0])
below = core.std.Binarize(mcmask,threshold=127-16,v0=255,v1=0,planes=[0])
mcmask = core.std.Merge(above, below, .5)
mcmask = core.std.Binarize(mcmask,threshold=127,v0=0,v1=255,planes=[0])
mcmask = core.std.ShufflePlanes(mcmask, [0,0,0], vs.YUV)
mcmask = core.resize.Bilinear(mcmask,format=vs.YUV420P8)
# dcmap frame n
dcmap = core.dotdetect.Detect(video, 2)
dcmap = core.std.Merge(dcmap, mmask, .5)
dcmap = core.std.Binarize(dcmap,threshold=255,v0=0,v1=255,planes=[0])
dcmap = core.std.ShufflePlanes(dcmap, [0,0,0], vs.YUV)
dcmap = core.resize.Bilinear(dcmap,format=vs.YUV420P8)
dcmappre = dcmap[0] + dcmap
# rbmap
upscaled = core.resize.Bilinear(video,format=vs.YUV444P8)
upscaledmmap = core.resize.Bilinear(mmask,format=vs.YUV444P8)
rbmap = core.rainbowdetect.Detect(upscaled,10,5,5,20,20)
#rbmap = core.std.Merge(rbmap, upscaledmmap, .5)
rbmap = core.std.Binarize(rbmap,threshold=255,v0=0,v1=255,planes=[0])
rbmap = core.std.ShufflePlanes(rbmap, [0,0,0], vs.YUV)
rbmap = core.resize.Bilinear(rbmap,format=vs.YUV420P8)
# filtering (by merging masks where appropriate)
nommask = core.std.Levels(core.std.Invert(mmask),0,255,1,0,127)
#filtered = core.std.Merge(video,pre,0.5)
filtered = core.std.MaskedMerge(video, pre, nommask, [0,1,2], True)
tempmask = core.std.Merge(mmask,core.std.Invert(mcmask,[0,1,2]),.5)
tempmask = core.std.Binarize(tempmask,threshold=255,v0=0,v1=255,planes=[0])
mcmasknew = tempmask
dcmapboth = core.std.Merge(dcmap,dcmappre,.5)
dcmapboth = core.std.Binarize(dcmapboth,threshold=255,v0=0,v1=255,planes=[0])
#dcmapboth = core.std.ShufflePlanes(dcmapboth, [0,0,0], vs.YUV)
dcmapneither = core.std.Merge(core.std.Invert(dcmap),core.std.Invert(dcmappre),.5)
dcmapneither = core.std.Binarize(dcmapneither,threshold=255,v0=0,v1=255,planes=[0])
dcmapeither = core.std.Merge(dcmap,dcmappre,.5)
dcmapeither = core.std.Binarize(dcmapeither,threshold=127,v0=0,v1=255,planes=[0])
dcmapone = core.std.Merge(dcmapeither, core.std.Invert(dcmapboth), .5)
dcmapone = core.std.Binarize(dcmapone, threshold=255,v0=0,v1=255,planes=[0])
rbmaponly = core.std.Merge(rbmap,dcmapneither,.5)
rbmaponly = core.std.Binarize(rbmaponly,threshold=255,v0=0,v1=255,planes=[0])
rbordcmap = core.std.Merge(dcmapboth, rbmaponly, .5)
rbordcmap = core.std.Binarize(rbordcmap,threshold=127,v0=0,v1=255,planes=[0])
tempmask = core.std.Merge(tempmask,rbordcmap,.5)
tempmask = core.std.Binarize(tempmask,threshold=255,v0=0,v1=255,planes=[0])
tempmask = core.std.ShufflePlanes(tempmask, [0,0,0], vs.YUV)
tempmask = core.resize.Bilinear(tempmask,format=vs.YUV420P8)
tempmask = core.std.Levels(tempmask,0,255,1,0,127)
spacemask = core.std.ShufflePlanes(dcmapone, [0,0,0], vs.YUV)
spacemask = core.resize.Bilinear(spacemask,format=vs.YUV420P8)
spacemask = core.std.Levels(spacemask,0,255,1,0,127)
blurred = core.dotblur.Blur(upscaled)
blurred = core.resize.Bilinear(blurred,format=vs.YUV420P8)
filtered = core.std.MaskedMerge(filtered, comp, tempmask, [0,1,2], True)
filtered = core.std.MaskedMerge(filtered, blurred, spacemask, [0,1,2], True)
#int = core.std.Interleave(clips=[video, mmask, mcmask, tempmask])
int = core.std.Interleave([video,filtered])
int.set_output()