Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys, os
- sys.path.append(os.getenv('APPDATA') + r"\VapourSynth\scripts")
- import vapoursynth as vs
- import havsfunc as haf
- from fractions import Fraction
- def select30(vid, start, end, a=0, b=0, c=0, d=0, show=None):
- core = vs.get_core()
- if end == 0:
- end = vid.num_frames - 1
- return vid[start:end+1:2]
- def select60(vid, start, end, a=0, b=0, c=0, d=0, show=None):
- core = vs.get_core()
- if end == 0:
- end = vid.num_frames - 1
- return vid[start:end+1]
- def select24_naive(vid, start, end, a=0, b=0, c=0, d=0, show=None):
- core = vs.get_core()
- v2 = vid[start:end+1]
- return core.std.SelectEvery(v2, 10, [a,b,c,d])
- def select24(vid, start, end, a=0, b=0, c=0, d=0, show=None):
- core = vs.get_core()
- if end == 0:
- end = vid.num_frames - 1
- vclip = vid[start:end+1]
- if not show or show == 1:
- if vclip.num_frames % 10 == 0:
- return select24_naive(vid, start, end, a, b, c, d)
- else:
- split_point = vclip.num_frames - (vclip.num_frames % 10)
- round_part = vclip[:split_point]
- messy_part = vclip[split_point:]
- clean_picked = core.std.SelectEvery(round_part, 10, [a,b,c,d])
- messy_picked = core.std.SelectEvery(messy_part, 10, [a,b,c,d])
- inframes = messy_part.num_frames
- vid_spf = Fraction(1001, 60000)
- new_spf = vid_spf * inframes / messy_picked.num_frames
- messy_picked = core.std.AssumeFPS(messy_picked, fpsnum=new_spf.denominator,
- fpsden=new_spf.numerator)
- return core.std.Splice([clean_picked, messy_picked])
- elif show == 4:
- return show4(vclip, a, b, c, d).text.Text('{}-{}: {},{},{},{}'.format(start,end,a,b,c,d), 9)
- elif show == 10:
- return show10(vclip, a, b, c, d)
- else:
- return core.text.Text(vid, 'Invalid value for "show"')
- def select24blur(vid, start, end):
- core = vs.get_core()
- trimmed = vid[start:end+1]
- super = core.mv.Super(trimmed)
- bvec = core.mv.Analyse(super, isb=True, delta=2)
- fvec = core.mv.Analyse(super, delta=2)
- blur = core.mv.FlowBlur(trimmed, super, bvec, fvec, blur=105)
- flowed = core.mv.FlowFPS(blur, super, bvec, fvec, num=24000, den=1001)
- return flowed
- def show10(vid, a, b, c, d):
- core = vs.get_core()
- w_out = int(vid.width * .6)
- h_out = int(vid.height * .6)
- if w_out % 2 == 1:
- w_out += 1
- if h_out % 2 == 1:
- h_out += 1
- svid = core.resize.Bilinear(vid, w_out, h_out, filter_param_a=-.5, filter_param_b=0.25)
- splitframes = []
- for i in range(10):
- splitframes.append(core.std.SelectEvery(svid, 10, i))
- bclip = core.std.BlankClip(splitframes[0])
- splitframes[a] = highlight_edge(splitframes[a])
- splitframes[b] = highlight_edge(splitframes[b])
- splitframes[c] = highlight_edge(splitframes[c])
- splitframes[d] = highlight_edge(splitframes[d])
- r1 = core.std.StackHorizontal(splitframes[0:4])
- r2 = core.std.StackHorizontal(splitframes[4:7] + [bclip])
- r3 = core.std.StackHorizontal(splitframes[7:10] + [bclip])
- return core.std.StackVertical([r1,r2,r3])
- def highlight_edge(vid):
- core = vs.get_core()
- return core.std.CropRel(vid, 6,6,4,4).std.AddBorders(6,6,4,4, [19456,21504,65535])
- def show4(vid, a, b, c, d):
- core = vs.get_core()
- fa = core.std.SelectEvery(vid, 10, a).text.Text(str(a))
- fb = core.std.SelectEvery(vid, 10, b).text.Text(str(b))
- fc = core.std.SelectEvery(vid, 10, c).text.Text(str(c))
- fd = core.std.SelectEvery(vid, 10, d).text.Text(str(d))
- t = core.std.StackHorizontal([fa, fb])
- b = core.std.StackHorizontal([fc, fd])
- return core.std.StackVertical([t, b])
- def zoom(vid, l, t, r, b):
- core = vs.get_core()
- w_out = vid.width - l - abs(r)
- h_out = vid.height - t - abs(b)
- return core.resize.Spline36(vid, src_top=t, src_left=l, src_width=w_out, src_height=h_out)
- def manual_frame_adjust(raw, picked):
- core = vs.get_core()
- vid_spf = Fraction(1001, 60000)
- new_spf = vid_spf * raw.num_frames / picked.num_frames
- #print(new_spf)
- #return(core.text.Text(picked, str(new_spf.denominator)))
- return core.std.AssumeFPS(picked, fpsnum=new_spf.denominator, fpsden=new_spf.numerator)
- core = vs.get_core()
- vid = core.lsmas.LWLibavSource('disc7.mkv')
- vid = vid[0:43310]
- # vid = core.tcomb.TComb(vid, mode=2)
- # vid = core.nnedi3.nnedi3(vid, field=3)
- vid = haf.QTGMC(vid, Preset="very slow", TFF=True, Denoiser="dfttest")
- # vid = core.std.SetFieldBased(vid, 0)
- #vid = core.lsmas.LibavSMASHSource("30_lossless_bobbed.mp4")
- #vid = core.resize.Bilinear(vid, format=vs.YUV420P16)
- vid = core.std.CropRel(vid, 4, 12, 6, 0)
- oin = vid[:5156]#.text.FrameNum(5)
- ain = vid[5156:42920]#.text.FrameNum(5)
- bin = vid[42920:80864]#.text.FrameNum(5)
- ein = vid[80864:85720]#.text.FrameNum(5)
- pin = vid[85720:]#.text.FrameNum(5)
- op = []
- op.append(select30(oin, 0,179))
- op.append(zoom(select24(oin, 180,1649, 1,3,5,9), 2, 2, -2, -3))
- op.append(zoom(select24(oin, 1650, 1833, 1, 3, 5, 7), 0, 0, 0, 0)) # 3.070
- op.append(select30(oin, 1834, 1905))
- op.append(select24(oin, 1906, 2081, 0, 2, 4, 8))
- op.append(select30(oin, 2082, 2133))
- op.append(select24(oin, 2134, 2343, 0, 2, 4, 6))
- op.append(select30(oin, 2344, 2403))
- op.append(select24(oin, 2404, 2477, 0, 2, 4, 6))
- op.append(select24(oin, 2478, 2653, 0, 2, 4, 8))
- op.append(zoom(select30(oin, 2654, 2695), 12, 0, 0, -13))
- op.append(select24(oin, 2696,2759,0,2,4,8))
- op.append(select24(oin, 2760, 2931, 0, 2, 4, 6))
- op.append(select30(oin, 2932, 2981))
- op.append(select24(oin, 2982, 3053, 0, 2, 4, 6))
- r = oin[3054:3125]
- swoop_a = core.std.SelectEvery(r, 10, [1,2,4,6,8,9])
- op.append(manual_frame_adjust(r, swoop_a))
- r = oin[3126:3139]
- swoop_b = core.std.SelectEvery(r, 10, [1,2,4,6,7,9])
- op.append(manual_frame_adjust(r, swoop_b))
- r = oin[3140:3208]
- runner = core.std.DeleteFrames(r, [3,4,7,8,11,12,15,16,18,20,23,24,27,28,30,32,34,36,38,40,42,44,46,48,51,52,54,56,58,60,62,64,66])
- op.append(manual_frame_adjust(r, runner))
- op.append(select30(oin, 3210, 3255))
- op.append(select24(oin, 3256,3475, 0,3,5,8)) #check me
- op.append(select24(oin, 3476,3643, 2,4,6,8))
- op.append(select30(oin, 3644, 3783))
- op.append(select24(oin, 3784,3915, 0,4,6,8))
- op.append(select24(oin, 3916,3999, 0,2,4,8))
- op.append(select24(oin, 4000,4107, 0,2,6,8))
- op.append(select30(oin, 4108,4181))
- op.append(select24(oin, 4182,4209, 0,2,4,6))
- op.append(select24(oin, 4210,4311, 0,2,4,8))
- op.append(select24(oin, 4312,4629, 0,2,4,6))
- op.append(zoom(select24(oin, 4630,0, 0,2,4,6), 2,0,-2,-4))
- oout = core.std.Splice(op, mismatch=True)
- oout = core.std.FreezeFrames(oout, [58], [89], [76])
- vid = oout
- # apart = []
- aout = select24(ain, 0,0, 2,4,7,9)
- # aout = core.std.Splice(apart, mismatch=True)
- aout = core.std.FreezeFrames(aout, [2033,2323,11680,11702,11716,11733,15090], [2055,2404,11692,11707,11724,11761,15104], [2035,2325,11682,11704,11718,11736,15092])
- #bpart = []
- bout = select24(bin, 0,0, 2,4,7,9)
- # freeze starting two, ~27402, ~27607, ~30342
- bout = core.std.FreezeFrames(bout, [0,51,10960,11042,12136,], [26,70,10983,11061,12159], [26,53,10962,11061,12138])
- ed = []
- ed.append(select30(ein, 0,919))
- ed.append(zoom(select30(ein, 920,959), 16, 0, 0, -4))
- ed.append(select30(ein, 960,1113))
- ed.append(zoom(select30(ein, 1114, 1173), 16,0,0,-5))
- ed.append(select30(ein, 1174, 1381))
- ed.append(zoom(select30(ein, 1382, 1401), 0, 0, -13, -6))
- ed.append(zoom(select30(ein, 1402,1441),16,0,0,-5))
- ed.append(select30(ein, 1442,1639))
- ed.append(select24(ein, 1640,2143, 1,3,7,9))
- ed.append(select30(ein, 2144,2665))
- ed.append(select24(ein, 2666,2751, 0,2,4,8))
- ed.append(select24(ein, 2752,2839, 1,3,5,7))
- ed.append(select30(ein, 2840,3293))
- ed.append(select24(ein, 3294,3381, 0,4,6,8))
- ed.append(select24(ein, 3382,3469, 0,2,4,6))
- ed.append(select30(ein, 3470,3887))
- ed.append(select24(ein, 3888,4163, 0,2,4,6))
- ed.append(zoom(select24(ein, 4164,4225, 0,2,4,8), 15, 0,0, -7))
- ed.append(zoom(select24(ein, 4226,4295, 0,2,4,6), 15, 0,0, -7))
- ed.append(select24(ein, 4296,4371, 0,4,6,8))
- ed.append(zoom(select24(ein, 4372,4443, 0,2,4,6), 16,3,0,-5))
- ed.append(select24(ein, 4444,4627, 0,2,4,8))
- ed.append(select24(ein,4628,4851, 0,2,4,6))
- eout = core.std.Splice(ed, mismatch=True)
- eout = core.std.FreezeFrames(eout, [0], [16], [2])
- pv = []
- pv.append(select24(pin, 0,685, 1,4,6,9))
- t = select60(pin, 686,759, 0,2,4,8)
- t2 = core.std.DeleteFrames(t, [0,2,5,6,8,10,11,13,14,15,17,19,21,22,23,25,27,28,31,33,34,36,38,39,40,42,44,45,46,48,49,51,53,55,56,57,59,61,62,64,65,66,68,70,73])
- inframes = t.num_frames
- vid_spf = Fraction(1001, 60000)
- new_spf = vid_spf * inframes / t2.num_frames
- pv.append(core.std.AssumeFPS(t2, fpsnum=new_spf.denominator, fpsden=new_spf.numerator))
- pv.append(select24(pin, 760,0, 2,4,7,9))
- pout = core.std.Splice(pv, mismatch=True)
- pout = core.std.FreezeFrames(pout, [357], [358], [357])
- #vid = core.std.Splice([oout,aout,bout,eout,pout])
- #
- vid = core.resize.Spline36(vid, 640, 480)
- #vid.set_output(1)
- #vid = haf.SMDegrain(vid, contrasharp=True, RefineMotion=True)
- #
- #vid = core.resize.Bilinear(vid, format=vs.YUV420P8, dither_type="ordered")
- # vid = core.text.ClipInfo(vid)
- vid.set_output()
- if __name__ == "__main__":
- prefix = os.path.splitext(__file__)[0]
- f = 0
- qp = ''
- for c in [oout,aout,bout,eout]:
- f += c.num_frames
- qp += '{} K\n'.format(f)
- with open('{}.qpfile'.format(prefix),'w') as q:
- q.write(qp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement