import { ICompiler, Stream, StreamRef, IFilter, IFragment } from './Compiler'; /** * @category composable */ export declare type FilterParams = Record; /** * @category composable */ export declare class FilterStreamRef

= Filter

> extends StreamRef { protected _name: string; filter: F; get name(): string; constructor(filter: F); compile(compiler: ICompiler): void; named(name: string): this; clone(): FilterStreamRef; } /** * Represents a native FFMPEG filter. Filters are made of four parts: a list of inputs, a name, some parameters, and finally, a list of outputs. * * Some of those parts are optional. For example, some filters (sources) have no inputs: These can be represented by instantiating the ***Filter* * class with an empty array `[]` or `null`. * ```typescript * const filter = new Filter( null, 'color', { * color: 'black', * size: `1920x1080`, * rate: frameRate, * duration: '5000' * } ); * ``` * * In the same line, not all filters require parameters, so those can be ommited (or an empty object `{}` can be passed). * ```typescript * const filter = new Filter( input, 'anullsink' ); * ``` * * Some filters expect only one parameter. In that case pass it inside `default` property of parameters. * ```typescript * // Resulting string will look like `atempo=2`. * const filter = new AudioTempo( input, { * default: 2, * }); * ``` * * When filters have more than one input, an array of streams can be provided. Similarly, by default this module allocates one output stream for each * filter. In case a filter outputs more than one though, a fourth parameter can be provided indicating how many output streams should be allocated. * ```typescript * const concatFilter = new Filter( * [ video1, audio1, video2, audio2 ], * 'concat', * { n: 2, v: 1, a: 1 }, * 2 * ); * ``` * In the example above, the [concat](https://ffmpeg.org/ffmpeg-filters.html#toc-concat) filter generates two output streams: one for video, and one for audio (it is always `v + a`). * These can be accessed through the [[Filter.outputs]] property, or by destructuring the filter itself. * * ```typescript * const video = concatFilter.outputs[ 0 ]; * const audio = concatFilter.outputs[ 1 ]; * // Or equivalent * const [ video, audio ] = concatFilter; * ``` * * @category composable */ export declare class Filter

implements IFilter { name: string; parameters: P; inputs: Stream[]; outputs: FilterStreamRef>[]; protected _customOutputsCount: number; get dependencies(): IFragment[]; constructor(inputs: Stream | Stream[], name: string, parameters?: P, outputs?: number); protected rebuildOutputs(): void; getOutputCount(): number; getParameter(name: string, defaultValue?: T): T; compileStreams(compiler: ICompiler, streams: Stream[]): string; compileArgumentValue(arg: string | number): string; compileArguments(compiler: ICompiler): string; compile(compiler: ICompiler): void; materialize(): string; clone(): Filter

; named(...names: string[]): this; [Symbol.iterator](): IterableIterator; } /** * @category composable */ export declare function filter(inputs: Stream | Stream[], name: string, parameters?: FilterParams): Filter; export declare function filter(inputs: Stream | Stream[], name: string, parameters: FilterParams, outputs: number): Filter; /** * A Composite is similar to a filter, but instead of being a mapping to a real, native FFMPEG filter, it is a virtual one: * behind it may be other composites or other complex FFMPEG filter. * * To create a new composite, just extends the [[Composite]] class (implementing the two abstract methods [[Composite.compose]] and [[Composite.clone]]). * * ```typescript * export class BlackoutComposite extends Composite { * public constructor ( * public original : Stream, public width : number, public height : number, * public start : number, public end : number * ) { * super(); * } * * public compose () : Stream { * const black = new VideoColor( null, { * color: 'black', * size: '' + this.width + 'x' + this.height, * duration: this.end - this.start * } ); * * return new VideoOverlay( * [ this.original, black ], * { enable: `'between(t,${ this.start },${ this.end })'` } * ); * } * * public clone () : Composite { * return new BlackoutComposite( * this.original, this.width, this.height, this.start, this.end * ); * } * } * ``` * * Once created, composites can be used almost anywhere a regular filter can. * ```typescript * const input = new Input( 'input.mp4' ); * * const filter = new BlackoutComposite( input, 1920, 1080, 10, 20 ); * * const output = Output( 'output.mp4', [ '-map', filter ] ); * ``` * * The `compose` method can return one or multiple streams. Only streams returned * by the `compose` method (and their *implicit* dependencies) will be compiled. * * Aditionally, composites can be created in a more functional style using the [[composite]] function. * * @category composable */ export declare abstract class Composite implements IFilter { inputs: Stream[]; protected _outputs: StreamRef[]; get outputs(): StreamRef[]; get dependencies(): IFragment[]; abstract compose(): Stream[] | Stream; abstract clone(): Composite; compile(compiler: ICompiler): void; materialize(): string; named(...names: string[]): this; [Symbol.iterator](): IterableIterator; } /** * @category composable */ export declare function composite(compose: (...args: T) => Stream | Stream[]): (...args: T) => Composite;