Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Composite

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).

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.

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.

Hierarchy

Implements

Index

Properties

Protected _outputs

_outputs: StreamRef[]

inputs

inputs: Stream[] = []

Accessors

dependencies

  • Returns IFragment[]

outputs

  • Returns StreamRef[]

Methods

[Symbol.iterator]

  • [Symbol.iterator](): IterableIterator<StreamRef>

Abstract clone

compile

Abstract compose

materialize

  • materialize(): string

named

  • named(...names: string[]): this
  • Parameters

    • Rest ...names: string[]

    Returns this

Generated using TypeDoc