From 66dbe5e53f608938c58dd6f61f1497555a9c97cc Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 27 Apr 2020 16:18:12 -0400 Subject: [PATCH 1/4] magireco: link varde's repo --- Magia Record/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Magia Record/README.md diff --git a/Magia Record/README.md b/Magia Record/README.md new file mode 100644 index 0000000..60d26fb --- /dev/null +++ b/Magia Record/README.md @@ -0,0 +1,4 @@ +Magireco was encoded by [Vardë](https://github.com/Ichunjo) and the encode +scripts can be found in his repo: +[TV](https://github.com/Ichunjo/encode-scripts/tree/master/Raws-Maji/Magia%20Record%20%5BWEB%5D), +[BD](https://github.com/Ichunjo/encode-scripts/tree/master/Other%20groups/YameteTomete/Magia%20Record%20%5BBD%5D) From b1b2aa6b54552b3b74cc4aab3a88904d4001a300 Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 27 Apr 2020 16:30:25 -0400 Subject: [PATCH 2/4] xv: bd: update vol 2 --- Symphogear/XV [BD]/03/ep3.vpy | 2 +- Symphogear/XV [BD]/04/ep4.vpy | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Symphogear/XV [BD]/03/ep3.vpy b/Symphogear/XV [BD]/03/ep3.vpy index 8436ae2..bbb4fb3 100644 --- a/Symphogear/XV [BD]/03/ep3.vpy +++ b/Symphogear/XV [BD]/03/ep3.vpy @@ -77,7 +77,7 @@ bm3d = core.std.ShufflePlanes([w2x, bm3d], planes=[0, 1, 2], colorfamily=vs.YUV) denoise_2 = replace_ranges(scaled, bm3d, W2X_DENOISE) line = kgf.retinex_edgemask(denoise_2).std.Binarize(9500).rgvs.RemoveGrain(3).std.Inflate() -deband = denoise_2.neo_f3kdb.Deband(range=18, y=32, cb=24, cr=24, grainy=24, grainc=0, output_depth=16, sample_mode=4) +deband = denoise_2.neo_f3kdb.Deband(range=18, y=32, cb=24, cr=24, grainy=24, grainc=0, output_depth=16, sample_mode=4, keep_tv_range=True) deband = core.std.MaskedMerge(deband, denoise_2, line) # mask OP/ED credits, stolen from varde diff --git a/Symphogear/XV [BD]/04/ep4.vpy b/Symphogear/XV [BD]/04/ep4.vpy index 2e95bfc..7f13d4b 100644 --- a/Symphogear/XV [BD]/04/ep4.vpy +++ b/Symphogear/XV [BD]/04/ep4.vpy @@ -79,7 +79,7 @@ bm3d = core.std.ShufflePlanes([w2x, bm3d], planes=[0, 1, 2], colorfamily=vs.YUV) denoise_2 = replace_ranges(scaled, bm3d, W2X_DENOISE) line = kgf.retinex_edgemask(denoise_2).std.Binarize(9500).rgvs.RemoveGrain(3).std.Inflate() -nf3kdb = denoise_2.neo_f3kdb.Deband(range=18, y=32, cb=24, cr=24, grainy=24, grainc=0, output_depth=16, sample_mode=4) +nf3kdb = denoise_2.neo_f3kdb.Deband(range=18, y=32, cb=24, cr=24, grainy=24, grainc=0, output_depth=16, sample_mode=4, keep_tv_range=True) nf3kdb = core.std.MaskedMerge(nf3kdb, denoise_2, line) placebo = denoise_2.placebo.Deband(iterations=3, threshold=3, radius=24, grain=4) placebo2 = denoise_2.placebo.Deband(iterations=3, threshold=5, radius=32, grain=4) @@ -95,4 +95,4 @@ credit = core.std.MaskedMerge(deband, denoise, credit_m) final = credit final = adaptive_grain(final, 0.3) final = core.fmtc.bitdepth(final, bits=10, dmode=3) -final.set_output() \ No newline at end of file +final.set_output() From f809291a265d9768a36e82358322b55cc30716b7 Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 27 Apr 2020 16:30:59 -0400 Subject: [PATCH 3/4] add readme and license --- LICENSE | 21 +++++++++++++++++++++ README.md | 1 + 2 files changed, 22 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4dba5e0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 YameteTomete + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f61fea0 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Vapoursynth scripts for our projects From aa9edcbca7bca99909910a280bc3c13d4093ac96 Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 27 Apr 2020 22:52:29 -0400 Subject: [PATCH 4/4] xv: bd: ep1 patches and x264 settings --- Symphogear/XV [BD]/01/ep1_patch.vpy | 85 ++++++++++++++++++++ Symphogear/XV [BD]/01/ep1_patch_patch.vpy | 96 +++++++++++++++++++++++ Symphogear/XV [BD]/settings | 5 ++ 3 files changed, 186 insertions(+) create mode 100644 Symphogear/XV [BD]/01/ep1_patch.vpy create mode 100644 Symphogear/XV [BD]/01/ep1_patch_patch.vpy create mode 100644 Symphogear/XV [BD]/settings diff --git a/Symphogear/XV [BD]/01/ep1_patch.vpy b/Symphogear/XV [BD]/01/ep1_patch.vpy new file mode 100644 index 0000000..82557a8 --- /dev/null +++ b/Symphogear/XV [BD]/01/ep1_patch.vpy @@ -0,0 +1,85 @@ +import vapoursynth as vs +import lvsfunc as lvf +import kagefunc as kgf +import mvsfunc as mvf +import vsutil + +from ytttfunc.adaptivegrain import adaptive_grain +from ytttfunc.replace_ranges import replace_ranges +from functools import partial + +core = vs.core +core.max_cache_size = 1024 + +LOGO = [(20777, 20942)] +NO_SCALE = [(30836, 33230), (34463, 34553)] +FORCE_SCALE = [(4015, 5159)] +DESCALE_MASK = [(256, 1546)] +DEBAND_HARD = [(4120, 4210)] +DEBAND_HARDER = [(4138, 4174)] + +src_ep = core.lsmas.LWLibavSource("bdmv/KIXA_90888/BDMV/STREAM/00003.m2ts") +src_pv = core.lsmas.LWLibavSource("bdmv/KIXA_90888/BDMV/STREAM/00004.m2ts")[:-24] +src = src_ep + src_pv +src = src.fmtc.bitdepth(bits=16) + +# mkvmerge --split frames:1547,3900,4215 -o ep1_split_%1d.mkv ep1_bd.mp4 +split_src1 = core.ffms2.Source("ep1_split_1.mkv") +split_src2 = core.ffms2.Source("ep1_split_2.mkv") +split_src3 = core.ffms2.Source("ep1_split_3.mkv") +split_src4 = core.ffms2.Source("ep1_split_4.mkv") + +denoisechroma = core.knlm.KNLMeansCL(src, d=1, a=2, h=0.45, channels="UV", device_type='gpu', device_id=0) +denoiseluma = core.knlm.KNLMeansCL(src, d=3, a=2, h=0.4, channels="Y", device_type='gpu', device_id=0) +denoise = core.std.ShufflePlanes([denoiseluma, denoisechroma], planes=[0, 1, 2], colorfamily=vs.YUV) + +logo_mask = core.imwri.Read("mask_2.png") +logo_mask = logo_mask.resize.Bilinear(format=src.format.id, matrix_s="709") + +Y = vsutil.get_y(denoise) + +def sraa_frameeval(n, clip): + frame = clip.get_frame(n) + if frame.height < 1080: + rfactor = 2.5 + else: + rfactor = 1.5 + return lvf.upscaled_sraa(clip.resize.Bicubic(frame.width, frame.height), rfactor=rfactor, h=1080, ar=16/9) + +edge = kgf.retinex_edgemask(Y, .0001).std.Binarize(10000) + +Ys = lvf.smart_descale(Y, [871, 872, 873], kernel="bicubic", b=1/3, c=1/3, thr=0.003) +Yf = lvf.smart_descale(Y, [871, 872, 873], kernel="bicubic", b=1/3, c=1/3, thr=0) +Yd = replace_ranges(Ys, Yf, FORCE_SCALE) +Yd = Yd.resize.Bicubic(format=vs.GRAY16) +Ysraa = Yd.std.FrameEval(partial(sraa_frameeval, clip=Yd)) +Ysraa = Ysraa.resize.Spline36(1920, 1080, format=vs.GRAY16) +Yline = core.std.MaskedMerge(Y, Ysraa, edge) +text_mask = core.std.Expr([Y, Yd.resize.Bicubic(1920, 1080, filter_param_a=1/3, filter_param_b=1/3)], 'x y - abs') +text_mask = vsutil.iterate(text_mask, core.std.Maximum, 4) +text_mask = text_mask.std.Binarize(4000) +Ydmask = core.std.MaskedMerge(Yline, Y, text_mask) +Yfinal = replace_ranges(Yline, Ydmask, DESCALE_MASK) + +scaled = core.std.ShufflePlanes([Yfinal, denoise], planes=[0, 1, 2], colorfamily=vs.YUV) + +logo_merge = core.std.MaskedMerge(scaled, denoise, logo_mask) + +scaled = replace_ranges(scaled, denoise, NO_SCALE) +scaled = replace_ranges(scaled, logo_merge, LOGO) + +line = kgf.retinex_edgemask(scaled).std.Binarize(9500).rgvs.RemoveGrain(3).std.Inflate() +nf3kdb = scaled.neo_f3kdb.Deband(range=18, y=32, cb=24, cr=24, grainy=24, grainc=0, output_depth=16, sample_mode=4) +nf3kdb = core.std.MaskedMerge(nf3kdb, scaled, line) +placebo = scaled.placebo.Deband(iterations=3, threshold=3, radius=24, grain=4) +placebo2 = scaled.placebo.Deband(iterations=3, threshold=5, radius=32, grain=4) +deband = replace_ranges(nf3kdb, placebo, DEBAND_HARD) +deband = replace_ranges(deband, placebo2, DEBAND_HARDER) + +patch1 = deband[:-1*(split_src2.num_frames+split_src3.num_frames+split_src4.num_frames)] # patch for intro credit mask +patch2 = deband[split_src1.num_frames+split_src2.num_frames:-split_src4.num_frames] # patch for henshin deband + +final = patch2 +final = adaptive_grain(final, 0.3) +final = core.fmtc.bitdepth(final, bits=10, dmode=3) +final.set_output() diff --git a/Symphogear/XV [BD]/01/ep1_patch_patch.vpy b/Symphogear/XV [BD]/01/ep1_patch_patch.vpy new file mode 100644 index 0000000..400f8e6 --- /dev/null +++ b/Symphogear/XV [BD]/01/ep1_patch_patch.vpy @@ -0,0 +1,96 @@ +import vapoursynth as vs +import lvsfunc as lvf +import kagefunc as kgf +import mvsfunc as mvf +import vsutil + +from ytttfunc.adaptivegrain import adaptive_grain +from ytttfunc.replace_ranges import replace_ranges +from functools import partial + +def mask_with_ref(clip_a, clip_b, range, rframe): + mask = core.std.Expr([clip_b[rframe], clip_a[rframe]], 'x y - abs') + mask = vsutil.iterate(mask, core.std.Maximum, 4) + mask = mask.std.Binarize(4000) + return replace_ranges(clip_a, core.std.MaskedMerge(clip_a, clip_b, mask), range) + +core = vs.core +core.max_cache_size = 1024 + +LOGO = [(20777, 20942)] +NO_SCALE = [(30836, 33230), (34463, 34553)] +FORCE_SCALE = [(4015, 5159)] +DESCALE_MASK = [(256, 1546)] +DEBAND_HARD = [(4120, 4210)] +DEBAND_HARDER = [(4138, 4174)] + +src_ep = core.lsmas.LWLibavSource("bdmv/KIXA_90888/BDMV/STREAM/00003.m2ts") +src_pv = core.lsmas.LWLibavSource("bdmv/KIXA_90888/BDMV/STREAM/00004.m2ts")[:-24] +src = src_ep + src_pv +src = src.fmtc.bitdepth(bits=16) + +# mkvmerge --split frames:1547,3900,4215 -o ep1_split_%1d.mkv ep1_bd.mp4 +# i r encode good +# mkvmerge --split frames:944,1039 -o ep1_split_1_split_%1d.mkv ep1_split_1.mkv +split_src1_1 = core.ffms2.Source("ep1_split_1_split_1.mkv") +split_src1_2 = core.ffms2.Source("ep1_split_1_split_2.mkv") +split_src1_3 = core.ffms2.Source("ep1_split_1_split_3.mkv") +split_src2 = core.ffms2.Source("ep1_split_2.mkv") +split_src3 = core.ffms2.Source("ep1_split_3.mkv") +split_src4 = core.ffms2.Source("ep1_split_4.mkv") + +denoisechroma = core.knlm.KNLMeansCL(src, d=1, a=2, h=0.45, channels="UV", device_type='gpu', device_id=0) +denoiseluma = core.knlm.KNLMeansCL(src, d=3, a=2, h=0.4, channels="Y", device_type='gpu', device_id=0) +denoise = core.std.ShufflePlanes([denoiseluma, denoisechroma], planes=[0, 1, 2], colorfamily=vs.YUV) + +logo_mask = core.imwri.Read("mask_2.png") +logo_mask = logo_mask.resize.Bilinear(format=src.format.id, matrix_s="709") + +Y = vsutil.get_y(denoise) + +def sraa_frameeval(n, clip): + frame = clip.get_frame(n) + if frame.height < 1080: + rfactor = 2.5 + else: + rfactor = 1.5 + return lvf.upscaled_sraa(clip.resize.Bicubic(frame.width, frame.height), rfactor=rfactor, h=1080, ar=16/9) + +edge = kgf.retinex_edgemask(Y, .0001).std.Binarize(10000) + +Ys = lvf.smart_descale(Y, [871, 872, 873], kernel="bicubic", b=1/3, c=1/3, thr=0.003) +Yf = lvf.smart_descale(Y, [871, 872, 873], kernel="bicubic", b=1/3, c=1/3, thr=0) +Yd = replace_ranges(Ys, Yf, FORCE_SCALE) +Yd = Yd.resize.Bicubic(format=vs.GRAY16) +Yr = Yd.resize.Bicubic(1920, 1080, filter_param_a=1/3, filter_param_b=1/3) +Ysraa = Yd.std.FrameEval(partial(sraa_frameeval, clip=Yd)) +Ysraa = Ysraa.resize.Spline36(1920, 1080, format=vs.GRAY16) +Yline = core.std.MaskedMerge(Y, Ysraa, edge) +text_mask = core.std.Expr([Y, Yr], 'x y - abs') +text_mask = vsutil.iterate(text_mask, core.std.Maximum, 4) +text_mask = text_mask.std.Binarize(4000) +Ydmask = core.std.MaskedMerge(Yline, Y, text_mask) +Ydmask = mask_with_ref(Ydmask, Y, [(943, 1026)], 960) +Yfinal = replace_ranges(Yline, Ydmask, DESCALE_MASK) + +scaled = core.std.ShufflePlanes([Yfinal, denoise], planes=[0, 1, 2], colorfamily=vs.YUV) + +logo_merge = core.std.MaskedMerge(scaled, denoise, logo_mask) + +scaled = replace_ranges(scaled, denoise, NO_SCALE) +scaled = replace_ranges(scaled, logo_merge, LOGO) + +line = kgf.retinex_edgemask(scaled).std.Binarize(9500).rgvs.RemoveGrain(3).std.Inflate() +nf3kdb = scaled.neo_f3kdb.Deband(range=18, y=32, cb=24, cr=24, grainy=24, grainc=0, output_depth=16, sample_mode=4) +nf3kdb = core.std.MaskedMerge(nf3kdb, scaled, line) +placebo = scaled.placebo.Deband(iterations=3, threshold=3, radius=24, grain=4) +placebo2 = scaled.placebo.Deband(iterations=3, threshold=5, radius=32, grain=4) +deband = replace_ranges(nf3kdb, placebo, DEBAND_HARD) +deband = replace_ranges(deband, placebo2, DEBAND_HARDER) + +patchpatch = deband[split_src1_1.num_frames:-1*(split_src1_3.num_frames+split_src2.num_frames+split_src3.num_frames+split_src4.num_frames)] # uncooporative intro credit + +final = patchpatch +final = adaptive_grain(final, 0.3) +final = core.fmtc.bitdepth(final, bits=10, dmode=3) +final.set_output() \ No newline at end of file diff --git a/Symphogear/XV [BD]/settings b/Symphogear/XV [BD]/settings new file mode 100644 index 0000000..ed1ef57 --- /dev/null +++ b/Symphogear/XV [BD]/settings @@ -0,0 +1,5 @@ +01-02: +x264 - --demuxer y4m --input-depth 10 --output-depth 10 --colormatrix bt709 --colorprim bt709 --transfer bt709 --preset slower --crf 16 --bframes 16 --aq-mode 3 --aq-strength 0.85 --qcomp 0.70 --no-dct-decimate --no-fast-pskip --psy-rd 0.85:0.0 --merange 20 + +03-13: +x264 - --demuxer y4m --input-depth 10 --output-depth 10 --colormatrix bt709 --colorprim bt709 --transfer bt709 --preset slower --crf 16 --bframes 16 --aq-mode 3 --aq-strength 0.85 --qcomp 0.70 --no-dct-decimate --no-fast-pskip --psy-rd 0.85:0.0 --merange 20 --deblock -1:-1