I'm trying to make a master script in AVISynth for my filtering. Some videos need different filters for different parts and I'm kind of tired of juggling trim statement and variables. At the moment I've got this:
The idea being I can just add a new scene to the list by just adding two lines to the ApplyFilters section. This one I'm making for Merlin at the moment which is rather simple but some shows need different cropping in almost every scene so I need to be able to easily add a part in the middle - which up to now has been a pain. Unfortunately this isn't working at the moment and I'm not sure how to fix it.Code:function applyfilters(clip "Vin", int "Cut1", string "Cut1f",int "Cut2", string "Cut2f", int "Cut3", string "Cut3f", int "Cut4", string "Cut4f", int "Cut5", string "Cut5f", int "Cut6", string "Cut6f", int "Cut7", string "Cut7f", int "Cut8", string "Cut8f", int "Cut9", string "Cut9f", int "Cut10", string "Cut10f", int "Cut11", string "Cut11f", int "Cut12", string "Cut12f", int "Cut13", string "Cut13f", int "Cut14", string "Cut14f", int "Cut15") { V1 = trim(Vin, Cut1, Cut2-1).Eval(Cut1f) Cut2>1?(V1=(V1++trim(Vin, Cut2, Cut3-1).Eval(Cut2f))):return V1 Cut3>1?(V1=(V1++trim(Vin, Cut3, Cut4-1).Eval(Cut3f))):return V1 Cut4>1?(V1=(V1++trim(Vin, Cut4, Cut5-1).Eval(Cut4f))):return V1 Cut5>1?(V1=(V1++trim(Vin, Cut3, Cut6-1).Eval(Cut5f))):return V1 Cut6>1?(V1=(V1++trim(Vin, Cut3, Cut7-1).Eval(Cut6f))):return V1 Cut7>1?(V1=(V1++trim(Vin, Cut3, Cut8-1).Eval(Cut7f))):return V1 Cut8>1?(V1=(V1++trim(Vin, Cut3, Cut9-1).Eval(Cut8f))):return V1 Cut9>1?(V1=(V1++trim(Vin, Cut3, Cut10-1).Eval(Cut9f))):return V1 Cut10>1?(V1=(V1++trim(Vin, Cut3, Cut11-1).Eval(Cut10f))):return V1 Cut11>1?(V1=(V1++trim(Vin, Cut3, Cut12-1).Eval(Cut11f))):return V1 Cut12>1?(V1=(V1++trim(Vin, Cut3, Cut13-1).Eval(Cut12f))):return V1 Cut13>1?(V1=(V1++trim(Vin, Cut3, Cut14-1).Eval(Cut13f))):return V1 Cut14>1?(V1=(V1++trim(Vin, Cut3, Cut15-1).Eval(Cut14f))):return V1 } mpeg2source("Video 1.d2v", cpu=4) applyfilters(\ 0,\ "fft3dfilter(sigma=2)",\ 1,\ "AssumeTFF().QTGMC(Preset="Placebo").SelectEven().fft3dfilter(sigma=2, plane=4).ColorYUV(gamma_y=600, off_y=-40).Sharpen(0.5,1.0).Blur(1.0,0.5).ColorYUV(gain_y=-30)",\ 1,\ "fft3dfilter(sigma=2)",\ 1\ ) Crop(6,4,-4,-4)
+ Reply to Thread
Results 1 to 7 of 7
-
Last edited by ndjamena; 22nd Apr 2014 at 00:02.
-
If anyone is interested:
Code:function AFP(clip "Vin", clip "Cut1f", int "Cut2", clip "Cut2f", int "Cut3", clip "Cut3f", int "Cut4", clip "Cut4f", int "Cut5", clip "Cut5f", int "Cut6", clip "Cut6f", int "Cut7", clip "Cut7f", int "Cut8", clip "Cut8f", int "Cut9", clip "Cut9f", int "Cut10", clip "Cut10f", int "Cut11", clip "Cut11f", int "Cut12", clip "Cut12f", int "Cut13", clip "Cut13f", int "Cut14", clip "Cut14f", int "Cut15", clip "Cut15f", int "Cut16", clip "Cut16f", int "Cut17", clip "Cut17f", int "Cut18", clip "Cut18f", int "Cut19", clip "Cut19f", int "Cut20", clip "Cut20f", int "Cut21", clip "Cut21f", int "Cut22", clip "Cut22f", int "Cut23", clip "Cut23f", int "Cut24", clip "Cut24f", int "Cut25", clip "Cut25f", int "Cut26", clip "Cut26f", int "Cut27", clip "Cut27f") { CALC1 = 0.0 CALC2 = 0.0 Cut2 = ABS(Default(Cut2, 1)) Cut3 = ABS(Default(Cut3, 1)) Cut4 = ABS(Default(Cut4, 1)) Cut5 = ABS(Default(Cut5, 1)) Cut6 = ABS(Default(Cut6, 1)) Cut7 = ABS(Default(Cut7, 1)) Cut8 = ABS(Default(Cut8, 1)) Cut9 = ABS(Default(Cut9, 1)) Cut10 = ABS(Default(Cut10, 1)) Cut11 = ABS(Default(Cut11, 1)) Cut12 = ABS(Default(Cut12, 1)) Cut13 = ABS(Default(Cut13, 1)) Cut14 = ABS(Default(Cut14, 1)) Cut15 = ABS(Default(Cut15, 1)) Cut16 = ABS(Default(Cut16, 1)) Cut17 = ABS(Default(Cut17, 1)) Cut18 = ABS(Default(Cut18, 1)) Cut19 = ABS(Default(Cut19, 1)) Cut20 = ABS(Default(Cut20, 1)) Cut21 = ABS(Default(Cut21, 1)) Cut22 = ABS(Default(Cut22, 1)) Cut23 = ABS(Default(Cut23, 1)) Cut24 = ABS(Default(Cut24, 1)) Cut25 = ABS(Default(Cut25, 1)) Cut26 = ABS(Default(Cut26, 1)) Cut27 = ABS(Default(Cut27, 1)) Cut1f = Default(Cut1f, Vin) Cut2f = (Cut2<2)?Vin:Default(Cut2f, Vin) Cut3f = (Cut3<2)?Vin:Default(Cut3f, Vin) Cut4f = (Cut4<2)?Vin:Default(Cut4f, Vin) Cut5f = (Cut5<2)?Vin:Default(Cut5f, Vin) Cut6f = (Cut6<2)?Vin:Default(Cut6f, Vin) Cut7f = (Cut7<2)?Vin:Default(Cut7f, Vin) Cut8f = (Cut8<2)?Vin:Default(Cut8f, Vin) Cut9f = (Cut9<2)?Vin:Default(Cut9f, Vin) Cut10f = (Cut10<2)?Vin:Default(Cut10f, Vin) Cut11f = (Cut11<2)?Vin:Default(Cut11f, Vin) Cut12f = (Cut12<2)?Vin:Default(Cut12f, Vin) Cut13f = (Cut13<2)?Vin:Default(Cut13f, Vin) Cut14f = (Cut14<2)?Vin:Default(Cut14f, Vin) Cut15f = (Cut15<2)?Vin:Default(Cut15f, Vin) Cut16f = (Cut16<2)?Vin:Default(Cut16f, Vin) Cut17f = (Cut17<2)?Vin:Default(Cut17f, Vin) Cut18f = (Cut18<2)?Vin:Default(Cut18f, Vin) Cut19f = (Cut19<2)?Vin:Default(Cut19f, Vin) Cut20f = (Cut20<2)?Vin:Default(Cut20f, Vin) Cut21f = (Cut21<2)?Vin:Default(Cut21f, Vin) Cut22f = (Cut22<2)?Vin:Default(Cut22f, Vin) Cut23f = (Cut23<2)?Vin:Default(Cut23f, Vin) Cut24f = (Cut24<2)?Vin:Default(Cut24f, Vin) Cut25f = (Cut25<2)?Vin:Default(Cut25f, Vin) Cut26f = (Cut26<2)?Vin:Default(Cut26f, Vin) Cut27f = (Cut27<2)?Vin:Default(Cut27f, Vin) CALC2=Max(((Float(Cut1f.framecount)/Float(Vin.framecount))*Float(Cut2)), 1.0) Trim(Cut1f, 0, int(CALC2)-1) CALC1 = CALC2 CALC2=Max(((Float(Cut2f.framecount)/Float(Vin.framecount))*Float(Cut3)), 1.0) Cut2>1?last++Trim(Cut2f, int(CALC1), int(CALC2) -1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut3f.framecount)/Float(Vin.framecount))*Float(Cut4)), 1.0) Cut3>1?last++Trim(Cut3f, int(CALC1), int(CALC2) -1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut4f.framecount)/Float(Vin.framecount))*Float(Cut5)), 1.0) Cut4>1?last++Trim(Cut4f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut5f.framecount)/Float(Vin.framecount))*Float(Cut6)), 1.0) Cut5>1?last++Trim(Cut5f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut6f.framecount)/Float(Vin.framecount))*Float(Cut7)), 1.0) Cut6>1?last++Trim(Cut6f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut7f.framecount)/Float(Vin.framecount))*Float(Cut8)), 1.0) Cut7>1?last++Trim(Cut7f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut8f.framecount)/Float(Vin.framecount))*Float(Cut9)), 1.0) Cut8>1?last++Trim(Cut8f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut9f.framecount)/Float(Vin.framecount))*Float(Cut10)), 1.0) Cut9>1?last++Trim(Cut9f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut10f.framecount)/Float(Vin.framecount))*Float(Cut11)), 1.0) Cut10>1?last++Trim(Cut10f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut11f.framecount)/Float(Vin.framecount))*Float(Cut12)), 1.0) Cut11>1?last++Trim(Cut11f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut12f.framecount)/Float(Vin.framecount))*Float(Cut13)), 1.0) Cut12>1?last++Trim(Cut12f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut13f.framecount)/Float(Vin.framecount))*Float(Cut14)), 1.0) Cut13>1?last++Trim(Cut13f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut14f.framecount)/Float(Vin.framecount))*Float(Cut15)), 1.0) Cut14>1?last++Trim(Cut14f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut15f.framecount)/Float(Vin.framecount))*Float(Cut16)), 1.0) Cut15>1?last++Trim(Cut15f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut16f.framecount)/Float(Vin.framecount))*Float(Cut17)), 1.0) Cut16>1?last++Trim(Cut16f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut17f.framecount)/Float(Vin.framecount))*Float(Cut18)), 1.0) Cut17>1?last++Trim(Cut17f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut18f.framecount)/Float(Vin.framecount))*Float(Cut19)), 1.0) Cut18>1?last++Trim(Cut18f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut19f.framecount)/Float(Vin.framecount))*Float(Cut20)), 1.0) Cut19>1?last++Trim(Cut19f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut20f.framecount)/Float(Vin.framecount))*Float(Cut21)), 1.0) Cut20>1?last++Trim(Cut20f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut21f.framecount)/Float(Vin.framecount))*Float(Cut22)), 1.0) Cut21>1?last++Trim(Cut21f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut22f.framecount)/Float(Vin.framecount))*Float(Cut23)), 1.0) Cut22>1?last++Trim(Cut22f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut23f.framecount)/Float(Vin.framecount))*Float(Cut24)), 1.0) Cut23>1?last++Trim(Cut23f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut24f.framecount)/Float(Vin.framecount))*Float(Cut25)), 1.0) Cut24>1?last++Trim(Cut24f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut25f.framecount)/Float(Vin.framecount))*Float(Cut26)), 1.0) Cut25>1?last++Trim(Cut25f, int(CALC1), int(CALC2)-1):NOP() CALC1 = CALC2 CALC2=Max(((Float(Cut26f.framecount)/Float(Vin.framecount))*Float(Cut27)), 1.0) Cut26>1?last++Trim(Cut26f, int(CALC1), int(CALC2)-1):NOP() Cut26>1?last++Trim(Cut27f, int(CALC2), 0):NOP() return last }
Code:function daa3chroma(clip c) { dbl = merge(c.nnedi3(field = 1, nns = 1),c.nnedi3(field = 0, nns = 1)).converttoyv12(interlaced=false) dblD = mt_makediff(c,dbl,U=3,V=3) shrpD = mt_makediff(dbl,dbl.removegrain(11),U=3,V=3) DD = shrpD.repair(dblD,13) return mergechroma(c.converttoyv12(interlaced=false), dbl.mt_adddiff(DD,U=3,V=3)) } function DoFreo(clip FreoClip) { Mask = GreyScale(FreoClip).Blur(0.75).Deen("a2d", 3, 8, 12).ColorYUV(off_y=-32).ColorYUV(gain_y=512).Invert().ConvertToRGB() BackGround = Crop(FreoClip, 10, 10, 32, 32).Blur(1.58).Blur(1.58).Deen("a2d", 5, 20, 20).TemporalSoften(12, 10, 10).TemporalSoften(12, 10, 10).PointResize(FreoClip.width, FreoClip.height).ConvertToRGB() ForeGround = deen(FreoClip, "a2d",2,10,12).LSFMOD(defaults="slow").ConvertToRGB() return Layer(ForeGround, Mask(BackGround,Mask)).ConvertToYV12(interlaced=false) } MPEG2SOURCE("Video 1.d2v", cpu=4) a1 = Daa3Chroma().EdgeCleaner() a = Merge(FFT3dFilter(a1, sigma=1.5, bt=5, bw=32, bh=32, ow=16, oh=16, sharpen=0.4, plane=4), FFT3dFilter(a1, sigma=1.5, bt=5, bw=64, bh=64, ow=32, oh=32, sharpen=0.4, plane=4)).NNEDI3_Resize16(1024,576,2,2,-3,-2) #Main Program b = a #Blank Frames c = -1 d = GreyScale().ConvertToYV12(interlaced=false).ColorYUV(off_y=-255).PointResize(1024,576) #Credits e = -1 f = GreyScale().QTGMC(Preset="Placebo").SelectEven().EdgeCleaner(strength=13).Blur(0.25).Deen("a2d", 3, 8, 12).ColorYUV(gain_y=128).NNEDI3_Resize16(1024,576,2,2,-3,-2).FFT3dFilter(sigma=5, bt=5, bw=32, bh=32, ow=16, oh=16, sharpen=0.4, plane=4).Blur(0.25).ColorYUV(off_y=-24).ColorYUV(gain_y=128).LSFMOD(defaults="slow") #Blank Frames g = -1 h = d #Shine Logo i = -1 j = a #Fremantle Media Logo k = -1 l = DoFreo(a) #End m = -1 n = a AFP(a, b, c, d, e, f, g, h, i, j, k, l ,m, n) FFT3dFilter(sigma=0.5, bt=5, bw=32, bh=32, ow=16, oh=16, sharpen=0.2, plane=4)
Possibly a waste of time, but I enjoyed itLast edited by ndjamena; 22nd Apr 2014 at 00:13.
-
To save yourself a lot of work just use ReplaceFramesSimple which is part of stickboy's RemapFrames filter:
http://www.avisynth.nl/users/stickboy/
It looks to me like you're trying to reinvent the wheel. When you have a lot of filters to use on different sections of video, many being repeated, ReplaceFramesSimple is the way to go. -
OK, thankyou. I actually found a reference to stickboy's scripts during my searching but the link supplied pointed to the old site which doesn't work anymore and I stupidly assumed it had been discontinued. There's a lot of stuff there but I found ReplaceFramesSimple and although it looks like it would make my script simpler I don't she how it would directly address the problem I was trying to solve. This was my script for 'Blackadder - 1x06', it's already been through QTGMC:
Code:AVISOURCE("Blackadder - 01x06.avi").FFT3DFILTER(sigma=2, plane=4) a=trim(0,2371).nnedi3_resize16(720,576,8,-10,-17,-10) b=trim(2372,2485).nnedi3_resize16(720,576,8,20,-42,-20) c=trim(2486,2685).nnedi3_resize16(720,576,8,12,-22,-12) d=trim(2686,2793).nnedi3_resize16(720,576,8,20,-42,-20) e=trim(2794,3177).nnedi3_resize16(720,576,16,12,-14,-12) f=trim(3178,13633).nnedi3_resize16(720,576,8,8,-12,-8) g=trim(13634,14795).nnedi3_resize16(720,576,8,10,-17,-10) h=trim(14796,15289).nnedi3_resize16(720,576,18,12,-12,-12) i=trim(15290,17337).nnedi3_resize16(720,576,13,12,-17,-12) j=trim(17338,18157).nnedi3_resize16(720,576,8,10,-17,-10) k=trim(18158,28331).nnedi3_resize16(720,576,8,8,-12,-8) l=trim(28332,29367).nnedi3_resize16(720,576,8,10,-17,-10) m=trim(29368,85144).nnedi3_resize16(720,576,8,8,-12,-8) n=trim(85145,85855).nnedi3_resize16(720,576,8,10,-17,-10) o=trim(85856,86201).nnedi3_resize16(720,576,16,14,-19,-14) p=trim(86202,87997).nnedi3_resize16(720,576,8,10,-17,-10) q=trim(87998,0).nnedi3_resize16(720,576,8,16,-32,-16) a++b++c++d++e++f++g++h++i++j++k++l++m++n++o++p++q
-
B=Last.nnedi3_resize16(720,576,8,-10,-17,-10)#that first -10 is a typo?
ReplaceFramesSimple(Last,B,Mappings="[0 2371] [13634 14795] [17338 18157] [28332 29367] [85145 85855] [86202 87997]")
B=Last.nnedi3_resize16(720,576,8,20,-42,-20)
ReplaceFramesSimple(Last,B,Mappings="[2372 2485] [2686 2793] ")
B=Last.nnedi3_resize16(720,576,8,12,-22,-12)
ReplaceFramesSimple(Last,B,Mappings="[2486 2685]")
B=Last.nnedi3_resize16(720,576,16,12,-14,-12)
ReplaceFramesSimple(Last,B,Mappings="[2794 3177]")
B=Last.nnedi3_resize16(720,576,8,8,-12,-8)
ReplaceFramesSimple(Last,B,Mappings="[3178 13633] [18158 28331] [28332 29367]")
B=Last.nnedi3_resize16(720,576,18,12,-12,-12)
ReplaceFramesSimple(Last,B,Mappings="[14796 15289]")
B=Last.nnedi3_resize16(720,576,13,12,-17,-12)
ReplaceFramesSimple(Last,B,Mappings="[15290 17337]")
B=Last.nnedi3_resize16(720,576,16,14,-19,-14)
ReplaceFramesSimple(Last,B,Mappings="[85856 86201]")
B=Last.nnedi3_resize16(720,576,8,16,-32,-16)
ReplaceFramesSimple(Last,B,Mappings="[87998 0]")#requires the actual last frame number and not '0'
I think that'll do it. I don't do audio in my scripts but the doc says it's unaffected.
There were more scenes that needed alternate croppings but I gave up and encoded it at that point
You can make 'templates' with a whole bunch of:
B=Last.nnedi3_resize16(720,576,0,0,0,0)
ReplaceFramesSimple(Last,B,Mappings=" ")#nothing in between the parentheses
in the script and nothing will happen until you begin to fill in the crop values and frame numbers. You can do the same with other kinds of filtering. I use it most often for Levels and Tweak filtering scene-by-scene and have templates set up for that purpose so I don't have to type a bunch of stuff, or do a lot of copying and pasting, when I want to use ReplaceFramesSimple. Maybe someone else will come along and show a more efficient way to use it, or to do what you want, but this works for me and I find it intuitive as well.Last edited by manono; 15th Oct 2013 at 13:49.
-
Yup, and yet it worked (maybe there's ABS functions in that script too) :P
I've played GemTD on StarCraft 2 and have seen some players place stones in seemly random positions on the map and somehow come up with a flawless, functioning maze. Personally I need things organized in a simple linear way so my mind can encompass it and I'd get lost using ReplaceFramesSimple the way you did there. Actually, it seems only marginally less complicated than using masses of trims, or moreso if you take into account that scenes are no longer listed in a linear fashion. For now I'll see how my script pans out, I had to remove Eval() because it used too much memory and destroyed any multithreading capabilities. If it was just Merlin, ReplaceFramesSimple would be ideal as it's just the credits that need replacing, but I want a script that I can use for everything without my brain sputtering and dying.
Similar Threads
-
How can i Use VDub Script[.vcf] into Avisynth Script[.avs] ( Megui )
By Maskoff in forum EditingReplies: 1Last Post: 25th Jun 2013, 15:30 -
avs script giving me fits
By willmoodom in forum Newbie / General discussionsReplies: 32Last Post: 30th Sep 2009, 03:43 -
How do I create an AVS script
By Sopt Finder in forum Newbie / General discussionsReplies: 4Last Post: 15th Jun 2009, 13:17 -
AVS script and Subtitle Workshop
By sambat in forum SubtitleReplies: 3Last Post: 19th Apr 2009, 10:20 -
This correct avs script for this source?
By alcOre in forum Newbie / General discussionsReplies: 2Last Post: 13th Feb 2009, 01:24