diff --git a/12/ac.py b/12/ac.py new file mode 100644 index 0000000..0483a37 --- /dev/null +++ b/12/ac.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +import vapoursynth as vs +import audiocutter + +core = vs.core + +ts = "cap/Senki Zesshou Symphogear XV - 12 (MX).d2v" +src = core.d2v.Source(ts) +src = src.vivtc.VFM(1).vivtc.VDecimate() + +ac = audiocutter.AudioCutter() + +audio = ac.split(src, [(813, 2971), (4651, 14215), (15656, 37976)]) + +ac.ready_qp_and_chapters(audio) + +audio.set_output(0) + +if __name__ == "__main__": + ac.cut_audio("mx_audio.m4a", audio_source="cap/mx_adjusted.m4a") diff --git a/12/mask_2.png b/12/mask_2.png new file mode 100644 index 0000000..526f02f Binary files /dev/null and b/12/mask_2.png differ diff --git a/12/x264.vpy b/12/x264.vpy new file mode 100644 index 0000000..fccaed7 --- /dev/null +++ b/12/x264.vpy @@ -0,0 +1,77 @@ +import vapoursynth as vs +import kagefunc as kgf +import fvsfunc as fvf +import vsTAAmbk as vstaa +import adjust +import vsutil +from nnedi3_rpow2 import nnedi3_rpow2 +from ytttfunc import descale_eval +from ytttfunc import adaptivegrain + +core = vs.core +core.max_cache_size = 32768 + +ed = [31646, 34043] +logo = [11640, 11805] +chris = 13412 # youtube henshin for chris doesn't have the intro so i picked an arbitrary ref frame + +chris_mappings_115 = f''' +[{chris+344} {chris+791}] +''' + +chris_mappings_135_115 = f''' +[{chris+1031} {chris+1060}] +''' + +src = core.ffms2.Source("[HorribleSubs] Symphogear XV - 12 [1080p].mkv") +src = core.fmtc.bitdepth(src, bits=16) + +# todo: examine potential for actually descaling this episode +# flashback to ep10 at ~5:00 (bad non-descalable episode) +logo_mask = core.imwri.Read('mask_2.png') +logo_mask = core.resize.Bilinear(logo_mask, format=src.format.id, matrix_s="709") +deblock = core.deblock.Deblock(src, quant=16) +Y = vsutil.get_y(deblock) + +HEIGHT = 873 +Yconst = kgf.inverse_scale(Y, height=HEIGHT, kernel="bicubic", b=1/3, c=1/3, mask_detail=False) +Ynn = nnedi3_rpow2(Yconst).resize.Spline36(1920, 1080, format=vs.GRAY16) + +# threshold scaling works basically not at all +# so instead we're just going to use it for range functionality +Yde = descale_eval.descale_range(Y, heights=list(range(870, 875)), threshold=1, debug=False, mask_detail=True) +Yde = Yde.resize.Point(Yde.width, Yde.height, format=vs.GRAY16) + +scaled_all = core.std.ShufflePlanes([Yde, deblock], planes=[0, 1, 2], colorfamily=vs.YUV) + +scaled = scaled_all +logo_merge = core.std.MaskedMerge(scaled, deblock, logo_mask) +scaled = fvf.rfs(scaled, logo_merge, mappings=f"[{logo[0]} {logo[1]}]") +scaled = fvf.rfs(scaled, src, mappings=f"[{ed[0]} {ed[1]}]") + +dim1 = adjust.Tweak(scaled, sat=1.15, cont=1.15) +dim2 = adjust.Tweak(scaled, sat=1.35, cont=1.15) + +undim = fvf.rfs(scaled, dim1, mappings=chris_mappings_115+" [3776 6034] [7898 8022] [14687 14740] [15948 16019] [16074 16103] [16826 16840] [17259 17444] [17811 17861] [17976 18020] [18084 18137]") +undim = fvf.rfs(undim, dim2, mappings=chris_mappings_135_115) + +denoisechroma = core.knlm.KNLMeansCL(undim, d=1, a=2, h=0.4, channels="UV", device_type='gpu', device_id=0) +denoiseluma = core.knlm.KNLMeansCL(undim, d=3, a=2, h=0.35, channels="Y", device_type='gpu', device_id=0) +denoise = core.std.ShufflePlanes([denoiseluma, denoisechroma], planes=[0, 1, 2], colorfamily=vs.YUV) +taa = vstaa.TAAmbk(denoise,aatype='Nnedi3') +db = taa.f3kdb.Deband(range=16, y=40, cb=32, cr=32, grainy=24, grainc=0, output_depth=16) +mask = kgf.retinex_edgemask(denoise) +merged = core.std.MaskedMerge(db, taa, mask) + +Y, U, V = kgf.split(merged) +Y = Y.edgefixer.Continuity(top=3, left=4) +U = U.edgefixer.Continuity(top=2, left=3) +V = V.edgefixer.Continuity(top=2, left=3) +endcardfix = core.std.ShufflePlanes([Y, U, V], planes=[0], colorfamily=vs.YUV) +fixed = fvf.rfs(merged, endcardfix, mappings="[31601 31645]") + +final = adaptivegrain.adaptive_grain(fixed) +final = core.fmtc.bitdepth(final, bits=10, dmode=3) +final.set_output() + +#vspipe -y "x264.vpy" - | ffmpeg -i pipe: -c:v libx264 -tune animation -crf 16 -preset slower -aq-mode 3 -pix_fmt yuv420p10le -x264-params no-dct-decimate:no-fast-pskip -y "x264.mp4" \ No newline at end of file diff --git a/13/ac.py b/13/ac.py new file mode 100644 index 0000000..a9a374d --- /dev/null +++ b/13/ac.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +import vapoursynth as vs +import audiocutter + +core = vs.core + +ts = "cap/Senki Zesshou Symphogear XV - 13 (MX).d2v" +src = core.d2v.Source(ts) +src = src.vivtc.VFM(1).vivtc.VDecimate() + +ac = audiocutter.AudioCutter() + +audio = ac.split(src, [(800, 9264), (10942, 18350), (19790, 37963)]) + +ac.ready_qp_and_chapters(audio) + +audio.set_output(0) + +if __name__ == "__main__": + ac.cut_audio("mx_audio.m4a", audio_source="cap/mx_adjusted.m4a") diff --git a/13/mask_2.png b/13/mask_2.png new file mode 100644 index 0000000..526f02f Binary files /dev/null and b/13/mask_2.png differ diff --git a/13/x264.vpy b/13/x264.vpy new file mode 100644 index 0000000..a4d8e5b --- /dev/null +++ b/13/x264.vpy @@ -0,0 +1,59 @@ +import vapoursynth as vs +import kagefunc as kgf +import fvsfunc as fvf +import vsTAAmbk as vstaa +import adjust +import vsutil +from nnedi3_rpow2 import nnedi3_rpow2 +from ytttfunc import descale_eval, adaptivegrain + +core = vs.core +core.max_cache_size = 32768 + +src = core.ffms2.Source("[HorribleSubs] Symphogear XV - 13 [1080p].mkv") +src = core.fmtc.bitdepth(src, bits=16) + +logo_mask = core.imwri.Read('mask_2.png') +logo_mask = core.resize.Bilinear(logo_mask, format=src.format.id, matrix_s="709") +deblock = core.deblock.Deblock(src, quant=16) + +Y = vsutil.get_y(deblock) + +Ycond = descale_eval.descale_range(Y, heights=list(range(870, 875)), threshold=1, debug=False, mask_detail=True) +Ycond = Ycond.resize.Point(Ycond.width, Ycond.height, format=vs.GRAY16) + +scaled = core.std.ShufflePlanes([Ycond, deblock], planes=[0, 1, 2], colorfamily=vs.YUV) + +scaled = fvf.rfs(scaled, src, mappings="[30162 32320]") + +logo_merge = core.std.MaskedMerge(scaled, deblock, logo_mask) +scaled = fvf.rfs(scaled, logo_merge, mappings=f"[15790 15955]") + +# lightarrows did it this time so it doesn't suck +dim1 = adjust.Tweak(scaled, sat=1.15, cont=1.15) +dim2 = adjust.Tweak(scaled, sat=1.20, cont=1.20) +dim3 = adjust.Tweak(scaled, sat=1.05, cont=1.05) +dim4 = adjust.Tweak(scaled, sat=1.10, cont=1.10) + +undim = fvf.rfs(scaled, dim1, mappings="[1870 1938] [2011 2136] [2441 2670] [2719 2730] [5157 5697] [6482 6571] [6591 7079] [7140 7222] [7274 7842] [7961 7994] [8048 8244] [8634 8686] [9134 9178] [12581 13487] [14285 14862] [14898 15071] [22374 22527] [26853 26944] [27379 27920]") +undim = fvf.rfs(undim, dim2, mappings="[2731 2802] [2851 3108] [4444 4614] [4781 5156] [20144 20404]") +undim = fvf.rfs(undim, dim3, mappings="[3109 3147] [8771 8860] [13902 14284] [14863 14897] [25518 26047] [26437 26557] [26945 27053] [28077 29071]") +undim = fvf.rfs(undim, dim4, mappings="[13828 13901]") + +sq_mask = kgf.squaremask(scaled, 1049, 594, 0, 238) +ed_undim = fvf.rfs(undim, dim3, mappings="[32254 32305]") +undim = core.std.MaskedMerge(undim, ed_undim, sq_mask) + +denoisechroma = core.knlm.KNLMeansCL(undim, d=1, a=2, h=0.4, channels="UV", device_type='gpu', device_id=0) +denoiseluma = core.knlm.KNLMeansCL(undim, d=3, a=2, h=0.35, channels="Y", device_type='gpu', device_id=0) +denoise = core.std.ShufflePlanes([denoiseluma, denoisechroma], planes=[0, 1, 2], colorfamily=vs.YUV) +taa = vstaa.TAAmbk(denoise,aatype='Nnedi3') +db = taa.f3kdb.Deband(range=16, y=40, cb=32, cr=32, grainy=24, grainc=0, output_depth=16) +mask = kgf.retinex_edgemask(denoise) +merged = core.std.MaskedMerge(db, taa, mask) + +final = adaptivegrain.adaptive_grain(merged) +final = core.fmtc.bitdepth(final, bits=10, dmode=3) +final.set_output() + +#vspipe -y "x264.vpy" - | ffmpeg -i pipe: -c:v libx264 -tune animation -crf 16 -preset slower -aq-mode 3 -pix_fmt yuv420p10le -x264-params no-dct-decimate:no-fast-pskip -y "x264.mp4" \ No newline at end of file