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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 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?
D9JK is offline   Reply With Quote
Old 30th November 2014, 18:22   #2  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,666
Have you looked at AvgAll or ClipBlend?

Last edited by Reel.Deel; 30th November 2014 at 18:39. Reason: typo
Reel.Deel is offline   Reply With Quote
Old 30th November 2014, 20:42   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
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.
StainlessS is offline   Reply With Quote
Old 30th November 2014, 21:08   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
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.
StainlessS is offline   Reply With Quote
Old 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!
D9JK is offline   Reply With Quote
Old 3rd December 2014, 17:13   #6  |  Link
colours
Registered User
 
colours's Avatar
 
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!
colours is offline   Reply With Quote
Old 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 View Post
Needs Avisynth+ for the if statement goodness.
Or GScript of course.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 3rd December 2014, 21:49   #8  |  Link
creaothceann
Registered User
 
Join Date: Jul 2010
Location: Germany
Posts: 357
Alternatively:

Quote:
Originally Posted by colours View Post
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
}
creaothceann is offline   Reply With Quote
Reply


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 Jump


All times are GMT +1. The time now is 05:02.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.