Functions Index :: F :: FrameFilterReader
Module:
Definition:
FrameFilterReader(clip orig, string script, string filenames, val "p1", val "p2", val "p3", val "p4", ..., val "p50", string "vars", bool "show", bool "after_frame")
Description:
An extension of the FrameFilter filter. 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
- all the text-substitution literals accepted by FrameFilter, plus
- the text-substitution literals ${read1}, ${read2}, ..., ${readN}, N == filenames.ArrayLen.
The later are replaced by FrameFilterReader with the actual auto-generated global variables' names whose values are set internally by the filter from external files passed in (their path) as elements of filenames with ConditionalReader. [1]
For any text-substitution literal contained inside the script, there must be a corresponding p1...p50 argument or element of the vars or filenames arrays, else the filter will fail.
Arguments:
filenames is a CR/LF delimited array of filenames (each filename in a single line). Thus, it is the same as a multi-line string.
It contains the names of files with ConditionalReader-compatible format that set the variables corresponding to the ${readI} literals. The type and value of each ${readI} can be anything that suits your script and is supported by ConditionalReader; it just has to be the same type as that declared in the text file.
orig, script, "p1", ..., "p50", vars, show and after_frame: See the documentation of FrameFilter.
Notes and conditions on arguments relations:
1] If filenames == "", ConditionalReader will not be used by FrameFilterReader. A call with a zero-length filenames array is the same as calling FrameFilter (provided there are no ${readI} literals in the script).
Examples:
See the 15th example and 16th example of the documentation for some real use cases.
...
LoadModule("avslib", "array", "core")
LoadModule("avslib", "filters", "frames")
# a simple per-frame filter mixer ( filtered )
FF_MIX = """
filtered = %q
${read1} > 0 ? Eval(filtered.ArrayGetString(${read1} - 1)) : last
"""
src = AviSource(...)
ft1 = src.Levels(0,0.95,250,0,255).SubTitle("ft1") # SubTitle() is for illustration
ft2 = src.Levels(0,1.05,255,10,252).SubTitle("ft2")
ft3 = src.Levels(10,1.15,255,0,255).SubTitle("ft3")
FrameFilterReader(src, FF_MIX, "mix.txt", ArrayCreate(ft1, ft2, ft3))
# a sample mix.txt contents (ignore # at the begining):
# type int
# default 0
# R 10 35 1
# R 45 48 2
# R 49 53 1
# R 105 123 3
[1]: ${readI} literals 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 text file (through the auto-generated global variables).