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.
compose
Aditionally, composites can be created in a more functional style using the composite function.
Generated using TypeDoc
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 thecompose
method (and their implicit dependencies) will be compiled.Aditionally, composites can be created in a more functional style using the composite function.