ClipBlend
Abstract | |
---|---|
Author | StainlessS |
Version | v1.01 |
Download | ClipBlend_25_26_x86_x64_dll_v1-01_20181127.zip |
Category | Averaging |
License | GPLv2 |
Discussion | Doom9 Thread |
Contents |
Description
AviSynth filter to blend consecutive frames in a clip.
Requirements
- [x86]: AviSynth+ or AviSynth 2.6
- [x64]: AviSynth+
- Supported color formats: RGB24, RGB32, YUY2, Y8, YV12, YV16, YV24
- *** vcredist_x86.exe is required for ClipBlend-x86
- *** vcredist_x64.exe is required for ClipBlend-x64
Syntax and Parameters
- ClipBlend (clip, int "delay")
- ClipBlend16 (clip, int "delay")
- clip =
- Input clip.
ClipBlend16
: input clip needs to be stack16, see examples.
- clip =
- int delay = 0
- Delay, default = 0, == ALL frames played so far blended.
- 1 = blend with previous frame ie two frames blended.
- 10 = blend with 10 previous frames, ie 11 frames blended, etc.
- Delay, default = 0, == ALL frames played so far blended.
- int delay = 0
Examples
#ClipBlend with default settings: AviSource("blah.avi") ClipBlend(delay=0)
#To get average of all frames 0 to frame 300: AviSource("blah.avi") ClipBlend() # Default delay=0 ie all previous frames Trim(300,-1) # Get Required frame
#Or to get a single frame average of all frames in a clip: AviSource("blah.avi") ClipBlend() Trim(FrameCount-1,-1)
#Stacked 16-bit processing with AviSynth+: AviSource("blah.avi") ConvertToStacked() ClipBlend16(delay=0) ConvertFromStacked()
How ClipBlend Works
ClipBlend() uses a single 32 bit accumulator (unsigned int) for each channel of each pixel x,y position in the clip frame. With a maximum possible value per pixel/channel being 255 ie 8 bits, this leaves 24 bits available for accumulating the sum of values for that pixel/channel position, ie adding the values for that pixel/channel from every selected frame in the blended range. The additional 24 bits would allow for up to ~16 Million (2^24) frames to be summed, however we also need another bit to maintain maximum precision possible for 8 bit result, so reducing maximum possible frame range to ~8 million frames.
Code:
Return AviSource("test.avi").ClipBlend(delay=0).Trim(999,-1) # 1000 frames, 1000 values per accumulator, ie max 1000*255
Above would sum (each channel/pixel) with maximum possible sum for an accumulator being 1000*255 (about 18 bits, 2^10=1024,2^8=256) As clipblend scans frames, it adds the channel/pixel values at each x,y position to the accumulators, for all of the required frames. If delay = 0, it just adds next frame values to the accumulators. If eg delay=10, and current scanned range is already 10, it subtracts the channel/pixel values of the oldest frame (lowest number) and then adds the values for the next frame to the accumulators. When delivering the result (delay=whatever), it just divides the accumulated sum by the number of sample frames to get the average, and writes it to the relevant pixel/channel/x/y position, could not be simpler.
Implementation is equivalent to this:
int(accumulator / Float(FramesDone) + 0.5)
The actual implementation and reason for the extra needed bit that was mentioned (ie accumulator*2):
((accumulator*2) + FramesDone) / (FramesDone*2)
The *2 pair and addition of FramesDone is the integer equivalent of division, adding 0.5 and taking Int() whist maintaining max possible precision at 8 bits result.
Changelog
Version Date(Y/M/D) Changes
v1.01 2018/11/27 - Added Version resource. Moved to VS2008, with x64. v1.00 2013/06/11 - Initial version.
Archived Downloads
Version | Download | Mirror |
---|---|---|
v1.01 | ClipBlend_25&26_x86_x64_dll_v1-01_20181127.zip | ClipBlend_25_26_x86_x64_dll_v1-01_20181127.zip |
External Links
Back to External Filters ←