View difference between Paste ID: 2JPC88Lc and LC4pB1Sg
SHOW: | | - or go back to the newest paste.
1-
# avisynth script template for cel anime dvds that contain field blending/aliasing, dot-crawl and rainbowing.
1+
# avisynth script template for cel anime dvds (or laserdiscs) that contain field blending/aliasing, dot-crawl and rainbowing.
2
# note: this thing tries to be mild, since the creator doesn't believe in overfiltering and destroying the original sources.
3
4
function daa3slow(clip c) {
5
dbl   = merge(c.nnedi3(etype=1, field = 1, nns = 4, qual=2, nsize = 3,fapprox = 7,pscrn=1),c.nnedi3(etype=1, field = 0, nns = 4, qual=2, nsize = 3,fapprox = 7,pscrn=1))
6
dblD = mt_makediff(c,dbl,U=3,V=3)
7
shrpD = mt_makediff(dbl,dbl.removegrain(11),U=3,V=3)
8
DD = shrpD.repair(dblD,13)
9
return dbl.mt_adddiff(DD,U=3,V=3) }
10
11
#or use this faster version if daa3slow is too fast for you:
12
function daa3(clip c) {
13
dbl   = merge(c.nnedi3(etype=1, field = 1, nns = 2,nsize = 3,fapprox = 7,pscrn=1),c.nnedi3(etype=1, field = 0, nns = 2, nsize = 3,fapprox = 7,pscrn=1))
14
dblD = mt_makediff(c,dbl,U=3,V=3)
15
shrpD = mt_makediff(dbl,dbl.removegrain(11),U=3,V=3)
16
DD = shrpD.repair(dblD,13)
17
return dbl.mt_adddiff(DD,U=3,V=3) }
18
19
20
21
# Here comes your video source line (your video must still be interlaced - it gets IVTCed/decimated as a first step, below)
22
# Input a lossless encode of the captured video (made through virtualdub I guess). Could be a mkv,
23
# but then you would need fffvideosource() isntead
24
# for dvd, use dgindex/dgdecode source instead.
25
26
avisource("c:\something\yoursource.avi")
27
28
29
# inverse telecine + decimation, to get to 24 fps.
30-
#assumetff()
30+
31
# the following line to make TFM() work.
32
33
assumetff()
34
35
#if dot crawl is very strong and this script isn't removing it enough, you can uncomment this line, but it can hurt details a bit
36
#TComb(mode=0,fthreshl=2,fthreshc=1,othreshl=1,othreshc=6,map=false,scthresh=12.0)
37
38
39
tfm(slow=2,pp=1,mode=2).tdecimate()
40
assumefps(24000,1001)
41
42
43
44
# Here comes a hack against dot crawl - it doesn't remove it 100%ly, but is rather detail safe.
45
# It however needs that the file "noisepattern.avi" must be present in the location specified below.
46
# That video contains a sample of dot-crawl noise to serve as a 'training' for fft3dfilter.
47
# it is a sample video from a lousy ADV DVD... ask and ye shall be given, I guess?
48
# try htttp://ulozto.net/x493J9tg/noisepattern-avi
49
50
# also, your video needs to be 720x480 here - crop at the end of the script instead
51
52
src = last
53
54
55
# change the path of the noisepattern.avi file to wherever you put it
56
avisource("c:\pattern\noisepattern.avi") + last
57
58
unf = last
59
fft3dfilter(sigma= 1.7500, plane=0,bw=8,bh=8)
60
den = last
61
denoisediff = mt_makediff(unf,den,U=3,V=3)
62
fft3dfilter(sigma= 0.01, pframe = 0, px = 34,py = 18, plane=0,pfactor =0.7,pcutoff=0.01,pshow=false,bw=8,bh=8)
63
mt_adddiff(denoisediff,U=3,V=3)
64
trim(1,0)
65
66
67
# Now we will derainbow. Again, rather detail safe, but some limited discoloration can happen.
68
# Current derainbowing methods available are sadly far form perfect.
69
70
prerb = last
71
derbmask = removegrainhd(rank=23,radius=6).tedgemask(threshY=8).mt_inflate()
72
73
prefiltered = last
74
derbsuperfilt = MSuper(prefiltered)
75
derbsuper = derbsuperfilt
76
derbbackward_vectors = MAnalyse(derbsuperfilt, truemotion = true, isb = true, chroma=false)
77
derbforward_vectors = MAnalyse(derbsuperfilt, truemotion = true, isb = false, chroma=false)
78
derbforward_compensation = MCompensate(derbsuper, derbforward_vectors)
79
derbbackward_compensation = MCompensate(derbsuper, derbbackward_vectors)
80
interleave(derbforward_compensation,last,derbbackward_compensation)
81
dfmderainbow(maskthresh=10)
82
selectevery(3,1)
83
mt_merge(prerb,last, derbmask,luma=true)
84
85
86
# now antialising (your video should still be 720x480 here - or at least should have height divisible by 4)
87
# this line covers up nasty aliasing and interlacing artifacts (combing) that are left from field blends.
88
# It nicely smooths those nasties and is still quite nice to detail.
89
# The daa3slow() function is defined at the start of this script.
90
91
spline36resize(width,height*3/2).daa3slow.spline36resize(width,height)
92
93
#now we will stabilise lines/edges, it also helps against some dot crawl and shimmering. It should be detail-safe, though not 100%.
94
95
source = last
96
97
prefilt = last.removegrain(6).FFT3Dfilter(sigma=1.5,bw=16,bh=16,bt=3,ow=8,oh=8,plane=4)
98
superfilt = prefilt.MSuper(pel=2, sharp=1)
99
super = MSuper(pel=2, sharp=1)
100
backward_vec2 = MAnalyse(superfilt, isb = true, delta = 2, overlap=4)
101
backward_vec1 = MAnalyse(superfilt, isb = true, delta = 1, overlap=4)
102
forward_vec1 = MAnalyse(superfilt, isb = false, delta = 1, overlap=4)
103
forward_vec2 = MAnalyse(superfilt, isb = false, delta = 2, overlap=4)
104-
#You can crop now. Also, add denoising filters now if desired. /Please be gentle ;)/
104+
105
106
degrainedge = source.MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=230)
107
edgemask = removegrainhd(rank=25,radius=6).tedgemask(threshY=8)
108
109
mt_merge(source,degrainedge,edgemask,luma=true)
110
111
#You can crop now. Also, add denoising filters now if desired. /Please be gentle ;)/
112
#for example:
113
#crop(4,0,-4,0)