コード例 #1
0
def generate_comparison(src: FileInfo, enc: Union[os.PathLike[str], str], flt: vs.VideoNode) -> None:
    make_comps(
        {
            'source': src.clip_cut,
            'filtered': flt,
            'encode': source(str(enc), force_lsmas=True, cachedir='')
        },
        num=int(src.clip_cut.num_frames / 500) if src.clip_cut.num_frames > 5000 else 50,
        collection_name=f'[Kaleido-subs] {src.name} Encode test',
        path=f'.comps/{src.name}', force_bt709=True, slowpics=True, public=False
    )
コード例 #2
0
from vardautomation import FileInfo, PresetAAC, PresetBD, VPath

from project_module import enc, flt

core = vs.core

shader_file = Path(r'assets/FSRCNNX_x2_56-16-4-1.glsl')
if not shader_file.exists:
    hookpath = r"mpv/shaders/FSRCNNX_x2_56-16-4-1.glsl"
    shader_file = os.path.join(os.getenv("APPDATA"), hookpath)

# Sources
JP_BD = FileInfo(
    r'BDMV/[BDMV][210728][Yuru Camp Season 2][Vol.3 Fin]/BD/BDMV/STREAM/00005.m2ts',
    [(24, -24)],
    idx=lambda x: source(x, force_lsmas=True, cachedir=''),
    preset=[PresetBD, PresetAAC])
JP_NCOP = FileInfo(
    r'BDMV/[BDMV][210728][Yuru Camp Season 2][Vol.3 Fin]/BD/BDMV/STREAM/00013.m2ts',
    [(24, -24)],
    idx=lambda x: source(x, force_lsmas=True, cachedir=''))
JP_NCED = FileInfo(
    r'BDMV/[BDMV][210728][Yuru Camp Season 2][Vol.3 Fin]/BD/BDMV/STREAM/00014.m2ts',
    [(24, -24)],
    idx=lambda x: source(x, force_lsmas=True, cachedir=''))
JP_BD.name_file_final = VPath(f"premux/{JP_BD.name} (Premux).mkv")
JP_BD.a_src_cut = VPath(JP_BD.name)
JP_BD.do_qpfile = True

# OP/ED scenefiltering
opstart = 2882
コード例 #3
0
from typing import Optional, Sequence, Tuple, Union

import vapoursynth as vs
from lvsfunc.misc import source
from vardautomation import (JAPANESE, FileInfo, MplsReader, PresetAAC,
                            PresetBD, PresetChapXML, VPath)

from project_module import encoder as enc, flt

core = vs.core
core.num_threads = 4

# Sources
JP_BD = FileInfo(r'BDMV//00003.m2ts', (24, -24),
                 idx=lambda x: source(x, cachedir=''),
                 preset=[PresetBD, PresetAAC, PresetChapXML])
JP_BD_NCOP = FileInfo(r'BDMV/120926_JOSHIRAKU_VOL1/BDMV/STREAM/00001.m2ts',
                      (24, -24),
                      idx=lambda x: source(x, cachedir=''))
JP_BD_NCED = FileInfo(r'BDMV/120926_JOSHIRAKU_VOL1/BDMV/STREAM/00002.m2ts',
                      (24, -24),
                      idx=lambda x: source(x, cachedir=''))
JP_BD_03 = FileInfo(r'BDMV/121024_JOSHIRAKU_VOL2/BDMV/STREAM/00000.m2ts',
                    (24, 2182),
                    idx=lambda x: source(x, cachedir=''))
JP_BD.name_file_final = VPath(fr"premux/{JP_BD.name} (Premux).mkv")
JP_BD.a_src_cut = VPath(f"{JP_BD.name}_cut.aac")
JP_BD.do_qpfile = True

# OP/ED Variables
opstart = 0
コード例 #4
0
import vapoursynth as vs
from lvsfunc.misc import source
from vardautomation import (JAPANESE, FileInfo, MplsReader, PresetAAC,
                            PresetBD, VPath)

from project_module import enc, flt

core = vs.core
core.num_threads = 4

EP_NUM = __file__[-5:-3]


# Sources
JP_BD = FileInfo(r'BDMV/[BDMV][210224][Majo no Tabitabi][Blu-Ray BOX下巻]/BDMV/STREAM/00003.m2ts',
                 (24, -24), idx=lambda x: source(x, force_lsmas=True, cachedir=''),
                 preset=[PresetBD, PresetAAC])
JP_BD_NCED = FileInfo(r'BDMV/[BDMV][アニメ][210127][MAJO_NO_TABITABI_1][Blu-Ray BOX 上]/BDMV/STREAM/00016.m2ts',
                     (24, -24), idx=lambda x: source(x, force_lsmas=True, cachedir=''))
JP_WEB = FileInfo(fr'WebSrc/Wandering Witch Elaina E{EP_NUM} [1080p][AAC][JapDub][GerSub][Web-DL].mkv',
                  (None, None), idx=lambda x: source(x, force_lsmas=True, cachedir=''))
JP_BD.name_file_final = VPath(f"premux/{JP_BD.name} (Premux).mkv")
JP_BD.a_src_cut = VPath(f"{JP_BD.name}_cut.aac")
JP_BD.do_qpfile = True


# Chapter creation
CHAPTERS = MplsReader(r"BDMV/[BDMV][210224][Majo no Tabitabi][Blu-Ray BOX下巻]", lang=JAPANESE) \
    .get_playlist()[1].mpls_chapters[int(EP_NUM)-13].to_chapters()
CHAP_NAMES: Sequence[Optional[str]] = ['Intro', 'OP', 'Part A', 'Part B', 'ED']
コード例 #5
0
from project_module import encoder as enc
from project_module import flt

core = vs.core


shader_file = 'assets/FSRCNNX_x2_16-0-4-1.glsl'
if not Path(shader_file).exists():
    hookpath = r"mpv/shaders/FSRCNNX_x2_16-0-4-1.glsl"
    shader_file = os.path.join(str(os.getenv("APPDATA")), hookpath)


# Sources
JP_BD = FileInfo(r"E:/src/Idol Time PriPara/IDOL_TIME_PRIPARA_BDBOX4_D2/BDMV/STREAM/00016.m2ts", (24, -24),
                 idx=lambda x: source(x, force_lsmas=True, cachedir=''), preset=[PresetBD, PresetFLAC])
JP_BD.name_file_final = VPath(fr"premux/{JP_BD.name} (Premux).mkv")
JP_BD.a_src_cut = JP_BD.name
JP_BD.do_qpfile = True


zones: Dict[Tuple[int, int], Dict[str, Any]] = {  # Zones for x265
}


def filterchain() -> Union[vs.VideoNode, Tuple[vs.VideoNode, ...]]:
    """Main VapourSynth filterchain"""
    import havsfunc as haf
    import lvsfunc as lvf
    import vardefunc as vdf
    from ccd import ccd
コード例 #6
0
def main() -> Union[vs.VideoNode, Tuple[vs.VideoNode, ...]]:
    """Vapoursynth filtering"""
    # Don't worry, this script is barely readable anymore even for me
    import rekt
    from awsmfunc import bbmod
    from havsfunc import ContraSharpening
    from lvsfunc.aa import upscaled_sraa
    from lvsfunc.comparison import stack_compare
    from lvsfunc.mask import BoundingBox
    from lvsfunc.util import replace_ranges
    from vardefunc import dcm
    from vardefunc.deband import dumb3kdb
    from vardefunc.mask import FreyChen
    from vsutil import depth, get_y, insert_clip

    src = JP_BD.clip_cut
    b = core.std.BlankClip(src, length=1)

    if opstart is not False:
        src_NCOP = NCOP.clip_cut
        op_scomp = stack_compare(
            src[opstart:opstart + src_NCOP.num_frames - 1] + b,
            src_NCOP[:-op_offset] + b,
            make_diff=True)  # noqa
    if edstart is not False:
        src_NCED = NCED.clip_cut
        #ed_scomp = stack_compare(src[edstart:edstart+src_NCED.num_frames-1]+b, src_NCED[:-ed_offset]+b, make_diff=True)  # noqa

    # Masking credits
    op_mask = dcm(
        src, src[opstart:opstart+src_NCOP.num_frames], src_NCOP,
        start_frame=opstart, thr=25, prefilter=True) if opstart is not False \
        else get_y(core.std.BlankClip(src))
    ed_mask = dcm(
        src, src[edstart:edstart+src_NCED.num_frames], src_NCED,
        start_frame=edstart, thr=25, prefilter=True) if edstart is not False \
        else get_y(core.std.BlankClip(src))
    credit_mask = core.std.Expr([op_mask, ed_mask], expr='x y +')
    credit_mask = depth(credit_mask, 16).std.Binarize()

    # Fixing an animation f**k-up
    for f in op_replace:
        src = insert_clip(src, src[f], f - 1)

    # Edgefixing
    ef = rekt.rektlvls(
        src,
        prot_val=[16, 235],
        min=16,
        max=235,
        rownum=[0, src.height - 1],
        rowval=[16, 16],
        colnum=[0, src.width - 1],
        colval=[16, 16],
    )

    bb_y = bbmod(ef,
                 left=1,
                 top=1,
                 right=1,
                 bottom=1,
                 thresh=32,
                 y=True,
                 u=False,
                 v=False)
    bb_uv = bbmod(bb_y,
                  left=2,
                  top=2,
                  right=2,
                  bottom=2,
                  y=False,
                  u=True,
                  v=True)
    bb32 = depth(bb_uv, 32)

    # --- Very specific filtering that should probably be removed for future episodes entirely
    # Fading for some... well, fades.
    fade = flt.fader(bb32, start_frame=4437, end_frame=4452)
    fade = flt.fader(fade, start_frame=18660, end_frame=18697)

    # Different sport names
    rkt_aa_ranges: Union[Union[int, None, Tuple[Optional[int], Optional[int]]],
                         List[Union[int, None,
                                    Tuple[Optional[int],
                                          Optional[int]]]], None] = [  # noqa
                                              (8824, 8907), (9828, 9911),
                                              (10995, 11078), (11904, 12010)
                                          ]

    rkt_aa = rekt.rekt_fast(fade,
                            fun=lambda x: upscaled_sraa(x),
                            top=854,
                            left=422,
                            bottom=60,
                            right=422)
    rkt_aa = replace_ranges(fade, rkt_aa, rkt_aa_ranges)

    # QP GET!
    rkt_aa2_ranges: Union[Union[int, None, Tuple[Optional[int],
                                                 Optional[int]]],
                          List[Union[int, None,
                                     Tuple[Optional[int],
                                           Optional[int]]]], None] = [  # noqa
                                               (26333, 26333), (28291, 28344),
                                               (30271, 30364)
                                           ]
    rkt_aa2 = rekt.rekt_fast(rkt_aa,
                             fun=lambda x: upscaled_sraa(x),
                             top=714,
                             left=354,
                             bottom=224,
                             right=354)
    rkt_aa2 = replace_ranges(fade, rkt_aa, rkt_aa2_ranges)

    # Table stuff
    rkt_aa3_ranges: Union[Union[int, None, Tuple[Optional[int],
                                                 Optional[int]]],
                          List[Union[int, None,
                                     Tuple[Optional[int],
                                           Optional[int]]]], None] = [  # noqa
                                               (32797, 32952)
                                           ]
    rkt_aa3 = rekt.rekt_fast(rkt_aa2,
                             fun=lambda x: upscaled_sraa(x),
                             top=488,
                             left=312,
                             bottom=390,
                             right=850)
    rkt_aa3 = replace_ranges(fade, rkt_aa2, rkt_aa3_ranges)

    rkt_aa = rkt_aa3

    # Clipping error Nyatalante/Achilles
    fixed_frame = source(
        JP_BD.workdir.to_str() + r"/assets/01/FGCBD_01_8970_fixed.png", rkt_aa)
    fix_error = replace_ranges(rkt_aa, fixed_frame, [(8968, 8970)])

    sp_out32 = fix_error
    sp_out16 = depth(sp_out32, 16)

    # Rescaling
    l_mask = FreyChen().get_mask(get_y(sp_out16)).morpho.Close(size=6)
    l_mask = core.std.Binarize(l_mask, 24 << 8).std.Maximum().std.Maximum()
    scaled, credit_mask = flt.rescaler(sp_out32,
                                       height=720,
                                       shader_file=shader)
    scaled = core.std.MaskedMerge(sp_out16, scaled, l_mask)
    scaled = core.std.MaskedMerge(scaled, sp_out16, credit_mask)

    # Denoising
    denoise = flt.multi_denoise(scaled, l_mask)

    # Anti-aliasing
    aa_clamped = flt.clamp_aa(denoise, strength=3.0)
    aa_rfs = replace_ranges(denoise, aa_clamped, aa_ranges)

    # Fix edges because they get f****d during the denoising and AA stages
    box = BoundingBox((1, 1), (src.width - 2, src.height - 2))
    fix_edges = core.std.MaskedMerge(scaled, aa_rfs, box.get_mask(scaled))

    # Regular debanding, but then...
    deband = flt.multi_debander(fix_edges, sp_out16)

    # --- More very specific filtering that should almost definitely be removed for other episodes
    boxes = [
        BoundingBox((0, 880), (1920, 200)),
        BoundingBox((1367, 0), (552, 1080)),
        BoundingBox((1143, 0), (466, 83)),
        BoundingBox((1233, 84), (237, 84)),
    ]

    boxed_deband = flt.placebo_debander(fix_edges,
                                        iterations=2,
                                        threshold=8,
                                        radius=14,
                                        grain=4)
    boxed_mask = core.std.BlankClip(
        boxed_deband.std.ShufflePlanes(planes=0, colorfamily=vs.GRAY))
    for bx in boxes:  # Gonna be awfully slow but OH WELLLLLL
        boxed_mask = core.std.Expr(
            [boxed_mask, bx.get_mask(boxed_mask)], "x y max")

    boxed_deband_merged = core.std.MaskedMerge(deband, boxed_deband,
                                               boxed_mask)
    boxed_deband_merged = replace_ranges(deband, boxed_deband_merged,
                                         [(20554, 20625)])

    stronger_deband = dumb3kdb(fix_edges, radius=18, threshold=[48, 32])
    stronger_deband = replace_ranges(boxed_deband_merged, stronger_deband,
                                     [(22547, 22912), (28615, 28846),
                                      (33499, 33708), (37223, 37572),
                                      (37636, 37791), (38047, 38102),
                                      (38411, 38733)])

    deband_csharp = ContraSharpening(stronger_deband, scaled, 17)

    sp_out = deband_csharp

    # Back to regular graining
    grain = flt.grain(sp_out)

    return grain
コード例 #7
0
from typing import Any, Dict, List, Tuple, Union

import vapoursynth as vs
from lvsfunc.misc import source
from lvsfunc.types import Range
from vardautomation import FileInfo, PresetBD, PresetFLAC, VPath

from project_module import encoder as enc
from project_module import flt

core = vs.core


# Sources
JP_BD = FileInfo(r'BDMV/Vol.06/BTOOOM 06/BDMV/STREAM/00010.m2ts', (24, -24),
                 idx=lambda x: source(x, cachedir=''), preset=[PresetBD, PresetFLAC])
JP_BD.name_file_final = VPath(fr"premux/{JP_BD.name} (Premux).mkv")
JP_BD.a_src_cut = JP_BD.name
JP_BD.do_qpfile = True


shift_chr: List[Range] = [  # Shift chroma ranges
]

str_grain: List[Range] = [  # Super strong stylistic grain
    (186, 200), (246, 260)
]

no_filter: List[Range] = [  # No filtering
]
コード例 #8
0
import vapoursynth as vs
from lvsfunc.misc import source
from lvsfunc.types import Range
from vardautomation import FileInfo, PresetWEB, PresetAAC, VPath

from project_module import encoder as enc

core = vs.core

# Sources
JP_TV = FileInfo(
    r'src/Code Geass - Hangyaku no Lelouch - 01 [15th Anniversary Rebroadcast] (TBS).d2v',
    (50972, 53670),
    preset=[PresetWEB, PresetAAC],
    idx=lambda x: source(x))
JP_TV.name_file_final = VPath(fr"premux/{JP_TV.name} (Premux).mkv")
JP_TV.a_src = VPath(JP_TV.path.to_str()[:-4] + ".aac")
JP_TV.a_src_cut = VPath(JP_TV.path.to_str()[:-4] + "_cut.aac")
JP_TV.do_qpfile = True

zones: Dict[Tuple[int, int], Dict[str, Any]] = {  # Zones for x265
}


def filterchain() -> Union[vs.VideoNode, Tuple[vs.VideoNode, ...]]:
    """Main filterchain"""
    import debandshit as dbs
    import lvsfunc as lvf
    from adptvgrnMod import adptvgrnMod
    from vsutil import depth
コード例 #9
0
from vardautomation import FileInfo, PresetAAC, PresetBD, VPath

from project_module import enc, flt

core = vs.core


shader_file = Path(r'assets/FSRCNNX_x2_56-16-4-1.glsl')
if not shader_file.exists:
    hookpath = r"mpv/shaders/FSRCNNX_x2_56-16-4-1.glsl"
    shader_file = os.path.join(os.getenv("APPDATA"), hookpath)


# Sources
JP_BD = FileInfo(r'BDMV/[BDMV][210728][Yuru Camp Season 2][Vol.3 Fin]/BD/BDMV/STREAM/00013.m2ts', [(24, -24)],
                 idx=lambda x: source(x, force_lsmas=True, cachedir=''), preset=[PresetBD, PresetAAC])
JP_EP = FileInfo(r'BDMV/[BDMV][210728][Yuru Camp Season 2][Vol.3 Fin]/BD/BDMV/STREAM/00008.m2ts',
                 [(1356+32, 1356+2184)], idx=lambda x: source(x, force_lsmas=True, cachedir=''))
JP_BD.name_file_final = VPath(f"premux/{JP_BD.name} (Premux).mkv")
JP_BD.a_src_cut = VPath(JP_BD.name)
JP_BD.do_qpfile = True


def filterchain() -> Union[vs.VideoNode, Tuple[vs.VideoNode, ...]]:
    """Main VapourSynth filterchain"""
    import EoEfunc as eoe
    import lvsfunc as lvf
    import vardefunc as vdf
    from ccd import ccd
    from finedehalo import fine_dehalo
    from vsutil import depth, get_y
コード例 #10
0
import vapoursynth as vs
from lvsfunc.misc import source
from vardautomation import FileInfo, PresetAAC, PresetBD, VPath
from vsgan import VSGAN

from project_module import encoder as enc
from project_module import flt

core = vs.core
core.num_threads = 4


# Sources
JP_DVD = FileInfo(r'BDMV/130208_JOSHIRAKU_OAD/VIDEO_TS/VTS_01_0.d2v', (26, -34),
                  idx=lambda x: source(x, rff=False), preset=[PresetBD, PresetAAC])
JP_BD_NCOP = FileInfo(r'BDMV/120926_JOSHIRAKU_VOL1/BDMV/STREAM/00001.m2ts', (24, -24),
                      idx=lambda x: source(x, cachedir=''))
JP_BD_NCED = FileInfo(r'BDMV/120926_JOSHIRAKU_VOL1/BDMV/STREAM/00002.m2ts', (24, -24),
                      idx=lambda x: source(x, cachedir=''))
JP_BD_03 = FileInfo(r'BDMV/121024_JOSHIRAKU_VOL2/BDMV/STREAM/00000.m2ts', (24, 34789),
                    idx=lambda x: source(x, cachedir=''))
JP_DVD.clip = core.std.AssumeFPS(JP_DVD.clip, fpsnum=24000, fpsden=1001)  # To get it to trim properly
JP_DVD.name_file_final = VPath(fr"premux/{JP_DVD.name} (Premux).mkv")
JP_DVD.a_src = VPath(r"BDMV/130208_JOSHIRAKU_OAD/VIDEO_TS/VTS_01_0 T80 stereo 448 kbps DELAY 0 ms.ac3")
JP_DVD.a_src_cut = VPath(f"{JP_DVD.name}_cut.ac3")
JP_DVD.do_qpfile = True


PROPS_DVD: Set[Tuple[str, int]] = {
    ('_ChromaLocation', 0),
コード例 #11
0
core = vs.core


class ClipForDatasets(NamedTuple):  # noqa: PLC0115
    clip: vs.VideoNode
    res_type: str


class Datasets(NamedTuple):  # noqa: PLC0115
    hr: ClipForDatasets
    lr: ClipForDatasets


# Source files
JP_DVD_clips: List[vs.VideoNode] = [
    source(r'../DVDISO/JOSHIRAKU_01.d2v', rff=False)[4844:74402],
    source(r'../DVDISO/JOSHIRAKU_02.d2v', rff=False)[4844:74398],
    source(r'../DVDISO/JOSHIRAKU_03.d2v', rff=False)[4844:74400],
    source(r'../DVDISO/JOSHIRAKU_04.d2v', rff=False)[4844:74399],
    source(r'../DVDISO/JOSHIRAKU_05.d2v', rff=False)[4844:74401],
    source(r'../DVDISO/JOSHIRAKU_06.d2v', rff=False)[19245:122872]
]

JP_BD_clips: List[vs.VideoNode] = [
    source(r'../BDMV/120926_JOSHIRAKU_VOL1/BDMV/STREAM/00000.m2ts')[24:-42],
    source(r'../BDMV/121024_JOSHIRAKU_VOL2/BDMV/STREAM/00000.m2ts')[24:-46],
    source(r'../BDMV/121128_JOSHIRAKU_VOL3/BDMV/STREAM/00000.m2ts')[24:-44],
    source(r'../BDMV/130123_JOSHIRAKU_VOL4/BDMV/STREAM/00000.m2ts')[24:-45],
    source(r'../BDMV/130227_JOSHIRAKU_VOL5/BDMV/STREAM/00000.m2ts')[24:-43],
    source(r'../BDMV/130522_JOSHIRAKU_VOL6/BDMV/STREAM/00000.m2ts')[24:-29],
]
コード例 #12
0
from vardautomation import FileInfo, PresetAAC, PresetBD, VPath

from project_module import enc, flt

core = vs.core


shader_file = Path(r'assets/FSRCNNX_x2_56-16-4-1.glsl')
if not shader_file.exists:
    hookpath = r"mpv/shaders/FSRCNNX_x2_56-16-4-1.glsl"
    shader_file = os.path.join(os.getenv("APPDATA"), hookpath)


# Sources
JP_BD = FileInfo(r'BDMV/[BDMV][210728][Yuru Camp Season 2][Vol.3 Fin]/BD/BDMV/STREAM/00013.m2ts', [(24, -24)],
                 idx=lambda x: source(x, force_lsmas=True, cachedir=''), preset=[PresetBD, PresetAAC])
JP_EP = FileInfo(r'BDMV/[BDMV][210728][Yuru Camp Season 2][Vol.3 Fin]/BD/BDMV/STREAM/00006.m2ts',
                 [(3024+24, 3024+2184)], idx=lambda x: source(x, force_lsmas=True, cachedir=''))
JP_BD.name_file_final = VPath(f"premux/{JP_BD.name} (Premux).mkv")
JP_BD.a_src_cut = VPath(JP_BD.name)
JP_BD.do_qpfile = True


def filterchain() -> Union[vs.VideoNode, Tuple[vs.VideoNode, ...]]:
    """Main VapourSynth filterchain"""
    import EoEfunc as eoe
    import lvsfunc as lvf
    import vardefunc as vdf
    from ccd import ccd
    from finedehalo import fine_dehalo
    from vsutil import depth, get_y