Functions Index :: F :: FrameFilter

[<< up one level]

Module:

filters :: frames

Definition:

FrameFilter(clip orig, string script, val "p1", val "p2", val "p3", val "p4", ..., val "p50", string "vars", bool "show", bool "after_frame")

Description:

Applies a (filter) script to each frame of clip orig. The script has in its disposal all runtime variables and functions (current_frame, AverageLuma, etc.) plus the following text-substitution literals:

For any text-substitution literal contained inside the script, there must be a corresponding p1...p50 argument or element of the vars array, else the filter will fail with a ScriptClip error message.

Arguments:

orig: The clip on which ScriptClip with the script resulting from substitution of arguments on script will be called.

script: The runtime script on which textual substitution with filter's variable's arguments will be performed. The script will then be passed internally by the filter to the ScriptClip standard Avisynth filter.

Typically script will be a multiline string surrounded by triple double quotes ("""); this allows to write naturally double quoted strings inside the script, as one does in a normal Avisynth script; but this is not enforced.

"p1", ..., "p50" (optional, default to none): Positional arguments to be passed to script. Their values will be substituted to the script text with the aid of StrPrint. Positional means that the arguments have to be supplied with the same order that StrPrint-compatible %? placeholders appear inside the script's text.

vars (optional, defaults to none): An array of values/variables/globals to be passed to script. They will replace all occurences of the correspondind ${varI} literals (I being their 1-based index in the array; be aware that AVSLib arrays are zero-based indexed) inside script.

Names of globals should be quoted inside the vars array in order to be treated as variables and not as values; use StrQuote when inserting the element to the array.

show and after_frame (optional): They have the same meaning as in ScriptClip standard Avisynth filter. See the later's documentation for details.

Examples:

See the 15th example and 16th example of the documentation for some real use cases.

...

LoadModule("avslib", "base", "constants")

LoadModule("avslib", "filters", "frames")

# a not-so-elegant dynamic brightness adjustment ( target_luma, threshold, filename )

FF_DYNAMIC_BRIGHTNESS = """

target_luma = %i

th = %i

logfile = %q

avg_luma = AverageLuma()

excess_luma = avg_luma - target_luma

logfile != "" \

? WriteFile(logfile, "current_frame", "TAB", "avg_luma", "TAB", "excess_luma", "TAB", "th") \

: last

Abs(excess_luma) > th ? Tweak(bright=-Sign(excess_luma)*(Abs(excess_luma) - th)) : last

"""

clp = AviSource(...)

FrameFilter(clp, FF_DYNAMIC_BRIGHTNESS, 46, 4, "dyn-bri_log.txt")

 

[<< top]

 


[1]: "named" arguments can be contained any times desired inside script. All occurences will be replaced in one step, with the same textual value, as it is supplied by the corresponding element of vars.

[2]: If you need to include a positional argument more than one time inside the script you will either have to assign it once to a local script variable and use the variable afterwards or supply it at the p1,...,p50 part of the filter's argument list as many times and in the correct order as defined inside script.