Ejemplo n.º 1
0
 def hardsub_mask(base: vs.VideoNode, sub: str,
                  fontdir: str) -> vs.VideoNode:
     _, masksub = core.sub.TextFile(base, sub, fontdir=fontdir, blend=False)
     masksub = masksub.std.Binarize(1)
     masksub = hvf.mt_expand_multi(masksub, 'ellipse', sw=6, sh=4)
     masksub = hvf.mt_inflate_multi(masksub,
                                    radius=4).std.Convolution([1] * 9)
     return masksub
Ejemplo n.º 2
0
def filtering() -> Union[vs.VideoNode, Tuple[vs.VideoNode, vs.VideoNode]]:
    """Vapoursynth filtering"""
    src_cru = WEB_CRU.clip_cut
    src_aod = WEB_AOD.clip_cut

    _, masksub = core.sub.TextFile(src_aod, SUB, fontdir='fonts', blend=False)
    masksub = core.std.Binarize(masksub, 1)
    masksub = hvf.mt_expand_multi(masksub, 'ellipse', sw=6, sh=4)
    masksub = hvf.mt_inflate_multi(masksub, radius=4).std.Convolution([1] * 9)

    dehardsub = core.std.MaskedMerge(src_aod, src_cru, masksub)
    dehardsub = depth(dehardsub, 16)
    out = dehardsub


    lineart = ScharrG41().get_mask(get_y(out), 4000, multi=1.2).rgvs.RemoveGrain(3).std.Maximum().std.Minimum()


    luma = get_y(out)
    ssing = vdf.scale.fsrcnnx_upscale(
        luma, height=1620, shader_file='shaders/FSRCNNX_x2_16-0-4-1.glsl',
        downscaler=lambda c, w, h: core.resize.Bicubic(c, w, h, filter_param_a=-0.5, filter_param_b=0.25),
        profile='fast',
    )
    sraing = sraa_eedi3(ssing, 13, gamma=100, nrad=2, mdis=15)
    down = core.resize.Bicubic(sraing, out.width, out.height, filter_param_a=-0.5, filter_param_b=0.25)
    masked = core.std.MaskedMerge(luma, down, lineart)
    merged = vdf.misc.merge_chroma(masked, out)
    out = merged


    contra = hvf.LSFmod(out, strength=80, Smode=3, edgemode=0, source=dehardsub)
    out = contra


    # I gave up on this
    ending = lvf.rfs(out, dehardsub, [(1368, 3524), (31072, out.num_frames - 1)])
    out = ending



    dehalo = gf.MaskedDHA(out, rx=1.4, ry=1.4, darkstr=0, brightstr=0.8)
    out = dehalo




    dbgra_cru = _dbgra(src_cru)
    deband = core.std.MaskedMerge(out, dbgra_cru, depth(masksub, 16))
    out = deband




    ref = src_cru
    rsc_m = vdf.mask.diff_rescale_mask(ref, 837, thr=80)
    rsc_m = depth(rsc_m, 16)

    ref = dehardsub
    credit = out


    # Ep Title
    creds = [
        Credit([(3691, 3810)], vdf.mask.region_mask(rsc_m[3696], 1450, 0, 800, 0)),
    ]
    for cred in creds:
        credit = lvf.rfs(credit, core.std.MaskedMerge(out, ref, cred.mask), cred.range_frames)

    out = credit



    # return dehardsub, vdf.mask.region_mask(rsc_m, 1450, 0, 800, 0)
    # return dehardsub, out


    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
Ejemplo n.º 3
0
def filtering() -> Union[vs.VideoNode, Tuple[vs.VideoNode, vs.VideoNode]]:
    """Vapoursynth filtering"""
    src_cru = WEB_CRU.clip_cut
    src_aod = WEB_AOD.clip_cut

    _, masksub = core.sub.TextFile(src_aod, SUB, fontdir='fonts', blend=False)
    masksub = core.std.Binarize(masksub, 1)
    masksub = hvf.mt_expand_multi(masksub, 'ellipse', sw=6, sh=4)
    masksub = hvf.mt_inflate_multi(masksub, radius=4).std.Convolution([1] * 9)

    dehardsub = core.std.MaskedMerge(src_aod, src_cru, masksub)
    dehardsub = depth(dehardsub, 16)
    out = dehardsub

    lineart = ScharrG41().get_mask(
        get_y(out), 4000,
        multi=1.2).rgvs.RemoveGrain(3).std.Maximum().std.Minimum()

    luma = get_y(out)
    ssing = vdf.scale.fsrcnnx_upscale(
        luma,
        height=1620,
        shader_file='shaders/FSRCNNX_x2_16-0-4-1.glsl',
        downscaler=lambda c, w, h: core.resize.Bicubic(
            c, w, h, filter_param_a=-0.5, filter_param_b=0.25),
        profile='fast',
    )
    sraing = sraa_eedi3(ssing, 13, gamma=100, nrad=2, mdis=15)
    down = core.resize.Bicubic(sraing,
                               out.width,
                               out.height,
                               filter_param_a=-0.5,
                               filter_param_b=0.25)
    masked = core.std.MaskedMerge(luma, down, lineart)
    merged = vdf.misc.merge_chroma(masked, out)
    out = merged

    contra = hvf.LSFmod(out,
                        strength=80,
                        Smode=3,
                        edgemode=0,
                        source=dehardsub)
    out = contra

    # I gave up on this
    ending = lvf.rfs(out, dehardsub, [(31782, out.num_frames - 1)])
    out = ending

    dehalo = gf.MaskedDHA(out, rx=1.4, ry=1.4, darkstr=0, brightstr=0.8)
    out = dehalo

    dbgra_cru = _dbgra(src_cru)
    deband = core.std.MaskedMerge(out, dbgra_cru, depth(masksub, 16))
    out = deband

    ref = src_cru
    rsc_m = vdf.mask.diff_rescale_mask(ref, 837, thr=80)
    rsc_m = depth(rsc_m, 16)

    ref = dehardsub
    credit = out

    # Beginning credits
    creds = [
        Credit([(0, 117)], vdf.mask.region_mask(rsc_m[94], 700, 600, 300,
                                                300)),
        Credit([(125, 233)],
               core.std.Expr([
                   vdf.mask.region_mask(rsc_m, 100, 1300, 120, 600),
                   vdf.mask.region_mask(rsc_m, 100, 1700, 80, 600)
               ], 'x y max')[137]),
        Credit([(288, 399)], vdf.mask.region_mask(rsc_m[303], 0, 1200, 0,
                                                  500)),
        Credit([(288, 399)], vdf.mask.region_mask(rsc_m[303], 0, 1200, 0,
                                                  500)),
        Credit([(526, 631)], vdf.mask.region_mask(rsc_m[543], 1200, 0, 0,
                                                  500)),
        Credit([(644, 749)], vdf.mask.region_mask(rsc_m[672], 0, 1000, 0, 0)),
        Credit([(758, 851)], vdf.mask.region_mask(rsc_m[771], 1300, 0, 0,
                                                  400)),
        Credit([(859, 966)], vdf.mask.region_mask(rsc_m[935], 1325, 0, 0, 0)),
        Credit([(996, 1083)], vdf.mask.region_mask(rsc_m[1007], 1325, 0, 0,
                                                   0)),
        Credit([(1091, 1198)], vdf.mask.region_mask(rsc_m[1117], 1325, 0, 0,
                                                    0)),
        Credit([(1216, 1315)],
               vdf.mask.region_mask(rsc_m[1253], 800, 800, 400, 400)),
        Credit([(1333, 1439)],
               core.std.Expr([
                   vdf.mask.region_mask(rsc_m, 1265, 0, 850, 0),
                   vdf.mask.region_mask(rsc_m, 1400, 0, 800, 0),
                   vdf.mask.region_mask(rsc_m, 1000, 0, 950, 0)
               ], 'x y max z max')[1365]),
    ]
    for cred in creds:
        credit = lvf.rfs(credit, core.std.MaskedMerge(out, ref, cred.mask),
                         cred.range_frames)

    # Ep Title
    creds = [
        Credit([(1653, 1772)],
               vdf.mask.region_mask(rsc_m[1705], 100, 600, 40, 940)),
    ]
    for cred in creds:
        credit = lvf.rfs(credit, core.std.MaskedMerge(out, ref, cred.mask),
                         cred.range_frames)

    out = credit

    # return dehardsub, rsc_m
    # return dehardsub, masksub

    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])