vivy: tv: 02
This commit is contained in:
parent
648b8e1a79
commit
91748bd7b7
Vivy
57
Vivy/02/02.vpy
Normal file
57
Vivy/02/02.vpy
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import vapoursynth as vs
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
sys.path.append("..")
|
||||||
|
|
||||||
|
from vivy_common import (HardsubSign, Range, bounded_dehardsub, antialias, deband, denoise, # noqa: E402
|
||||||
|
finalize, fsrcnnx_rescale, source)
|
||||||
|
|
||||||
|
core = vs.core
|
||||||
|
|
||||||
|
|
||||||
|
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
|
||||||
|
SIGNS_RU: List[HardsubSign] = [
|
||||||
|
HardsubSign((125, 245), ((220, 865), (992, 98)), refframe=143),
|
||||||
|
HardsubSign((865, 896), ((1173, 539), (232, 40))),
|
||||||
|
HardsubSign((2274, 2318), ((431, 671), (1068, 142))),
|
||||||
|
HardsubSign((2391, 2426), ((116, 62), (1471, 311))),
|
||||||
|
HardsubSign((2427, 2452), ((317, 728), (1176, 80))),
|
||||||
|
HardsubSign((3776, 3871), ((782, 286), (748, 76))),
|
||||||
|
HardsubSign((3877, 3950), ((866, 524), (494, 53))),
|
||||||
|
HardsubSign((6498, 6542), ((696, 296), (493, 31))),
|
||||||
|
HardsubSign((7212, 7221), ((430, 666), (1066, 149))),
|
||||||
|
HardsubSign((7222, 7233), ((317, 728), (1179, 84))),
|
||||||
|
HardsubSign((7234, 7245), ((410, 303), (1169, 129))),
|
||||||
|
HardsubSign((7246, 7254), ((514, 687), (807, 90))),
|
||||||
|
HardsubSign((27488, 27630), ((778, 287), (758, 78))),
|
||||||
|
HardsubSign((27636, 27779), ((756, 449), (792, 87))),
|
||||||
|
HardsubSign((28907, 28934), ((758, 454), (787, 79))),
|
||||||
|
HardsubSign((28945, 28954), ((773, 481), (758, 57))),
|
||||||
|
HardsubSign((28986, 29019), ((621, 748), (657, 52))),
|
||||||
|
HardsubSign((29053, 29061), ((621, 748), (657, 52))),
|
||||||
|
HardsubSign((29062, 29077), ((649, 333), (742, 53))),
|
||||||
|
HardsubSign((29615, 29674), ((336, 74), (1244, 76))),
|
||||||
|
HardsubSign((29675, 29758), ((587, 68), (750, 85))),
|
||||||
|
HardsubSign((30259, 30977), ((293, 843), (1321, 227))),
|
||||||
|
HardsubSign((32608, 32703), ((281, 859), (890, 101))),
|
||||||
|
]
|
||||||
|
CREDITS: List[Range] = [(30152, 32343)]
|
||||||
|
PIXELSHIT: List[Range] = [
|
||||||
|
(7255, 7278),
|
||||||
|
]
|
||||||
|
NOSCALE: List[Range] = CREDITS + PIXELSHIT
|
||||||
|
NOAA: List[Range] = PIXELSHIT
|
||||||
|
|
||||||
|
waka, funi = source(EPNUM)
|
||||||
|
waka = waka[:32344] + waka[32349:]
|
||||||
|
|
||||||
|
src = bounded_dehardsub(waka, funi, SIGNS_RU)
|
||||||
|
rescale = fsrcnnx_rescale(src, NOSCALE)
|
||||||
|
den = denoise(rescale)
|
||||||
|
deb = deband(den)
|
||||||
|
aa = antialias(deb, NOAA)
|
||||||
|
final = finalize(aa)
|
||||||
|
final.set_output()
|
@ -19,7 +19,7 @@ src = core.ffms2.Source(funi)
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
funi_audio: str = f"{EPNUM:02d}/funi.aac"
|
funi_audio: str = f"{EPNUM:02d}/funi.aac"
|
||||||
if not os.path.exists(funi_audio):
|
if not os.path.isfile(funi_audio):
|
||||||
call(["ffmpeg",
|
call(["ffmpeg",
|
||||||
"-i", funi,
|
"-i", funi,
|
||||||
"-vn",
|
"-vn",
|
||||||
@ -29,4 +29,4 @@ if __name__ == "__main__":
|
|||||||
funi_audio],
|
funi_audio],
|
||||||
stdout=DEVNULL, stderr=DEVNULL
|
stdout=DEVNULL, stderr=DEVNULL
|
||||||
)
|
)
|
||||||
ac.eztrim(src, (FUNI_INTRO, 0), funi_audio, f"{EPNUM:02d}/{EPNUM:02d}_cut.aac")
|
ac.eztrim(src, (FUNI_INTRO, 0), funi_audio, f"{EPNUM:02d}/{EPNUM:02d}_cut.mka")
|
||||||
|
@ -46,12 +46,16 @@ class HardsubSign():
|
|||||||
else:
|
else:
|
||||||
self.bound = BoundingBox(Position(bound[0][0], bound[0][1]), Size(bound[1][0], bound[1][1]))
|
self.bound = BoundingBox(Position(bound[0][0], bound[0][1]), Size(bound[1][0], bound[1][1]))
|
||||||
|
|
||||||
def get_hardsub_mask(self, hrdsb: vs.VideoNode, ref: vs.VideoNode) -> vs.VideoNode:
|
def _hardsub_mask(self, hrdsb: vs.VideoNode, ref: vs.VideoNode) -> vs.VideoNode:
|
||||||
if self.refframe is not None:
|
if self.refframe is not None:
|
||||||
return kgf.hardsubmask_fades(hrdsb[self.refframe], ref[self.refframe], highpass=2000)
|
mask = kgf.hardsubmask_fades(hrdsb[self.refframe], ref[self.refframe], highpass=2000)
|
||||||
return kgf.hardsubmask_fades(hrdsb, ref, highpass=2000)
|
else:
|
||||||
|
mask = kgf.hardsubmask_fades(hrdsb, ref, highpass=2000)
|
||||||
|
|
||||||
def get_bound_mask(self, ref: vs.VideoNode) -> vs.VideoNode:
|
assert isinstance(mask, vs.VideoNode)
|
||||||
|
return mask
|
||||||
|
|
||||||
|
def _bound_mask(self, ref: vs.VideoNode) -> vs.VideoNode:
|
||||||
if self.bound is not None:
|
if self.bound is not None:
|
||||||
mask = kgf.squaremask(ref, self.bound.size.x, self.bound.size.y,
|
mask = kgf.squaremask(ref, self.bound.size.x, self.bound.size.y,
|
||||||
self.bound.pos.x, self.bound.pos.y)
|
self.bound.pos.x, self.bound.pos.y)
|
||||||
@ -61,13 +65,17 @@ class HardsubSign():
|
|||||||
assert isinstance(mask, vs.VideoNode)
|
assert isinstance(mask, vs.VideoNode)
|
||||||
return mask
|
return mask
|
||||||
|
|
||||||
|
def get_mask(self, hrdsb: vs.VideoNode, ref: vs.VideoNode) -> vs.VideoNode:
|
||||||
|
bm = self._bound_mask(ref)
|
||||||
|
hm = self._hardsub_mask(hrdsb, ref)
|
||||||
|
return core.std.MaskedMerge(core.std.BlankClip(hm), hm, bm)
|
||||||
|
|
||||||
|
|
||||||
def bounded_dehardsub(hrdsb: vs.VideoNode, ref: vs.VideoNode, signs: List[HardsubSign]) -> vs.VideoNode:
|
def bounded_dehardsub(hrdsb: vs.VideoNode, ref: vs.VideoNode, signs: List[HardsubSign]) -> vs.VideoNode:
|
||||||
bound = hrdsb
|
bound = hrdsb
|
||||||
for sign in signs:
|
for sign in signs:
|
||||||
dhs = core.std.MaskedMerge(hrdsb, ref, sign.get_hardsub_mask(hrdsb, ref))
|
|
||||||
bound = lvf.misc.replace_ranges(bound,
|
bound = lvf.misc.replace_ranges(bound,
|
||||||
core.std.MaskedMerge(hrdsb, dhs, sign.get_bound_mask(hrdsb)),
|
core.std.MaskedMerge(hrdsb, ref, sign.get_mask(hrdsb, ref)),
|
||||||
[sign.range])
|
[sign.range])
|
||||||
|
|
||||||
return bound
|
return bound
|
||||||
|
Loading…
x
Reference in New Issue
Block a user