5
0

Compare commits

...

2 Commits

Author SHA1 Message Date
010673efa4
tensura: s2: bd: vol1 zoning and vol2 2021-06-03 19:48:41 -04:00
1a96b0f09e
yt_common: zoning support 2021-06-03 18:25:33 -04:00
21 changed files with 824 additions and 36 deletions

View File

@ -1,8 +1,8 @@
import vapoursynth as vs
from tensura_common import TenSuraConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner
from yt_common.automation import SelfRunner, Zone
from yt_common.chapters import Chapter
from yt_common.source import FileTrim, SimpleSource
@ -15,7 +15,7 @@ from typing import List, Tuple
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraConfig = TenSuraConfig(EPNUM)
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210326][Tensei Shitara Slime Datta Ken 2nd Season][Vol.1]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00006.m2ts"), (24, -50))
@ -35,6 +35,11 @@ NOD3: List[Range] = [
(33926, 34045),
]
ZONES: List[Zone] = [
]
ZONES += [Zone(r, 0.75) for r in NOD3 if isinstance(r, tuple)]
AA_STRONG: List[Range] = [
(15605, 15772),
]
@ -88,6 +93,6 @@ def filter() -> vs.VideoNode:
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS)
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS, zones=ZONES)
else:
filter()

View File

@ -1,6 +1,6 @@
import vapoursynth as vs
from tensura_common import TenSuraConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner
from yt_common.chapters import Chapter
@ -14,7 +14,7 @@ from typing import List
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraConfig = TenSuraConfig(EPNUM)
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210326][Tensei Shitara Slime Datta Ken 2nd Season][Vol.1]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00007.m2ts"), (None, -49))

View File

@ -1,8 +1,8 @@
import vapoursynth as vs
from tensura_common import TenSuraConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner
from yt_common.automation import SelfRunner, Zone
from yt_common.chapters import Chapter
from yt_common.source import FileTrim, SimpleSource
@ -14,7 +14,7 @@ from typing import List
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraConfig = TenSuraConfig(EPNUM)
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210326][Tensei Shitara Slime Datta Ken 2nd Season][Vol.1]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00008.m2ts"), (None, -50))
@ -34,6 +34,11 @@ NOD3: List[Range] = [
(33926, 34045),
]
ZONES: List[Zone] = [
]
ZONES += [Zone(r, 0.75) for r in NOD3 if isinstance(r, tuple)]
AA_STRONG: List[Range] = [
(3084, 3125),
]
@ -60,6 +65,6 @@ def filter() -> vs.VideoNode:
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS)
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS, zones=ZONES)
else:
filter()

View File

@ -1,6 +1,6 @@
import vapoursynth as vs
from tensura_common import TenSuraConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner
from yt_common.chapters import Chapter
@ -15,7 +15,7 @@ from typing import List, Tuple
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraConfig = TenSuraConfig(EPNUM)
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210326][Tensei Shitara Slime Datta Ken 2nd Season][Vol.1]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00009.m2ts"), (None, -51))

View File

@ -1,6 +1,6 @@
import vapoursynth as vs
from tensura_common import TenSuraConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner
from yt_common.chapters import Chapter
@ -15,7 +15,7 @@ from typing import List, Tuple
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraConfig = TenSuraConfig(EPNUM)
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210326][Tensei Shitara Slime Datta Ken 2nd Season][Vol.1]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00010.m2ts"), (None, -24))

View File

@ -1,8 +1,8 @@
import vapoursynth as vs
from tensura_common import TenSuraConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner
from yt_common.automation import SelfRunner, Zone
from yt_common.chapters import Chapter
from yt_common.source import FileTrim, SimpleSource
@ -15,7 +15,7 @@ from typing import List, Tuple
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraConfig = TenSuraConfig(EPNUM)
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210326][Tensei Shitara Slime Datta Ken 2nd Season][Vol.1]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00011.m2ts"), (24, -25))
@ -35,6 +35,11 @@ NOD3: List[Range] = [
(33927, 34046),
]
ZONES: List[Zone] = [
]
ZONES += [Zone(r, 0.75) for r in NOD3 if isinstance(r, tuple)]
AA_STRONG: List[Range] = [
(11640, 11685),
(12437, 12488),
@ -85,6 +90,6 @@ def filter() -> vs.VideoNode:
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS)
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS, zones=ZONES)
else:
filter()

View File

@ -0,0 +1,74 @@
import vapoursynth as vs
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner, Zone
from yt_common.chapters import Chapter
from yt_common.source import FileTrim, SimpleSource
from lvsfunc.mask import BoundingBox
from lvsfunc.misc import replace_ranges
from lvsfunc.types import Range
from typing import List, Tuple
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210526][Tensei Shitara Slime Datta Ken 2nd Season][Vol.2]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00006.m2ts"), (24, -50))
)
CHAPTERS: List[Chapter] = [
Chapter("Intro", 0),
Chapter("OP", 408),
Chapter("Part A", 2566),
Chapter("Part B", 14745),
Chapter("ED", 31768),
Chapter("Next", 33926),
]
NOD3: List[Range] = [
(12870, 13394),
(33926, 34045),
]
ZONES: List[Zone] = [
]
ZONES += [Zone(r, 0.75) for r in NOD3 if isinstance(r, tuple)]
AA_STRONG: List[Range] = [
(15848, 15925),
]
SANGNOM: List[Tuple[Range, List[BoundingBox]]] = [
]
DEBAND_NUCLEAR: List[Range] = [
]
core = vs.core
def filter() -> vs.VideoNode:
src = SOURCE.source()
ef = edgefix(src)
den = denoise(ef)
descaled = descale(den)
deb = deband(descaled, nuclear=DEBAND_NUCLEAR)
deb = replace_ranges(deb, src, NOD3)
aa = antialias(deb, strong=AA_STRONG, sangnom=SANGNOM)
grain = regrain(aa)
final = finalize(grain)
src.set_output(1)
final.set_output(0)
return final
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS, zones=ZONES)
else:
filter()

View File

@ -0,0 +1,77 @@
import vapoursynth as vs
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner, Zone
from yt_common.chapters import Chapter
from yt_common.source import FileTrim, SimpleSource
from lvsfunc.mask import BoundingBox
from lvsfunc.misc import replace_ranges
from lvsfunc.types import Range
from typing import List, Tuple
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210526][Tensei Shitara Slime Datta Ken 2nd Season][Vol.2]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00007.m2ts"), (None, -51))
)
CHAPTERS: List[Chapter] = [
Chapter("Intro", 0),
Chapter("OP", 3237),
Chapter("Part A", 5395),
Chapter("Part B", 16255),
Chapter("ED", 31767),
Chapter("Next", 33925),
]
NOD3: List[Range] = [
(20345, 20471),
(23716, 23971),
(26714, 26869),
(33925, 34044),
]
ZONES: List[Zone] = [
]
ZONES += [Zone(r, 0.75) for r in NOD3 if isinstance(r, tuple)]
AA_STRONG: List[Range] = [
(8606, 8677),
(26138, 26245),
]
SANGNOM: List[Tuple[Range, List[BoundingBox]]] = [
]
DEBAND_NUCLEAR: List[Range] = [
]
core = vs.core
def filter() -> vs.VideoNode:
src = SOURCE.source()
ef = edgefix(src)
den = denoise(ef)
descaled = descale(den)
deb = deband(descaled, nuclear=DEBAND_NUCLEAR)
deb = replace_ranges(deb, src, NOD3)
aa = antialias(deb, strong=AA_STRONG, sangnom=SANGNOM)
grain = regrain(aa)
final = finalize(grain)
src.set_output(1)
final.set_output(0)
return final
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS, zones=ZONES)
else:
filter()

View File

@ -0,0 +1,67 @@
import vapoursynth as vs
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner
from yt_common.chapters import Chapter
from yt_common.source import FileTrim, SimpleSource
from lvsfunc.mask import BoundingBox
from lvsfunc.misc import replace_ranges
from lvsfunc.types import Range
from typing import List, Tuple
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210526][Tensei Shitara Slime Datta Ken 2nd Season][Vol.2]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00008.m2ts"), (None, -50))
)
CHAPTERS: List[Chapter] = [
Chapter("Intro", 0),
Chapter("OP", 384),
Chapter("Part A", 2542),
Chapter("Part B", 17766),
Chapter("ED", 31768),
Chapter("Next", 33926),
]
NOD3: List[Range] = [
(33926, 34045),
]
AA_STRONG: List[Range] = [
]
SANGNOM: List[Tuple[Range, List[BoundingBox]]] = [
]
DEBAND_NUCLEAR: List[Range] = [
]
core = vs.core
def filter() -> vs.VideoNode:
src = SOURCE.source()
ef = edgefix(src)
den = denoise(ef)
descaled = descale(den)
deb = deband(descaled, nuclear=DEBAND_NUCLEAR)
deb = replace_ranges(deb, src, NOD3)
aa = antialias(deb, strong=AA_STRONG, sangnom=SANGNOM)
grain = regrain(aa)
final = finalize(grain)
src.set_output(1)
final.set_output(0)
return final
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS)
else:
filter()

View File

@ -0,0 +1,87 @@
import vapoursynth as vs
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner
from yt_common.chapters import Chapter, Edition
from yt_common.source import FileTrim, SimpleSource
from lvsfunc.mask import BoundingBox
from lvsfunc.misc import replace_ranges
from lvsfunc.types import Range
from typing import List, Tuple
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210526][Tensei Shitara Slime Datta Ken 2nd Season][Vol.2]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource([
FileTrim(os.path.join(BDMV, "00009.m2ts"), (None, None)),
FileTrim(os.path.join(BDMV, "00010.m2ts"), (None, -49)),
FileTrim(os.path.join(BDMV, "00016.m2ts"), (13348, 15699)),
FileTrim(os.path.join(BDMV, "00016.m2ts"), (17721, 17982)),
], asrc=[
# NC version has different (quieter) audio, so make sure we use the regular version
FileTrim(os.path.join(BDMV, "00009.m2ts"), (None, None)),
FileTrim(os.path.join(BDMV, "00010.m2ts"), (None, -49)),
FileTrim(os.path.join(BDMV, "00010.m2ts"), (13348, 15699)),
FileTrim(os.path.join(BDMV, "00010.m2ts"), (17721, 17982)),
])
EDITIONS: List[Edition] = [
Edition(chapters=[
Chapter("Intro", 0),
Chapter("OP", 2134),
Chapter("Part A", 4293),
Chapter("Part B", 16065),
Chapter("Next", 34047, 34167),
], default=True, ordered=True),
Edition(chapters=[
Chapter("Intro", 0),
Chapter("OP", 2134),
Chapter("Part A", 4293),
Chapter("Part B", 16065, 29413),
Chapter("Part B - NC", 34167, 36518),
Chapter("Part B", 31764, 33786),
Chapter("Part B - NC", 36518, -1),
Chapter("Next", 34047, 34167),
], default=False, ordered=True),
]
NOD3: List[Range] = [
(34047, 34166),
]
AA_STRONG: List[Range] = [
]
SANGNOM: List[Tuple[Range, List[BoundingBox]]] = [
]
DEBAND_NUCLEAR: List[Range] = [
]
core = vs.core
def filter() -> vs.VideoNode:
src = SOURCE.source()
ef = edgefix(src)
den = denoise(ef)
descaled = descale(den)
deb = deband(descaled, nuclear=DEBAND_NUCLEAR)
deb = replace_ranges(deb, src, NOD3)
aa = antialias(deb, strong=AA_STRONG, sangnom=SANGNOM)
grain = regrain(aa)
final = finalize(grain)
src.set_output(1)
final.set_output(0)
return final
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter, editions=EDITIONS)
else:
filter()

View File

@ -0,0 +1,101 @@
import vapoursynth as vs
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner, Zone
from yt_common.chapters import Chapter, Edition
from yt_common.source import FileTrim, SimpleSource
from lvsfunc.mask import BoundingBox
from lvsfunc.misc import replace_ranges
from lvsfunc.types import Range
from typing import List, Tuple
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210526][Tensei Shitara Slime Datta Ken 2nd Season][Vol.2]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource([
FileTrim(os.path.join(BDMV, "00011.m2ts"), (None, -49)),
FileTrim(os.path.join(BDMV, "00017.m2ts"), (None, 3158)),
FileTrim(os.path.join(BDMV, "00017.m2ts"), (33342, 33927)),
], asrc=[
# NC version has different (quieter) audio, so make sure we use the regular version
FileTrim(os.path.join(BDMV, "00011.m2ts"), (None, -49)),
FileTrim(os.path.join(BDMV, "00011.m2ts"), (None, 3158)),
FileTrim(os.path.join(BDMV, "00011.m2ts"), (33342, 33927)),
])
EDITIONS: List[Edition] = [
Edition(chapters=[
Chapter("Intro", 0),
Chapter("Part A", 840),
Chapter("Part B", 13980),
Chapter("Next", 33927, 34047),
], default=True, ordered=True),
Edition(chapters=[
Chapter("Intro - NC", 34047),
Chapter("Part A - NC", 34887, 37205),
Chapter("Part A", 3158),
Chapter("Part B", 13980, 33342),
Chapter("Part B - NC", 37205, -1),
Chapter("Next", 33927, 34047),
], default=False, ordered=True),
]
NOD3: List[Range] = [
(4862, 5023),
(8264, 8692),
(10200, 10576),
(17993, 18828),
(33927, 34046),
]
NODEN: List[Range] = [
(16484, 17992),
(18829, 19528),
]
ZONES: List[Zone] = [
]
ZONES += [Zone(r, 0.75) for r in NOD3 + NODEN if isinstance(r, tuple)]
AA_STRONG: List[Range] = [
(14544, 14588),
(14716, 14763),
(15493, 15633),
(19529, 19600),
]
SANGNOM: List[Tuple[Range, List[BoundingBox]]] = [
]
DEBAND_NUCLEAR: List[Range] = [
]
core = vs.core
def filter() -> vs.VideoNode:
src = SOURCE.source()
ef = edgefix(src)
den = denoise(ef)
replace_ranges(den, src, NODEN)
descaled = descale(den)
deb = deband(descaled, nuclear=DEBAND_NUCLEAR)
deb = replace_ranges(deb, src, NOD3)
aa = antialias(deb, strong=AA_STRONG, sangnom=SANGNOM)
grain = regrain(aa)
final = finalize(grain)
src.set_output(1)
final.set_output(0)
return final
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter, editions=EDITIONS, zones=ZONES)
else:
filter()

View File

@ -0,0 +1,81 @@
import vapoursynth as vs
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner, Zone
from yt_common.chapters import Chapter
from yt_common.source import FileTrim, SimpleSource
from lvsfunc.mask import BoundingBox
from lvsfunc.misc import replace_ranges
from lvsfunc.types import Range
from typing import List, Tuple
import os
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(EPNUM)
BDMV: str = "../bdmv/[BDMV][210526][Tensei Shitara Slime Datta Ken 2nd Season][Vol.2]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00012.m2ts"), (None, -26))
)
CHAPTERS: List[Chapter] = [
Chapter("Intro", 0),
Chapter("OP", 1272),
Chapter("Part A", 3429),
Chapter("Part B", 10549),
Chapter("ED", 31768),
]
NOD3: List[Range] = [
(3705, 3733),
(5329, 5360),
(7234, 7449),
]
NODEN: List[Range] = [
(3734, 3842),
(5361, 6372),
(26183, 27055),
]
ZONES: List[Zone] = [
]
ZONES += [Zone(r, 0.75) for r in NOD3 + NODEN if isinstance(r, tuple)]
AA_STRONG: List[Range] = [
(9805, 10155),
]
SANGNOM: List[Tuple[Range, List[BoundingBox]]] = [
]
DEBAND_NUCLEAR: List[Range] = [
]
core = vs.core
def filter() -> vs.VideoNode:
src = SOURCE.source()
ef = edgefix(src)
den = denoise(ef)
den = replace_ranges(den, src, NODEN)
descaled = descale(den)
deb = deband(descaled, nuclear=DEBAND_NUCLEAR)
deb = replace_ranges(deb, src, NOD3)
aa = antialias(deb, strong=AA_STRONG, sangnom=SANGNOM)
grain = regrain(aa)
final = finalize(grain)
src.set_output(1)
final.set_output(0)
return final
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS, zones=ZONES)
else:
filter()

View File

@ -0,0 +1,60 @@
import vapoursynth as vs
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner
from yt_common.source import FileTrim, SimpleSource
from lvsfunc.mask import BoundingBox
from lvsfunc.misc import replace_ranges
from lvsfunc.types import Range
from typing import List, Tuple
import os
DESC: str = os.path.basename(os.path.splitext(__file__)[0])
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(DESC)
BDMV: str = "../bdmv/[BDMV][210526][Tensei Shitara Slime Datta Ken 2nd Season][Vol.2]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00015.m2ts"), (24, -24))
)
NOD3: List[Range] = [
]
NODEN: List[Range] = [
]
AA_STRONG: List[Range] = [
]
SANGNOM: List[Tuple[Range, List[BoundingBox]]] = [
]
DEBAND_NUCLEAR: List[Range] = [
]
core = vs.core
def filter() -> vs.VideoNode:
src = SOURCE.source()
ef = edgefix(src)
den = denoise(ef)
den = replace_ranges(den, src, NODEN)
descaled = descale(den)
deb = deband(descaled, nuclear=DEBAND_NUCLEAR)
deb = replace_ranges(deb, src, NOD3)
aa = antialias(deb, strong=AA_STRONG, sangnom=SANGNOM)
grain = regrain(aa)
final = finalize(grain)
src.set_output(1)
final.set_output(0)
return final
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter)
else:
filter()

View File

@ -0,0 +1,60 @@
import vapoursynth as vs
from tensura_common import TenSuraS2BDConfig, antialias, deband, denoise, descale, edgefix, finalize, regrain
from yt_common.automation import SelfRunner
from yt_common.source import FileTrim, SimpleSource
from lvsfunc.mask import BoundingBox
from lvsfunc.misc import replace_ranges
from lvsfunc.types import Range
from typing import List, Tuple
import os
DESC: str = os.path.basename(os.path.splitext(__file__)[0])
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(DESC)
BDMV: str = "../bdmv/[BDMV][210526][Tensei Shitara Slime Datta Ken 2nd Season][Vol.2]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00014.m2ts"), (24, -24))
)
NOD3: List[Range] = [
]
NODEN: List[Range] = [
]
AA_STRONG: List[Range] = [
]
SANGNOM: List[Tuple[Range, List[BoundingBox]]] = [
]
DEBAND_NUCLEAR: List[Range] = [
]
core = vs.core
def filter() -> vs.VideoNode:
src = SOURCE.source()
ef = edgefix(src)
den = denoise(ef)
den = replace_ranges(den, src, NODEN)
descaled = descale(den)
deb = deband(descaled, nuclear=DEBAND_NUCLEAR)
deb = replace_ranges(deb, src, NOD3)
aa = antialias(deb, strong=AA_STRONG, sangnom=SANGNOM)
grain = regrain(aa)
final = finalize(grain)
src.set_output(1)
final.set_output(0)
return final
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter)
else:
filter()

View File

@ -0,0 +1,99 @@
import vapoursynth as vs
from tensura_common import (TenSuraS2BDConfig, antialias, deband, denoise, descale,
edgefix, finalize, megurumono_scenefilter, regrain)
from yt_common.automation import SelfRunner, Zone
from yt_common.chapters import Chapter
from yt_common.source import FileTrim, SimpleSource
from lvsfunc.mask import BoundingBox
from lvsfunc.misc import replace_ranges
from lvsfunc.types import Range
from typing import List, Tuple
import os
DESC: str = os.path.basename(os.path.splitext(__file__)[0])
CONFIG: TenSuraS2BDConfig = TenSuraS2BDConfig(DESC)
BDMV: str = "../bdmv/[BDMV][210326][Tensei Shitara Slime Datta Ken 2nd Season][Vol.1]/BDMV/STREAM"
SOURCE: SimpleSource = SimpleSource(
FileTrim(os.path.join(BDMV, "00013.m2ts"), (24, -24))
)
MEGURUMONO: Tuple[int, int] = (2873, 5034)
CHAPTERS: List[Chapter] = [
Chapter("Intro", 0),
Chapter("OP", MEGURUMONO[0]),
Chapter("Part A", MEGURUMONO[1]+1),
Chapter("Part B", 22561),
Chapter("ED", 31883),
]
NOD3: List[Range] = [
]
NODEN: List[Range] = [
(21749, 21849),
]
ZONES: List[Zone] = [
]
ZONES += [Zone(r, 0.75) for r in NOD3 + NODEN if isinstance(r, tuple)]
AA_STRONG: List[Range] = [
]
SANGNOM: List[Tuple[Range, List[BoundingBox]]] = [
]
DEBAND_STRONG: List[Range] = [
(0, 500),
(11519, 11615),
(14845, 14906),
(15137, 15234),
(15667, 15817),
(18848, 19536),
(19897, 20004),
(20749, 20814),
(21013, 21340),
(21485, 21748),
(22812, 22894),
(26719, 26769),
(31307, 31426),
(31596, 31882),
]
DEBAND_NUCLEAR: List[Range] = [
]
core = vs.core
def filter() -> vs.VideoNode:
src = SOURCE.source()
ef = edgefix(src)
den = denoise(ef)
den = replace_ranges(den, src, NODEN)
descaled = descale(den)
deb = deband(descaled, strong=DEBAND_STRONG, nuclear=DEBAND_NUCLEAR)
deb = replace_ranges(deb, src, NOD3)
aa = antialias(deb, strong=AA_STRONG, sangnom=SANGNOM)
grain = regrain(aa)
scenefilter = grain
if MEGURUMONO:
megurumono = megurumono_scenefilter(src, MEGURUMONO[0])
scenefilter = replace_ranges(scenefilter, megurumono, MEGURUMONO)
final = finalize(scenefilter)
src.set_output(1)
final.set_output(0)
return final
if __name__ == "__main__":
SelfRunner(CONFIG, SOURCE, filter, chapters=CHAPTERS, zones=ZONES)
else:
filter()

View File

@ -1,2 +1,3 @@
from .config import TenSuraConfig # noqa: F401
from .filter import antialias, deband, denoise, descale, edgefix, finalize, regrain # noqa: F401
from .config import TenSuraS2Config, TenSuraS2BDConfig, TenSuraS1BDConfig # noqa: F401
from .filter import (antialias, deband, denoise, descale, edgefix, finalize, # noqa: F401
megurumono_scenefilter, regrain)

View File

@ -1,21 +1,34 @@
from yt_common.config import Config, FlacMixin
from yt_common.config import Config, FlacMixin, OpusMixin
from typing import Union
import os
TITLE: str = "TenSura S2"
TITLE_LONG: str = "Tensei Shitara Slime Datta Ken S2"
RESOLUTION: int = 1080
DATAPATH: str = os.path.dirname(__file__)
class TenSuraConfig(FlacMixin, Config):
class TenSuraS1BDConfig(OpusMixin, Config):
def __init__(self, desc: Union[str, int]) -> None:
super().__init__(
desc,
TITLE,
TITLE_LONG,
"TenSura",
"Tensei Shitara Slime Datta Ken",
RESOLUTION,
DATAPATH
)
class TenSuraS2Config(Config):
def __init__(self, desc: Union[str, int]) -> None:
super().__init__(
desc,
"TenSura S2",
"Tensei Shitara Slime Datta Ken S2",
RESOLUTION,
DATAPATH
)
class TenSuraS2BDConfig(FlacMixin, TenSuraS2Config):
pass

View File

@ -101,3 +101,22 @@ def regrain(clip: vs.VideoNode) -> vs.VideoNode:
def finalize(clip: vs.VideoNode) -> vs.VideoNode:
return depth(clip, 10)
def megurumono_scenefilter(clip: vs.VideoNode, start: Optional[int] = None) -> vs.VideoNode:
if start is None:
return clip
DEBAND_STRONG: List[Range] = [
(start+12, start+256),
(start+778, start+1007),
(start+1025, start+1059),
(start+1217, start+1322),
(start+1368, start+1437),
]
ef = edgefix(clip)
den = denoise(ef)
descaled = descale(den)
deb = deband(descaled, strong=DEBAND_STRONG)
aa = antialias(deb)
grain = regrain(aa)
return grain

View File

@ -1 +1 @@
x265 --input - --y4m --input-depth 10 --output-depth 10 --input-csp i420 --profile main10 --colormatrix bt709 --colorprim bt709 --transfer bt709 --preset slower --rc-lookahead 72 --keyint 360 --min-keyint 23 --subme 5 --qcomp 0.7 --crf 15 --aq-mode 3 --aq-strength 0.9 --bframes 16 --psy-rd 2.0 --psy-rdoq 1.8 --rdoq-level 1 --deblock -2:-2 --no-sao --no-open-gop --no-strong-intra-smoothing --frames {frames:d} --output {filename:s}.h265
x265 --input - --y4m --input-depth 10 --output-depth 10 --input-csp i420 --profile main10 --colormatrix bt709 --colorprim bt709 --transfer bt709 --preset slower --rc-lookahead 72 --keyint 360 --min-keyint 23 --subme 5 --qcomp 0.7 --crf 15 --aq-mode 3 --aq-strength 0.9 --bframes 16 --psy-rd 2.0 --psy-rdoq 1.8 --rdoq-level 1 --deblock -2:-2 --no-sao --no-open-gop --no-strong-intra-smoothing --frames {frames:d} $QPFILE $ZONES --output {filename:s}.h265

View File

@ -11,7 +11,7 @@ import tempfile
from lvsfunc.render import clip_async_render
from typing import Any, BinaryIO, Callable, List, Optional, Sequence, Set, Tuple, cast
from typing import Any, BinaryIO, Callable, List, NamedTuple, Optional, Sequence, Set, Tuple, cast
from .chapters import Chapter, Edition, make_chapters, make_qpfile
from .config import Config
@ -39,6 +39,11 @@ def forward_signal(signum: int, frame: Any, process: Any) -> None:
process.send_signal(signum)
class Zone(NamedTuple):
r: Tuple[int, int]
b: float
class Encoder():
clip: vs.VideoNode
@ -58,6 +63,7 @@ class Encoder():
self._get_encoder_settings(settings_path)
def encode(self, clip: vs.VideoNode, filename: str, start: int = 0, end: int = 0,
zones: Optional[List[Zone]] = None, qpfile: Optional[str] = None,
timecode_file: Optional[str] = None, want_timecodes: bool = False) -> Tuple[str, List[float]]:
end = end if end != 0 else clip.num_frames
want_timecodes = True if timecode_file else want_timecodes
@ -68,7 +74,25 @@ class Encoder():
log.warn("Existing output detected, skipping encode!")
return outfile, []
params = [p.format(frames=end-start, filename=filename, qpfile="qpfile.txt") for p in self.params]
params: List[str] = []
for p in self.params:
if p == "$ZONES":
if zones:
zones.sort(key=lambda z: z.r[0])
params.append("--zones")
zargs: List[str] = []
for z in zones:
if z.r[0] - start >= 0 and z.r[0] < end:
s = z.r[0] - start
e = z.r[1] - start
e = e if e < end - start else end - start - 1
zargs.append(f"{s},{e},b={z.b}")
params.append("/".join(zargs))
elif p == "$QPFILE":
if qpfile:
params += ["--qpfile", qpfile]
else:
params.append(p.format(frames=end-start, filename=filename, qpfile="qpfile.txt"))
log.status("--- RUNNING ENCODE ---")
@ -171,6 +195,7 @@ class SelfRunner():
audio_file: str
timecodes: List[float]
timecode_file: Optional[str]
qpfile: Optional[str]
encoder: Encoder
audio: AudioGetter
@ -180,11 +205,13 @@ class SelfRunner():
def __init__(self, config: Config, source: FileSource, final_filter: Callable[[], vs.VideoNode],
workraw_filter: Optional[Callable[[], vs.VideoNode]] = None,
chapters: Optional[List[Chapter]] = None,
editions: Optional[List[Edition]] = None) -> None:
editions: Optional[List[Edition]] = None,
zones: Optional[List[Zone]] = None) -> None:
self.config = config
self.src = source
self.video_clean = False
self.audio_clean = False
self.qpfile = None
parser = argparse.ArgumentParser(description=f"Encode {self.config.title} {self.config.desc}")
if workraw_filter:
@ -207,8 +234,10 @@ class SelfRunner():
self.workraw = args.workraw if workraw_filter else False
self.profile = "workraw" if self.workraw else "final"
self.profile = args.profile or self.profile
self.suffix = args.suffix if args.suffix is not None else "workraw" if self.workraw else "premux"
self.suffix = args.profile or self.suffix
self.suffix = args.suffix if args.suffix is not None \
else "workraw" if self.workraw \
else args.profile if args.profile \
else "premux"
self.clip = workraw_filter() if workraw_filter and self.workraw else final_filter()
@ -258,9 +287,9 @@ class SelfRunner():
log.status("Comparison generated.")
return
open("qpfile.txt", "w").close() # guarantee qpfile is created/cleared as appropriate
if (editions or chapters) and (start == 0 and end == self.clip.num_frames):
make_qpfile("qpfile.txt", chapters=chapters, editions=editions)
self.qpfile = "qpfile.txt"
make_qpfile(self.qpfile, chapters=chapters, editions=editions)
settings_path = os.path.join(self.config.datapath, f"{self.profile}-settings")
if not os.path.isfile(settings_path):
@ -272,7 +301,7 @@ class SelfRunner():
if self.clip.fps_den == 0 else None
self.video_file, self.timecodes = self.encoder.encode(self.clip,
f"{self.config.desc}_{self.suffix}_{start}_{end}",
start, end, self.timecode_file)
start, end, zones, self.qpfile, self.timecode_file)
# calculate timecodes if cfr and we didn't generate any (we shouldn'tve)
self.timecodes = [round(float(1e9*f*(1/self.clip.fps)))/1e9 for f in range(0, self.clip.num_frames + 1)] \

View File

@ -112,6 +112,11 @@ def make_qpfile(qpfile: str,
chapters: Optional[List[Chapter]] = None,
editions: Optional[List[Edition]] = None) -> None:
editions = _to_edition(chapters=chapters, editions=editions)
frames = set(c.frame for e in editions for c in e.chapters)
frames = set()
for e in editions:
for c in e.chapters:
frames.add(c.frame)
if c.end_frame and c.end_frame > 0:
frames.add(c.end_frame)
with open(qpfile, "w", encoding="utf-8") as qp:
qp.writelines([f"{f} I\n" for f in sorted(list(frames))])