AVExtensions

From Avisynth wiki
Jump to: navigation, search
Abstract
Author nutbread
Version 20150117
Download [x86]: AVExtensions.dll

[x64]: AVExtensions-x64.dll

Category Multipurpose
License
Discussion


Contents

Description

Audio-video extensions is a collection of various AviSynth filters used to modify audio or video.

This is mainly a collection of miscellaneous filters, as they have no real theme with one another. Some are more useful and/or practical than others.

Requirements


Syntax and Parameters

AApproximate

		clip.AApproximate(...)
		Returns an "approximation" of the original audio track.
		Basically, this is a way of distorting audio.
		It attempts to map all the peaks of the audio track, and then create a waveform inbetween the peaks.
		@param clip
			The image to sample
		@param waveform
			The waveform to approximate with
			Available values are:
				"SQUARE"
				"TRIANGLE"
				"SINE"
		@param same_zeros
			True if the waveform should intersect the x-axis at the same location,
			False otherwise
		@param tolerance
			How much tolerance is used for a sign change to occur
			Range: [0,1]
		@param absoluteness
			How absolute the tolerance is
			0 = Relative to the previous peak
			1 = Relative to 1 (the maximum amplitude)
			Range: [0,1]
		@param interpolation
			The number of peaks that should be interpolated into a single peak
			1 or less means no interpolation
		@param interpolate_samples
			The number of samples that should be interpolated into a single sample
			1 or less means no interpolation
			If this is specified along with "interpolation", the minimum interpolation distance is used
		@return
			A distorted audio track
		@default
			clip = clip.AApproximate( \
				waveform = "SQUARE", \
				same_zeros = true, \
				tolerance = 0.0, \
				absoluteness = 0.0, \
				interpolation = 1, \
				interpolate_samples = 0 \
			)

AVideoToWaveform

		clip.AVideoToWaveform(...)
		Convert an image/video frame into an audio waveform.
		When opened in an audio viewer, the audio waveform should resemble the original image.
		(Black and white images work best)
		@param clip
			The image to sample
		@param sample_rate
			The rate of the resulting audio
		@param channels
			The number of channels in the resulting audio
		@param channel_split
			True if the resulting waveform image should be split across the total channels
			False if it should be replicated on each channel
		@param pixel_sample_size
			The number of audio samples that will form a single pixel
		@param block_sample_size
			The number of samples that form a "block"
			A "block" is a vertical section of audio which is used when multiple pixels exist in the same vertical scanline
		@param block_sample_period
			The number of samples that form a "block"
		@param waveform
			The waveform to use for the audio
			Available values are:
				"TRIANGLE"
				"SAWTOOTH"
				"SQUARE"
				"SINE"
				"FLAT"
		@param threshold_red
			The cutoff level for a color to be considered "black", and thus used as an audio block (red component)
			Range: [0,255]
		@param threshold_green
			The cutoff level for a color to be considered "black", and thus used as an audio block (green component)
			Range: [0,255]
		@param threshold_blue
			The cutoff level for a color to be considered "black", and thus used as an audio block (blue component)
			Range: [0,255]
		@return
			The video + a new audio track
		@default
			clip.AVideoToWaveform( \
				sample_rate = clip.AudioRate (or 44100 if no audio), \
				channels = clip.AudioChannels (or 2 if no audio), \
				channel_split = true, \
				pixel_sample_size = 128, \
				block_sample_size = 4, \
				block_sample_period = 4, \
				waveform = "TRIANGLE", \
				threshold_red = 128, \
				threshold_green = threshold_red, \
				threshold_blue = threshold_red \
			)

MArchitecture

		MArchitecture(...)
		Get the runtime architecture of the plugin
		@return
			"x86" if using a 32-bit compiled version
			"x64" if using a 64-bit compiled version
		@default
			MArchitecture()

VBlend

		clip.VBlend(...)
		Blend two clips together using a custom blending function
		@param source1
			The first clip to modify
		@param source2
			The second clip to modify
		@param factor1
			The factor to multiply source1's pixels by
			The total equation winds up being:
				(source1.pixel_component * factor1) [equation] (source2.pixel_component * factor2)
				with values being in the range [0,1] instead of [0,255]
			Available usages are:
				"value 0.5"
					Multiply it by a fixed value (Range: [0,1])
				"color [inv] (src)"
					Multiply the component by the same component of source(src)
					(src) can be 1 or 2
					[inv] is optional, and if specified, (1.0 - source(src)[component]) is used
				"red [inv] (src)"
				"green [inv] (src)"
				"blue [inv] (src)"
				"alpha [inv] (src)"
					Same idea as the "color" version, except the component is fixed to R, G, B, or A
		@param factor2
			Same idea as factor1, except applied to source2
		@param equation
			The equation to use to modify the two clips
			Available equations are:
				"add"
				"subtract"
				"multiply"
				"divide"
				"max"
				"min"
		@param x_offset1
			The number of pixels to offset the first source clip by (horizontally)
		@param y_offset1
			The number of pixels to offset the first source clip by (vertically)
		@param x_offset2
			The number of pixels to offset the secondsource clip by (horizontally)
		@param y_offset2
			The number of pixels to offset the second source clip by (vertically)
		@note
			The same applies for the _r, _g, _b, _a variations, except they apply for a specific component
		@param border_color1
			The color to be used if there is no pixel at a location in source1 (due to offsets)
		@param border_color2
			The color to be used if there is no pixel at a location in source2 (due to offsets)
		@return
			The two clips blended together
		@default
			Not applicable, always define the necessary variables

VBlur

		clip.VBlur(...)
		Blur a clip with custom parameters.
		@param clip
			The clip to blur
		@param x_blur
			The radius (in pixels) to blur horizontally
			Default: 4
		@param y_blur
			The radius (in pixels) to blur vertically
			Default: 4
		@param x_edge
			The horizontal edge clamping method
			Values:
				"clamp",
				"wrap",
				"color"
			Default: "clamp"
		@param y_edge
			The vertical edge clamping method
			Values:
				"clamp",
				"wrap",
				"color"
			Default: "clamp"
		@param x_color
			The color to be used when using horizontal color edges
			Default: $000000
		@param y_color
			The color to be used when using vertical color edges
			Default: $000000
		@param x_interval
			The horizontal pixel sampling interval
			Default: 1.0
		@param y_interval
			The horizontal pixel sampling interval
			Default: 1.0
		@param x_function
			The function to use for horizontal blurring
			Values:
				"gaussian",
				"polynomial"
			Default: "gaussian"
		@param y_function
			The function to use for vertical blurring
			Values:
				"gaussian",
				"polynomial"
			Default: "gaussian"
		@param x_polynomial_power
			This value is only applicable when "x_function" is "polynomial"
			The function used for polynomials is the following:
				y = intercept + ((1.0 - x / radius) ^ (power)) * (1.0 - intercept)
			This value represents "power" in the equation
		@param y_polynomial_power
			This value is only applicable when "y_function" is "polynomial"
			The function used for polynomials is the following:
				y = intercept + ((1.0 - x / radius) ^ (power)) * (1.0 - intercept)
			This value represents "power" in the equation
		@param x_polynomial_intercept
			This value is only applicable when "x_function" is "polynomial"
			The function used for polynomials is the following:
				y = intercept + ((1.0 - x / radius) ^ (power)) * (1.0 - intercept)
			This value represents "intercept" in the equation
		@param y_polynomial_intercept
			This value is only applicable when "y_function" is "polynomial"
			The function used for polynomials is the following:
				y = intercept + ((1.0 - x / radius) ^ (power)) * (1.0 - intercept)
			This value represents "intercept" in the equation
		@param gpu
			Use the GPU to modify the frame
			Default: true
			@note Presently, this does not do anything when gpu=false
		@default
			clip.VBlur( \
				x_blur = 4, \
				y_blur = 4, \
				x_edge = "clamp", \
				y_edge = "clamp", \
				x_color = #000000, \
				y_color = #000000, \
				x_interval = 1.0, \
				y_interval = 1.0, \
				x_function = "gaussian", \
				y_function = "gaussian", \
				x_polynomial_power = 1.0, \
				y_polynomial_power = 1.0, \
				x_polynomial_intercept = 1.0, \
				y_polynomial_intercept = 1.0, \
				gpu = true \
			)

VCache

		clip.VCache(...)
		Cache video frames in memory, so they don't have to be re-decoded or re-filtered if they are
			used multiple times in a row
		This is particularly useful when using Reverse() on a video clip. Example:
			clip.VCache(cache_size=100, before=99).Reverse()
			runs much faster than:
			clip.Reverse()
			because it caches multiple successive frames.
		@param clip
			The clip to cache frames of
		@param cache_size
			The maximum cache size
			Minimum of 1
		@param before
			The number of frames to cache in front of the current_frame
			when the current_frame is NOT already cached
		@param after
			The number of frames to cache behind the current_frame
			when the current_frame is NOT already cached
		@param before_hit
			The number of frames to cache in front of the current_frame
			when the current_frame is already cached
		@param after_hit
			The number of frames to cache behind the current_frame
			when the current_frame is already cached
		@return
			A video clip that looks identical to the original, but potentially allows the script to run faster
		@default
			clip.VCache( \
				cache_size = 1 + max(before, before_hit) + max(after, after_hit), \
				before = 0, \
				after = 0, \
				before_hit = 0, \
				after_hit = 0 \
			)

VChannel

		clip.VChannel(...)
		Extract a color channel from a video.
		This can be something such as the red (#ff0000), green (#00ff00), or blue (#0000ff) channel,
			or something more complex like an "orange" (#ff8000) channel
 		@param clip
			The clip to modify
		@param red
			The red component of the channel to extract
		@param green
			The green component of the channel to extract
		@param blue
			The blue component of the channel to extract
		@param hue
			The hue of the channel to extract
		@param saturation
			The saturation of the channel to extract
		@param value
			The value of the channel to extract
		@note
			If hue, saturation, or value is defined, any red/green/blue values are ignored
		@param color_full
			The color to use if the distance factor is minimum
			If set to -1, it assumes the value of the defined [red,green,blue] or [hue,saturation,value] color
		@param color_empty
			The color to use if the distance factor is maximum
			If set to -1, it assumes the value of the defined [red,green,blue] or [hue,saturation,value] color
		@param alpha_full
			The alpha to use if the distance factor is minimum
		@param alpha_empty
			The alpha to use if the distance factor is maximum
		@param normalize
			Normalize the distance factor to the range [0,1]
		@param maximize
			If true, the following equation is used to calculate the distance factor:
				max(0, red - (255 - pixel.red))
				... (similar for green and blue)
			If false:
				(red - max(0, red - pixel.red))
				... (similar for green and blue)
		@param per_component
			Apply on a per-component basis if true
		@return
			An extracted color channel video clip
		@default
			clip.VChannel( \
				red = 0, \
				green = 0, \
				blue = 0, \
				hue = 0, \
				saturation = 0, \
				value = 0, \
				color_full = -1, \
				color_empty = -1, \
				alpha_full = 255, \
				alpha_empty = 255, \
				normalize = true, \
				maximize = false, \
				per_component = false \
			)

VCompare

 		clip.VCompare(...)
		Perform a pixel-by-pixel difference of two videos, with lots of options
		@param clip
			The first clip to be compared
		@param to
			The second clip to be compared to
		@param diff_min
			Minimum difference required for a change to be shown
			Range: [0.0 - 255.0]
		@param diff_max
			Maximum value for the full change to be shown
			Range: [0.0 - 255.0]
		@param diff_alpha_min
			Minimum alpha for foreground
			Range: [0.0 - 1.0]
		@param diff_alpha_max
			Maximum alpha for foreground
			Range: [0.0 - 1.0]
		@param diff_normalize
			Normalize to be in the range of the maximum possible difference for a pixel
		@param bg_color
			The default background color
		@param bg_alpha
			The default background color (alpha component)
		@param bg_video1_alpha
			The alpha of the original clip1 (clip) color (background)
		@param bg_video2_alpha
			The alpha of the original clip2 (to) color (background)
		@param bg_method
			The comparison method for the background; available methods are:
				"add"
				"max"
				"min"
 				"mult"
				"mult_sqrt"
				"mult_sqrt_inv"
				"color"
		@param fg_color
			The default foreground color
		@param fg_alpha
			The default foreground color (alpha component)
		@param fg_video1_alpha
			The alpha of the original clip1 (clip) color (foreground)
		@param fg_video2_alpha
			The alpha of the original clip2 (to) color (foreground)
		@param fg_method
			The comparison method for the foreground; available methods are:
				"add"
				"max"
				"min"
				"mult"
				"mult_sqrt"
				"mult_sqrt_inv"
				"color"
		@param bg_cs_hue_min
			When bg_method=="color":
			The minimum hue
			Range: [0.0 - 1.0]
		@param bg_cs_hue_max
			When bg_method=="color":
			The maximum hue
		@param bg_cs_saturation_min
			When bg_method=="color":
			The minimum saturation
		@param bg_cs_saturation_max
			When bg_method=="color":
			The maximum saturation
		@param bg_cs_value_min
			When bg_method=="color":
			The minimum value
		@param bg_cs_value_max
			When bg_method=="color":
			The maximum value
		@param fg_cs_hue_min
			When fg_method=="color":
			The minimum hue
			Range: [0.0 - 1.0]
		@param fg_cs_hue_max
			When fg_method=="color":
			The maximum hue
		@param fg_cs_saturation_min
			When fg_method=="color":
			The minimum saturation
		@param fg_cs_saturation_max
			When fg_method=="color":
			The maximum saturation
		@param fg_cs_value_min
			When fg_method=="color":
			The minimum value
		@param fg_cs_value_max
			When fg_method=="color":
			The maximum value
		@param fluctuations
			A list of fluctuations to apply to parameters over time
			@todo : Document this more
		@param gpu
			Use the gpu to render
		@note
			When using gpu=false, a small amount of functionality is not available compared to using gpu=true
		@default:
			video1.VCompare( \
				to = video2, \
				diff_min = 0.0, \
				diff_max = 128.0, \
				diff_alpha_min = 0.0, \
				diff_alpha_max = 1.0, \
				diff_normalize = -1, \
				\
				bg_color = $000000, \
				bg_alpha = 1.0, \
				bg_video1_alpha = 0.0, \
				bg_video2_alpha = 0.0, \
				bg_method = "add", \
				\
				fg_color = $ffffff, \
				fg_alpha = 0.0, \
				fg_video1_alpha = 1.0, \
				fg_video2_alpha = 0.0, \
				fg_method = "add", \
				\
				bg_cs_hue_min = 0.0, \
				bg_cs_hue_max = 1.0, \
				bg_cs_saturation_min = 1.0, \
				bg_cs_saturation_max = 1.0, \
				bg_cs_value_min = 1.0, \
				bg_cs_value_max = 1.0, \
				\
				fg_cs_hue_min = 0.0, \
				fg_cs_hue_max = 1.0, \
				fg_cs_saturation_min = 1.0, \
				fg_cs_saturation_max = 1.0, \
				fg_cs_value_min = 1.0, \
				fg_cs_value_max = 1.0, \
				\
				fluctuations = "", \
				\
				 gpu = true \
			)

VGetPixel

		clip.VGetPixel(...)
		Get the color of a pixel of a video frame at a certain position
		@param clip
			The clip to sample
		@param frame
			The frame of the clip
		@param x
			The x coordinate
		@param y
			The y coordinate
		@param alpha
			True if alpha should be included
			If there is no alpha channel, 255 is used as the alpha
		@return
			A hex value of the pixels color'
			#[AA]RRGGBB
		@default
			clip.VGetPixel( \
				frame = 0, \
				x = 0, \
				y = 0, \
				alpha = false \
			)

VMostCommon

		clip.VMostCommon(...)
		Get the most common color inside blocks of a video.
		@param clip
			The clip to resize
		@param w_blocks
			How many horizontal blocks
			Range: [1, clip.width]
		@param h_blocks
			How many vertical blocks
			Range: [1, clip.width]
		@param range
			The RGB range a pixel can be for it to count for a nearby color
			Range: [0,255]
			The larger the value, the longer this takes
		@param small
			Instead of using blocks that fill the size of the original, block(s) are 1x1 pixel
		@return
			The clip with the entire clip (or blocks of it) composed of a single color
			If small=true, the size of the resulting clip = ( w_blocks , h_blocks )
		@default
			clip.VMostCommon( \
				w_blocks = 1, \
				h_blocks = 1, \
				range = 0, \
				small = false \
			)

VNoClear

 		clip.VNoClear(...)
		Render a RGB32 video, simulating no background clearing.
		(ie: transparent sections will show the previous frame)
 		@param clip
			The clip to resize
		@param color_initial
			The initial background color
			Default: $00000000 (RGBA=0,0,0,0)
		@param color_refresh
			The color overlayed on the previous frame before overlaying the new frame
			Default: $00000000 (RGBA=0,0,0,0)
		@param color_refresh_factor
			The factor at which the colors should be merged
			Range: [0, 1]
				let: color_refresh_factor=CRF, color_refresh=CR; ranges of everything normalized to [0, 1]
				final_R = (pre_R * (1-CRF) + CR_R * CRF) * (1.0 - new_A) + new_R * new_A // same for G,B,A
		@param clear_on_skip
			True: if a seek occured, the background should be cleared to color_initial
			False: ignore seeks
			A seek in this case means a non-sequential frame access; ie frame 3 to frame 5
		@return
			The clip with simulated no background clearing
		@default
			clip.VNoClear( \
				color_initial = $00000000, \
				color_refresh = $00000000, \
				color_refresh_factor = 0.0, \
				clear_on_skip = false \
			)

VNoise

		clip.VNoise(...)
		Add black and white noise to a video clip.
		@param clip
			The clip to add noise to
		 @param strength_min
			The minimum strength to apply the noise
			Range: [0,255]
 		@param strength_max
			The maximum strength to apply the noise
			Range: [0,255]
		@param shade_min
			The minimum shade (0=black)
			Range: [0,255]
		@param shade_max
			The maximum shade (255=white)
			Range: [0,255]
		@param seed
			The random number generator seed
			If less than 0, it's always seeded with the time
		@return
			The video clip with black and white noise added
		@default
			clip.VNoise( \
				strength_min = 0, \
				strenght_max = 40, \
				shade_min = 0, \
				shade_max = 255, \
				seed = 0 \
			)

VSimilar

		clip.VSimilar(...)
		Replace similar colors with the same color across frames
		@param clip
			The clip to modify
		@param group
			Group all components of a pixel together.
			i.e. if one changes, they all change.
		@param threshold_red
			The threshold range for pixels to be considered different (red component)
			i.e. if the difference in components is greater than or equal to this value, it will be classified as "different"
			Range: [0, 255]
		@param threshold_green
			The threshold range for pixels to be considered different (green component)
			Range: [0, 255]
		@param threshold_blue
			The threshold range for pixels to be considered different (green component)
			Range: [0, 255]
		@param normalize_red
			True if the threshold ranges should be normalized to the maximum possible range (red component)
		@param normalize_green
			True if the threshold ranges should be normalized to the maximum possible range (green component)
		@param normalize_blue
			True if the threshold ranges should be normalized to the maximum possible range (blue component)
		@param normalize_alpha
			True if the threshold ranges should be normalized to the maximum possible range (alpha component)
		@param ignore_red
			False if the red component should keep its original value no matter what
		@param ignore_blue
			False if the blue component should keep its original value no matter what
		@param ignore_green
			False if the green component should keep its original value no matter what
		@param ignore_alpha
			False if the alpha component should keep its original value no matter what
		@return
			The same clip, with colors similar colors across frames changed to be the same color
		@default
			clip.VSimilar( \
				group = true, \
				threshold_red = 1, \
				threshold_green = 1, \
				threshold_blue = 1, \
				threshold_alpha = 1, \
				normalize_red = false, \
				normalize_green = false, \
				normalize_blue = false, \
				normalize_alpha = false, \
				ignore_red = false, \
				ignore_green = false, \
				ignore_blue = false, \
				ignore_alpha = false \
			)

VSlideFPS

		clip.VSlideFPS(...)
		        Slide the framerate from one value to another across a clip
		@param clip
	 		The clip to add noise to
 		@param framerate_numerator
			The target framerate numerator
		@param framerate_denominator
			The target framerate denominator
		@param framerate_numerator_initial
			The initial framerate numerator
		@param framerate_denominator_initial
			The initial framerate denominator
		@param framerate_numerator_final
			The final framerate numerator used in the output
		@param framerate_denominator_final
			The final framerate denominator used in the output
		@param audiorate
			The target audiorate
		@param audiorate_initial
			The initial audiorate
		@param audiorate_final
			The final audiorate used in the output
		@default
 			clip.VSlideFPS( \
				framerate_numerator = -1, \
				framerate_denominator = -1, \
				framerate_numerator_initial = -1, \
				framerate_denominator_initial = -1, \
				framerate_numerator_final = -1, \
				framerate_denominator_final = -1, \
				audiorate = -1, \
				audiorate_initial = -1, \
				audiorate_final = -1 \
			)

VSubtitle

		clip.VSubtitle(...)
		Identical to Subtitle with the exception that it is formatted using
		snprintf(new_text, max(format_space, old_text.length), old_text, frame_number)
		if any % characters are located in the text. Otherwise it's the same


Examples

TODO

Changelog

Version      Date            Changes
20150117 2015/01/17 - Added a VNoClear filter 20140911 2014/09/11 - Inital release.


Archived Downloads

Version Download Mirror
20150117 avextensions_20150117.zip
  • Includes binaries and source code


External Links

  • GitHub - Source code repository




Back to External Filters

Personal tools