Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 Doom9's Forum Filter to average every N frames?
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 30th November 2014, 18:02 #1  |  Link D9JK Registered User   Join Date: Feb 2010 Posts: 41 Filter to average every N frames? Hello, Is anyone aware of a filter that averages (the entire contents of) every N frames in a clip? For example: "AverageFrames(30)" would take the first 30 frames and create a single, averaged frame out of them, and then move on to the next 30 frames. And so on. In this case, the total clip length is of course reduced to 1/30. To further clarify, "AverageFrames(2)" would be similar to: Code: A = Clip.SelectEven() B = Clip.SelectOdd() Merge(A,B) But how to do this efficiently for, say, every 30 frames?
 30th November 2014, 18:22 #2  |  Link Reel.Deel Registered User   Join Date: Mar 2012 Location: Texas Posts: 1,664 Have you looked at AvgAll or ClipBlend? Last edited by Reel.Deel; 30th November 2014 at 18:39. Reason: typo
 30th November 2014, 20:42 #3  |  Link StainlessS HeartlessS Usurer     Join Date: Dec 2009 Location: Over the rainbow Posts: 10,980 Dont think ClipBlend would suit, ClipBlend can output average of previous 30 frames with same o/p as i/p frame count. If you jump about in the stream [eg SelectEvery(30,29)] then it will 'reset' itself (throw away accumulated ave data) and start accumulating again, so for every output frame it would reset accumulator and would be no different to a simple SelectEvery(30,29). You could however do it in two passes Code: AviSource("d:\1.avi") ClipBlend(Delay=30-1) Code: AviSource("d:\2.avi") SelectEvery(30,29) Untested but should work I think. EDIT: "average of previous 30 frames" should read "average of previous 29 + current frames". __________________ I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 30th November 2014 at 20:53.
 30th November 2014, 21:08 #4  |  Link StainlessS HeartlessS Usurer     Join Date: Dec 2009 Location: Over the rainbow Posts: 10,980 This seems to (EDIT: does) work but conversion to RGB, EDIT: but ODD number of averaged frames only Code: # Temporal Average of 29 frames avisource("D:\avs\test.avi") ConvertToRGB24() RgbAmplifier(Radius=15,Multiplier=0.0) # Radius * 2 - 1 frames averaged (14 before, 14 after + current) SelectEvery(29,14) http://forum.doom9.org/showthread.ph...t=RGBAmplifier __________________ I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 30th November 2014 at 21:34.
 30th November 2014, 22:08 #5  |  Link D9JK Registered User   Join Date: Feb 2010 Posts: 41 Sounds good, I'll give it a try. :-) Thanks to both of you for your help!
 3rd December 2014, 17:13 #6  |  Link colours Registered User     Join Date: Mar 2014 Posts: 308 Why not just use TemporalSoften? It'll have the same limitation of only working when N is odd, but works on YUV too. Or actually, requiring that N is odd isn't too hard to work around… Code: function blend(clip c,int n) { if (n%2 == 0) { blended = c.temporalsoften(n/2-1,255,255,255,2).selectevery(n,n/2) return merge(blended,c.selectevery(n,0),1.0/n) } if (n == 1) {return c} return c.temporalsoften((n-1)/2,255,255,255,2).selectevery(n,(n-1)/2) } Needs Avisynth+ for the if statement goodness. (TemporalSoften can also be replaced by RgbAmplifier if you so desire, of course.) __________________ Say no to AviSynth 2.5.8 and DirectShowSource!
3rd December 2014, 17:30   #7  |  Link
Gavino
Avisynth language lover

Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
 Originally Posted by colours Needs Avisynth+ for the if statement goodness.
Or GScript of course.
__________________
GScript and GRunT - complex Avisynth scripting made easier

3rd December 2014, 21:49   #8  |  Link
creaothceann
Registered User

Join Date: Jul 2010
Location: Germany
Posts: 357
Alternatively:

Quote:
 Originally Posted by colours Code: function blend(clip c, int n) { (n % 2 == 0) ? Merge( c.TemporalSoften( n / 2 - 1, 255, 255, 255, 2).SelectEvery(n, n / 2), c.SelectEvery(n, 0), 1.0 / n) \: (n != 1) ? c.TemporalSoften((n - 1) / 2 , 255, 255, 255, 2).SelectEvery(n, (n - 1) / 2) \: c }

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements and Chat     General Discussion     News     Forum / Site Suggestions & Help General     Decrypting     Newbies     DVD2AVI / DGIndex     Audio encoding     Subtitles     Linux, Mac OS X, & Co Capturing and Editing Video     Avisynth Usage     Avisynth Development     VapourSynth     Capturing Video     DV     HDTV / DVB / TiVo     NLE - Non Linear Editing     VirtualDub, VDubMod & AviDemux     New and alternative a/v containers Video Encoding     (Auto) Gordian Knot     MPEG-4 ASP     MPEG-4 Encoder GUIs     MPEG-4 AVC / H.264     High Efficiency Video Coding (HEVC)     New and alternative video codecs     MPEG-2 Encoding     VP9 and AV1 (HD) DVD, Blu-ray & (S)VCD     One click suites for DVD backup and DVD creation     DVD & BD Rebuilder     (HD) DVD & Blu-ray authoring     Advanced authoring     IFO/VOB Editors     DVD burning Hardware & Software     Software players     Hardware players     PC Hard & Software Programming and Hacking     Development     Translations

All times are GMT +1. The time now is 07:29.

 doom9.org - Archive - Top