├── generator ├── index.hdb ├── render.js └── filter.hdb ├── package.json ├── lib ├── azmq.js ├── copy.js ├── null.js ├── afifo.js ├── anull.js ├── hflip.js ├── remap.js ├── vflip.js ├── amovie.js ├── asplit.js ├── atempo.js ├── biquad.js ├── earwax.js ├── negate.js ├── swapuv.js ├── reverse.js ├── areverse.js ├── nullsink.js ├── resample.js ├── anullsink.js ├── aresample.js ├── scale2ref.js ├── alphamerge.js ├── buffersink.js ├── replaygain.js ├── super2xsai.js ├── abuffersink.js ├── pixdesctest.js ├── premultiply.js ├── alphaextract.js ├── repeatfields.js ├── volumedetect.js ├── separatefields.js ├── ass.js ├── phase.js ├── qp.js ├── abench.js ├── displace.js ├── setfield.js ├── dejudder.js ├── weave.js ├── pp.js ├── framepack.js ├── hqx.js ├── xbr.js ├── bbox.js ├── anequalizer.js ├── amerge.js ├── asettb.js ├── extractplanes.js ├── asetpts.js ├── asetrate.js ├── field.js ├── hwupload_cuda.js ├── format.js ├── ainterleave.js ├── framestep.js ├── showpalette.js ├── fieldorder.js ├── midequalizer.js ├── noformat.js ├── threshold.js ├── arealtime.js ├── ssim.js ├── thumbnail.js ├── channelsplit.js ├── maskedmerge.js ├── lut3d.js ├── stereo3d.js ├── removelogo.js ├── w3fdif.js ├── colormatrix.js ├── tinterlace.js ├── transpose.js ├── adelay.js ├── cover_rect.js ├── shuffleframes.js ├── pp7.js ├── vibrato.js ├── astreamselect.js ├── telecine.js ├── crystalizer.js ├── hstack.js ├── vstack.js ├── aperms.js ├── asendcmd.js ├── ocv.js ├── yadif.js ├── bitplanenoise.js ├── extrastereo.js ├── dcshift.js ├── blackframe.js ├── asidedata.js ├── bs2b.js ├── interlace.js ├── utils.js ├── haldclut.js ├── scale_npp.js ├── silencedetect.js ├── random.js ├── tremolo.js ├── allpass.js ├── readeia608.js ├── uspp.js └── loop.js ├── README.md └── test └── utilsTest.js /generator/index.hdb: -------------------------------------------------------------------------------- 1 | {{#each this}} 2 | module.exports.{{toIdentifier filterName}} = require('./lib/{{filterName}}.js').{{toIdentifier filterName}}; 3 | {{/each}} 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fluent-ffmpeg-filters", 3 | "version": "1.0.13", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "fluent-ffmpeg": "^2.1.0" 13 | }, 14 | "devDependencies": { 15 | "async": "^2.1.5", 16 | "commander": "^2.9.0", 17 | "debug": "^2.6.3", 18 | "handlebars": "^4.0.6", 19 | "htmlparser2": "^3.9.2", 20 | "mocha": "^3.2.0", 21 | "request": "^2.81.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /generator/render.js: -------------------------------------------------------------------------------- 1 | const handlebars = require('handlebars'); 2 | const fs = require('fs'); 3 | const path = require('path'); 4 | 5 | const filterTemplatePath = path.join(__dirname, '.', 'filter.hdb'); 6 | const indexTemplatePath = path.join(__dirname, '.', 'index.hdb'); 7 | 8 | const filterTemplate = handlebars.compile(fs.readFileSync(filterTemplatePath, "utf8")); 9 | const indexTemplate = handlebars.compile(fs.readFileSync(indexTemplatePath, "utf8")); 10 | 11 | handlebars.registerHelper('capitalize', function(text) { 12 | return text.charAt(0).toUpperCase() + text.slice(1); 13 | }); 14 | 15 | handlebars.registerHelper('formatComment', function(text) { 16 | return text.replace(/(?:\r\n|\r|\n)/g, '\n * '); 17 | }); 18 | 19 | handlebars.registerHelper('toIdentifier', function(text) { 20 | 21 | if (RESERVED_WORDS.includes(text) || !isNaN(text.charAt(0))) { 22 | text = '_' + text; 23 | } 24 | 25 | return text.replace(/\W+/g, '_'); 26 | }); 27 | 28 | const RESERVED_WORDS = ['null', 'new', 'in', 'function']; 29 | 30 | function renderFilter(filter, out, cb) { 31 | const gen = filterTemplate(filter); 32 | out(filter.filterName, gen, cb); 33 | } 34 | 35 | function renderIndex(filters, out, cb) { 36 | const gen = indexTemplate(filters); 37 | out('index', gen, cb); 38 | } 39 | 40 | 41 | module.exports.renderFilter = renderFilter 42 | module.exports.renderIndex = renderIndex 43 | -------------------------------------------------------------------------------- /lib/azmq.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the azmq function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().azmq() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the azmq function. 17 | */ 18 | function azmq(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'azmq', function() { 20 | return new AzmqFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AzmqFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'azmq', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.azmq = azmq; 56 | -------------------------------------------------------------------------------- /lib/copy.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the copy function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().copy() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the copy function. 17 | */ 18 | function copy(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'copy', function() { 20 | return new CopyFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class CopyFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'copy', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.copy = copy; 56 | -------------------------------------------------------------------------------- /lib/null.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the null function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().null() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the null function. 17 | */ 18 | function _null(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, '_null', function() { 20 | return new NullFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class NullFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'null', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports._null = _null; 56 | -------------------------------------------------------------------------------- /lib/afifo.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the afifo function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().afifo() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the afifo function. 17 | */ 18 | function afifo(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'afifo', function() { 20 | return new AfifoFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AfifoFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'afifo', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.afifo = afifo; 56 | -------------------------------------------------------------------------------- /lib/anull.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the anull function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().anull() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the anull function. 17 | */ 18 | function anull(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'anull', function() { 20 | return new AnullFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AnullFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'anull', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.anull = anull; 56 | -------------------------------------------------------------------------------- /lib/hflip.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the hflip function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().hflip() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the hflip function. 17 | */ 18 | function hflip(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'hflip', function() { 20 | return new HflipFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class HflipFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'hflip', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.hflip = hflip; 56 | -------------------------------------------------------------------------------- /lib/remap.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the remap function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().remap() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the remap function. 17 | */ 18 | function remap(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'remap', function() { 20 | return new RemapFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class RemapFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'remap', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.remap = remap; 56 | -------------------------------------------------------------------------------- /lib/vflip.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the vflip function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().vflip() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the vflip function. 17 | */ 18 | function vflip(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'vflip', function() { 20 | return new VflipFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class VflipFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'vflip', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.vflip = vflip; 56 | -------------------------------------------------------------------------------- /lib/amovie.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the amovie function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().amovie() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the amovie function. 17 | */ 18 | function amovie(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'amovie', function() { 20 | return new AmovieFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AmovieFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'amovie', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.amovie = amovie; 56 | -------------------------------------------------------------------------------- /lib/asplit.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the asplit function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().asplit() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the asplit function. 17 | */ 18 | function asplit(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'asplit', function() { 20 | return new AsplitFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AsplitFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'asplit', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.asplit = asplit; 56 | -------------------------------------------------------------------------------- /lib/atempo.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the atempo function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().atempo() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the atempo function. 17 | */ 18 | function atempo(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'atempo', function() { 20 | return new AtempoFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AtempoFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'atempo', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.atempo = atempo; 56 | -------------------------------------------------------------------------------- /lib/biquad.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the biquad function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().biquad() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the biquad function. 17 | */ 18 | function biquad(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'biquad', function() { 20 | return new BiquadFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class BiquadFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'biquad', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.biquad = biquad; 56 | -------------------------------------------------------------------------------- /lib/earwax.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the earwax function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().earwax() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the earwax function. 17 | */ 18 | function earwax(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'earwax', function() { 20 | return new EarwaxFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class EarwaxFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'earwax', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.earwax = earwax; 56 | -------------------------------------------------------------------------------- /lib/negate.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the negate function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().negate() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the negate function. 17 | */ 18 | function negate(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'negate', function() { 20 | return new NegateFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class NegateFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'negate', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.negate = negate; 56 | -------------------------------------------------------------------------------- /lib/swapuv.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the swapuv function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().swapuv() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the swapuv function. 17 | */ 18 | function swapuv(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'swapuv', function() { 20 | return new SwapuvFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class SwapuvFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'swapuv', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.swapuv = swapuv; 56 | -------------------------------------------------------------------------------- /lib/reverse.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the reverse function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().reverse() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the reverse function. 17 | */ 18 | function reverse(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'reverse', function() { 20 | return new ReverseFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ReverseFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'reverse', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.reverse = reverse; 56 | -------------------------------------------------------------------------------- /lib/areverse.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the areverse function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().areverse() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the areverse function. 17 | */ 18 | function areverse(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'areverse', function() { 20 | return new AreverseFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AreverseFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'areverse', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.areverse = areverse; 56 | -------------------------------------------------------------------------------- /lib/nullsink.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the nullsink function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().nullsink() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the nullsink function. 17 | */ 18 | function nullsink(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'nullsink', function() { 20 | return new NullsinkFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class NullsinkFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'nullsink', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.nullsink = nullsink; 56 | -------------------------------------------------------------------------------- /lib/resample.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the resample function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().resample() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the resample function. 17 | */ 18 | function resample(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'resample', function() { 20 | return new ResampleFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ResampleFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'resample', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.resample = resample; 56 | -------------------------------------------------------------------------------- /lib/anullsink.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the anullsink function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().anullsink() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the anullsink function. 17 | */ 18 | function anullsink(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'anullsink', function() { 20 | return new AnullsinkFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AnullsinkFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'anullsink', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.anullsink = anullsink; 56 | -------------------------------------------------------------------------------- /lib/aresample.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the aresample function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().aresample() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the aresample function. 17 | */ 18 | function aresample(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'aresample', function() { 20 | return new AresampleFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AresampleFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'aresample', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.aresample = aresample; 56 | -------------------------------------------------------------------------------- /lib/scale2ref.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the scale2ref function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().scale2ref() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the scale2ref function. 17 | */ 18 | function scale2ref(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'scale2ref', function() { 20 | return new Scale2refFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class Scale2refFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'scale2ref', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.scale2ref = scale2ref; 56 | -------------------------------------------------------------------------------- /lib/alphamerge.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the alphamerge function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().alphamerge() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the alphamerge function. 17 | */ 18 | function alphamerge(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'alphamerge', function() { 20 | return new AlphamergeFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AlphamergeFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'alphamerge', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.alphamerge = alphamerge; 56 | -------------------------------------------------------------------------------- /lib/buffersink.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the buffersink function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().buffersink() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the buffersink function. 17 | */ 18 | function buffersink(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'buffersink', function() { 20 | return new BuffersinkFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class BuffersinkFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'buffersink', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.buffersink = buffersink; 56 | -------------------------------------------------------------------------------- /lib/replaygain.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the replaygain function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().replaygain() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the replaygain function. 17 | */ 18 | function replaygain(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'replaygain', function() { 20 | return new ReplaygainFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ReplaygainFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'replaygain', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.replaygain = replaygain; 56 | -------------------------------------------------------------------------------- /lib/super2xsai.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the super2xsai function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().super2xsai() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the super2xsai function. 17 | */ 18 | function super2xsai(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'super2xsai', function() { 20 | return new Super2xsaiFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class Super2xsaiFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'super2xsai', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.super2xsai = super2xsai; 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![npm version](https://badge.fury.io/js/fluent-ffmpeg-filters.svg)](https://badge.fury.io/js/fluent-ffmpeg-filters) 2 | [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/itoche/fluent-ffmpeg-filters.js/master/LICENSE) 3 | 4 | # fluent-ffmpeg-filters 5 | Extend fluent-ffmpeg with fluent API for adding ffmpeg filters, as listed [here](http://ffmpeg.org/ffmpeg-filters.html). 6 | 7 | `lib` directory contains one file per filter. Each filter module exposes a function that augment the ffmpeg instance. 8 | 9 | Here is an example of use with the `vstack` filter. 10 | 11 | ```javascript 12 | let ffmpeg = require('fluent-ffmpeg'); 13 | const vstack = require('fluent-ffmpeg-filters').vstack; 14 | 15 | ffmpeg = vstack(ffmpeg); 16 | 17 | ffmpeg('./one.jpg') 18 | .input('./two.jpg') 19 | .vstack() 20 | .input(2) 21 | .shortest(0) 22 | .build() 23 | .applyVideoFilters() 24 | ``` 25 | 26 | ### Generic functions 27 | These functions are available on each filter. 28 | 29 | #### build(): register the filter configuration 30 | The `build()` function is to be called once the filter function and its configuration function have all been called. Calling `build()` registers the filter configuration on the ffmpeg instance. 31 | 32 | #### applyComplexFilter(): configure all filters 33 | Apply the configurations of all filters to the ffmpeg instance. Call it only once. 34 | 35 | #### applyVideoFilters(): configure video filters 36 | Apply the configurations of video filters to the ffmpeg instance. 37 | 38 | #### applyAudioFilters(): configure audio filters 39 | Apply the configurations of audio filters to the ffmpeg instance. 40 | -------------------------------------------------------------------------------- /lib/abuffersink.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the abuffersink function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().abuffersink() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the abuffersink function. 17 | */ 18 | function abuffersink(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'abuffersink', function() { 20 | return new AbuffersinkFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AbuffersinkFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'abuffersink', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.abuffersink = abuffersink; 56 | -------------------------------------------------------------------------------- /lib/pixdesctest.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the pixdesctest function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().pixdesctest() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the pixdesctest function. 17 | */ 18 | function pixdesctest(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'pixdesctest', function() { 20 | return new PixdesctestFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class PixdesctestFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'pixdesctest', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.pixdesctest = pixdesctest; 56 | -------------------------------------------------------------------------------- /lib/premultiply.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the premultiply function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().premultiply() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the premultiply function. 17 | */ 18 | function premultiply(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'premultiply', function() { 20 | return new PremultiplyFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class PremultiplyFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'premultiply', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.premultiply = premultiply; 56 | -------------------------------------------------------------------------------- /lib/alphaextract.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the alphaextract function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().alphaextract() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the alphaextract function. 17 | */ 18 | function alphaextract(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'alphaextract', function() { 20 | return new AlphaextractFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AlphaextractFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'alphaextract', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.alphaextract = alphaextract; 56 | -------------------------------------------------------------------------------- /lib/repeatfields.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the repeatfields function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().repeatfields() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the repeatfields function. 17 | */ 18 | function repeatfields(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'repeatfields', function() { 20 | return new RepeatfieldsFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class RepeatfieldsFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'repeatfields', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.repeatfields = repeatfields; 56 | -------------------------------------------------------------------------------- /lib/volumedetect.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the volumedetect function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().volumedetect() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the volumedetect function. 17 | */ 18 | function volumedetect(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'volumedetect', function() { 20 | return new VolumedetectFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class VolumedetectFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'volumedetect', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.volumedetect = volumedetect; 56 | -------------------------------------------------------------------------------- /lib/separatefields.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the separatefields function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().separatefields() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the separatefields function. 17 | */ 18 | function separatefields(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'separatefields', function() { 20 | return new SeparatefieldsFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class SeparatefieldsFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | } 38 | 39 | 40 | /** 41 | * Creates this filter configuration and registers it in the ffmpeg instance. 42 | * @return {ffmpegCommand} The ffmpeg instance. 43 | */ 44 | build() { 45 | let opt = {}; 46 | 47 | addFilter(this.ffmpeg, { 48 | filter: 'separatefields', 49 | options: opt 50 | }); 51 | return this.ffmpeg; 52 | } 53 | } 54 | 55 | module.exports.separatefields = separatefields; 56 | -------------------------------------------------------------------------------- /lib/ass.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the ass function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().ass() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the ass function. 17 | */ 18 | function ass(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'ass', function() { 20 | return new AssFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AssFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AssFilter.prototype.withShaping = this.shaping; 38 | } 39 | 40 | /** 41 | * 42 | * @param val 43 | */ 44 | shaping(val) { 45 | this._shaping = val; 46 | return this; 47 | } 48 | 49 | 50 | /** 51 | * Creates this filter configuration and registers it in the ffmpeg instance. 52 | * @return {ffmpegCommand} The ffmpeg instance. 53 | */ 54 | build() { 55 | let opt = {}; 56 | if (this._shaping) { 57 | opt['shaping'] = this._shaping; 58 | } 59 | 60 | addFilter(this.ffmpeg, { 61 | filter: 'ass', 62 | options: opt 63 | }); 64 | return this.ffmpeg; 65 | } 66 | } 67 | 68 | module.exports.ass = ass; 69 | -------------------------------------------------------------------------------- /lib/phase.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the phase function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().phase() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the phase function. 17 | */ 18 | function phase(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'phase', function() { 20 | return new PhaseFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class PhaseFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | PhaseFilter.prototype.withMode = this.mode; 38 | } 39 | 40 | /** 41 | * 42 | * @param val 43 | */ 44 | mode(val) { 45 | this._mode = val; 46 | return this; 47 | } 48 | 49 | 50 | /** 51 | * Creates this filter configuration and registers it in the ffmpeg instance. 52 | * @return {ffmpegCommand} The ffmpeg instance. 53 | */ 54 | build() { 55 | let opt = {}; 56 | if (this._mode) { 57 | opt['mode'] = this._mode; 58 | } 59 | 60 | addFilter(this.ffmpeg, { 61 | filter: 'phase', 62 | options: opt 63 | }); 64 | return this.ffmpeg; 65 | } 66 | } 67 | 68 | module.exports.phase = phase; 69 | -------------------------------------------------------------------------------- /lib/qp.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the qp function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().qp() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the qp function. 17 | */ 18 | function qp(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'qp', function() { 20 | return new QpFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class QpFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | QpFilter.prototype.withQp = this.qp; 38 | } 39 | 40 | /** 41 | * Set expression for quantization parameter. 42 | * 43 | * @param val 44 | */ 45 | qp(val) { 46 | this._qp = val; 47 | return this; 48 | } 49 | 50 | 51 | /** 52 | * Creates this filter configuration and registers it in the ffmpeg instance. 53 | * @return {ffmpegCommand} The ffmpeg instance. 54 | */ 55 | build() { 56 | let opt = {}; 57 | if (this._qp) { 58 | opt['qp'] = this._qp; 59 | } 60 | 61 | addFilter(this.ffmpeg, { 62 | filter: 'qp', 63 | options: opt 64 | }); 65 | return this.ffmpeg; 66 | } 67 | } 68 | 69 | module.exports.qp = qp; 70 | -------------------------------------------------------------------------------- /lib/abench.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the abench function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().abench() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the abench function. 17 | */ 18 | function abench(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'abench', function() { 20 | return new AbenchFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AbenchFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AbenchFilter.prototype.withAction = this.action; 38 | } 39 | 40 | /** 41 | * 42 | * @param val 43 | */ 44 | action(val) { 45 | this._action = val; 46 | return this; 47 | } 48 | 49 | 50 | /** 51 | * Creates this filter configuration and registers it in the ffmpeg instance. 52 | * @return {ffmpegCommand} The ffmpeg instance. 53 | */ 54 | build() { 55 | let opt = {}; 56 | if (this._action) { 57 | opt['action'] = this._action; 58 | } 59 | 60 | addFilter(this.ffmpeg, { 61 | filter: 'abench', 62 | options: opt 63 | }); 64 | return this.ffmpeg; 65 | } 66 | } 67 | 68 | module.exports.abench = abench; 69 | -------------------------------------------------------------------------------- /lib/displace.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the displace function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().displace() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the displace function. 17 | */ 18 | function displace(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'displace', function() { 20 | return new DisplaceFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class DisplaceFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | DisplaceFilter.prototype.withEdge = this.edge; 38 | } 39 | 40 | /** 41 | * 42 | * @param val 43 | */ 44 | edge(val) { 45 | this._edge = val; 46 | return this; 47 | } 48 | 49 | 50 | /** 51 | * Creates this filter configuration and registers it in the ffmpeg instance. 52 | * @return {ffmpegCommand} The ffmpeg instance. 53 | */ 54 | build() { 55 | let opt = {}; 56 | if (this._edge) { 57 | opt['edge'] = this._edge; 58 | } 59 | 60 | addFilter(this.ffmpeg, { 61 | filter: 'displace', 62 | options: opt 63 | }); 64 | return this.ffmpeg; 65 | } 66 | } 67 | 68 | module.exports.displace = displace; 69 | -------------------------------------------------------------------------------- /lib/setfield.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the setfield function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().setfield() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the setfield function. 17 | */ 18 | function setfield(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'setfield', function() { 20 | return new SetfieldFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class SetfieldFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | SetfieldFilter.prototype.withMode = this.mode; 38 | } 39 | 40 | /** 41 | * 42 | * @param val 43 | */ 44 | mode(val) { 45 | this._mode = val; 46 | return this; 47 | } 48 | 49 | 50 | /** 51 | * Creates this filter configuration and registers it in the ffmpeg instance. 52 | * @return {ffmpegCommand} The ffmpeg instance. 53 | */ 54 | build() { 55 | let opt = {}; 56 | if (this._mode) { 57 | opt['mode'] = this._mode; 58 | } 59 | 60 | addFilter(this.ffmpeg, { 61 | filter: 'setfield', 62 | options: opt 63 | }); 64 | return this.ffmpeg; 65 | } 66 | } 67 | 68 | module.exports.setfield = setfield; 69 | -------------------------------------------------------------------------------- /lib/dejudder.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the dejudder function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().dejudder() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the dejudder function. 17 | */ 18 | function dejudder(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'dejudder', function() { 20 | return new DejudderFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class DejudderFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | DejudderFilter.prototype.withCycle = this.cycle; 38 | } 39 | 40 | /** 41 | * 42 | * @param val 43 | */ 44 | cycle(val) { 45 | this._cycle = val; 46 | return this; 47 | } 48 | 49 | 50 | /** 51 | * Creates this filter configuration and registers it in the ffmpeg instance. 52 | * @return {ffmpegCommand} The ffmpeg instance. 53 | */ 54 | build() { 55 | let opt = {}; 56 | if (this._cycle) { 57 | opt['cycle'] = this._cycle; 58 | } 59 | 60 | addFilter(this.ffmpeg, { 61 | filter: 'dejudder', 62 | options: opt 63 | }); 64 | return this.ffmpeg; 65 | } 66 | } 67 | 68 | module.exports.dejudder = dejudder; 69 | -------------------------------------------------------------------------------- /lib/weave.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the weave function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().weave() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the weave function. 17 | */ 18 | function weave(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'weave', function() { 20 | return new WeaveFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class WeaveFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | WeaveFilter.prototype.withFirst_field = this.first_field; 38 | } 39 | 40 | /** 41 | * 42 | * @param val 43 | */ 44 | first_field(val) { 45 | this._first_field = val; 46 | return this; 47 | } 48 | 49 | 50 | /** 51 | * Creates this filter configuration and registers it in the ffmpeg instance. 52 | * @return {ffmpegCommand} The ffmpeg instance. 53 | */ 54 | build() { 55 | let opt = {}; 56 | if (this._first_field) { 57 | opt['first_field'] = this._first_field; 58 | } 59 | 60 | addFilter(this.ffmpeg, { 61 | filter: 'weave', 62 | options: opt 63 | }); 64 | return this.ffmpeg; 65 | } 66 | } 67 | 68 | module.exports.weave = weave; 69 | -------------------------------------------------------------------------------- /lib/pp.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the pp function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().pp() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the pp function. 17 | */ 18 | function pp(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'pp', function() { 20 | return new PpFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class PpFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | PpFilter.prototype.withSubfilters = this.subfilters; 38 | } 39 | 40 | /** 41 | * Set postprocessing subfilters string. 42 | * 43 | * @param val 44 | */ 45 | subfilters(val) { 46 | this._subfilters = val; 47 | return this; 48 | } 49 | 50 | 51 | /** 52 | * Creates this filter configuration and registers it in the ffmpeg instance. 53 | * @return {ffmpegCommand} The ffmpeg instance. 54 | */ 55 | build() { 56 | let opt = {}; 57 | if (this._subfilters) { 58 | opt['subfilters'] = this._subfilters; 59 | } 60 | 61 | addFilter(this.ffmpeg, { 62 | filter: 'pp', 63 | options: opt 64 | }); 65 | return this.ffmpeg; 66 | } 67 | } 68 | 69 | module.exports.pp = pp; 70 | -------------------------------------------------------------------------------- /lib/framepack.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the framepack function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().framepack() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the framepack function. 17 | */ 18 | function framepack(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'framepack', function() { 20 | return new FramepackFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class FramepackFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | FramepackFilter.prototype.withFormat = this.format; 38 | } 39 | 40 | /** 41 | * 42 | * @param val 43 | */ 44 | format(val) { 45 | this._format = val; 46 | return this; 47 | } 48 | 49 | 50 | /** 51 | * Creates this filter configuration and registers it in the ffmpeg instance. 52 | * @return {ffmpegCommand} The ffmpeg instance. 53 | */ 54 | build() { 55 | let opt = {}; 56 | if (this._format) { 57 | opt['format'] = this._format; 58 | } 59 | 60 | addFilter(this.ffmpeg, { 61 | filter: 'framepack', 62 | options: opt 63 | }); 64 | return this.ffmpeg; 65 | } 66 | } 67 | 68 | module.exports.framepack = framepack; 69 | -------------------------------------------------------------------------------- /lib/hqx.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the hqx function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().hqx() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the hqx function. 17 | */ 18 | function hqx(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'hqx', function() { 20 | return new HqxFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class HqxFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | HqxFilter.prototype.withN = this.n; 38 | } 39 | 40 | /** 41 | * Set the scaling dimension: 2 for hq2x, 3 for 42 | * hq3x and 4 for hq4x. 43 | * Default is 3. 44 | * 45 | * @param val 46 | */ 47 | n(val) { 48 | this._n = val; 49 | return this; 50 | } 51 | 52 | 53 | /** 54 | * Creates this filter configuration and registers it in the ffmpeg instance. 55 | * @return {ffmpegCommand} The ffmpeg instance. 56 | */ 57 | build() { 58 | let opt = {}; 59 | if (this._n) { 60 | opt['n'] = this._n; 61 | } 62 | 63 | addFilter(this.ffmpeg, { 64 | filter: 'hqx', 65 | options: opt 66 | }); 67 | return this.ffmpeg; 68 | } 69 | } 70 | 71 | module.exports.hqx = hqx; 72 | -------------------------------------------------------------------------------- /lib/xbr.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the xbr function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().xbr() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the xbr function. 17 | */ 18 | function xbr(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'xbr', function() { 20 | return new XbrFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class XbrFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | XbrFilter.prototype.withN = this.n; 38 | } 39 | 40 | /** 41 | * Set the scaling dimension: 2 for 2xBR, 3 for 42 | * 3xBR and 4 for 4xBR. 43 | * Default is 3. 44 | * 45 | * @param val 46 | */ 47 | n(val) { 48 | this._n = val; 49 | return this; 50 | } 51 | 52 | 53 | /** 54 | * Creates this filter configuration and registers it in the ffmpeg instance. 55 | * @return {ffmpegCommand} The ffmpeg instance. 56 | */ 57 | build() { 58 | let opt = {}; 59 | if (this._n) { 60 | opt['n'] = this._n; 61 | } 62 | 63 | addFilter(this.ffmpeg, { 64 | filter: 'xbr', 65 | options: opt 66 | }); 67 | return this.ffmpeg; 68 | } 69 | } 70 | 71 | module.exports.xbr = xbr; 72 | -------------------------------------------------------------------------------- /lib/bbox.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the bbox function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().bbox() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the bbox function. 17 | */ 18 | function bbox(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'bbox', function() { 20 | return new BboxFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class BboxFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | BboxFilter.prototype.withMin_val = this.min_val; 38 | } 39 | 40 | /** 41 | * Set the minimal luminance value. Default is 16. 42 | * 43 | * @param val 44 | */ 45 | min_val(val) { 46 | this._min_val = val; 47 | return this; 48 | } 49 | 50 | 51 | /** 52 | * Creates this filter configuration and registers it in the ffmpeg instance. 53 | * @return {ffmpegCommand} The ffmpeg instance. 54 | */ 55 | build() { 56 | let opt = {}; 57 | if (this._min_val) { 58 | opt['min_val'] = this._min_val; 59 | } 60 | 61 | addFilter(this.ffmpeg, { 62 | filter: 'bbox', 63 | options: opt 64 | }); 65 | return this.ffmpeg; 66 | } 67 | } 68 | 69 | module.exports.bbox = bbox; 70 | -------------------------------------------------------------------------------- /lib/anequalizer.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the anequalizer function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().anequalizer() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the anequalizer function. 17 | */ 18 | function anequalizer(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'anequalizer', function() { 20 | return new AnequalizerFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AnequalizerFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AnequalizerFilter.prototype.withParams = this.params; 38 | } 39 | 40 | /** 41 | * 42 | * @param val 43 | */ 44 | params(val) { 45 | this._params = val; 46 | return this; 47 | } 48 | 49 | 50 | /** 51 | * Creates this filter configuration and registers it in the ffmpeg instance. 52 | * @return {ffmpegCommand} The ffmpeg instance. 53 | */ 54 | build() { 55 | let opt = {}; 56 | if (this._params) { 57 | opt['params'] = this._params; 58 | } 59 | 60 | addFilter(this.ffmpeg, { 61 | filter: 'anequalizer', 62 | options: opt 63 | }); 64 | return this.ffmpeg; 65 | } 66 | } 67 | 68 | module.exports.anequalizer = anequalizer; 69 | -------------------------------------------------------------------------------- /lib/amerge.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the amerge function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().amerge() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the amerge function. 17 | */ 18 | function amerge(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'amerge', function() { 20 | return new AmergeFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AmergeFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AmergeFilter.prototype.withInputs = this.inputs; 38 | } 39 | 40 | /** 41 | * Set the number of inputs. Default is 2. 42 | * 43 | * 44 | * @param val 45 | */ 46 | inputs(val) { 47 | this._inputs = val; 48 | return this; 49 | } 50 | 51 | 52 | /** 53 | * Creates this filter configuration and registers it in the ffmpeg instance. 54 | * @return {ffmpegCommand} The ffmpeg instance. 55 | */ 56 | build() { 57 | let opt = {}; 58 | if (this._inputs) { 59 | opt['inputs'] = this._inputs; 60 | } 61 | 62 | addFilter(this.ffmpeg, { 63 | filter: 'amerge', 64 | options: opt 65 | }); 66 | return this.ffmpeg; 67 | } 68 | } 69 | 70 | module.exports.amerge = amerge; 71 | -------------------------------------------------------------------------------- /lib/asettb.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the asettb function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().asettb() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the asettb function. 17 | */ 18 | function asettb(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'asettb', function() { 20 | return new AsettbFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AsettbFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AsettbFilter.prototype.withExpr = this.expr; 38 | } 39 | 40 | /** 41 | * The expression which is evaluated into the output timebase. 42 | * 43 | * 44 | * @param val 45 | */ 46 | expr(val) { 47 | this._expr = val; 48 | return this; 49 | } 50 | 51 | 52 | /** 53 | * Creates this filter configuration and registers it in the ffmpeg instance. 54 | * @return {ffmpegCommand} The ffmpeg instance. 55 | */ 56 | build() { 57 | let opt = {}; 58 | if (this._expr) { 59 | opt['expr'] = this._expr; 60 | } 61 | 62 | addFilter(this.ffmpeg, { 63 | filter: 'asettb', 64 | options: opt 65 | }); 66 | return this.ffmpeg; 67 | } 68 | } 69 | 70 | module.exports.asettb = asettb; 71 | -------------------------------------------------------------------------------- /lib/extractplanes.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the extractplanes function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().extractplanes() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the extractplanes function. 17 | */ 18 | function extractplanes(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'extractplanes', function() { 20 | return new ExtractplanesFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ExtractplanesFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | ExtractplanesFilter.prototype.withPlanes = this.planes; 38 | } 39 | 40 | /** 41 | * 42 | * @param val 43 | */ 44 | planes(val) { 45 | this._planes = val; 46 | return this; 47 | } 48 | 49 | 50 | /** 51 | * Creates this filter configuration and registers it in the ffmpeg instance. 52 | * @return {ffmpegCommand} The ffmpeg instance. 53 | */ 54 | build() { 55 | let opt = {}; 56 | if (this._planes) { 57 | opt['planes'] = this._planes; 58 | } 59 | 60 | addFilter(this.ffmpeg, { 61 | filter: 'extractplanes', 62 | options: opt 63 | }); 64 | return this.ffmpeg; 65 | } 66 | } 67 | 68 | module.exports.extractplanes = extractplanes; 69 | -------------------------------------------------------------------------------- /lib/asetpts.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the asetpts function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().asetpts() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the asetpts function. 17 | */ 18 | function asetpts(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'asetpts', function() { 20 | return new AsetptsFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AsetptsFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AsetptsFilter.prototype.withExpr = this.expr; 38 | } 39 | 40 | /** 41 | * The expression which is evaluated for each frame to construct its timestamp. 42 | * 43 | * 44 | * @param val 45 | */ 46 | expr(val) { 47 | this._expr = val; 48 | return this; 49 | } 50 | 51 | 52 | /** 53 | * Creates this filter configuration and registers it in the ffmpeg instance. 54 | * @return {ffmpegCommand} The ffmpeg instance. 55 | */ 56 | build() { 57 | let opt = {}; 58 | if (this._expr) { 59 | opt['expr'] = this._expr; 60 | } 61 | 62 | addFilter(this.ffmpeg, { 63 | filter: 'asetpts', 64 | options: opt 65 | }); 66 | return this.ffmpeg; 67 | } 68 | } 69 | 70 | module.exports.asetpts = asetpts; 71 | -------------------------------------------------------------------------------- /lib/asetrate.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the asetrate function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().asetrate() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the asetrate function. 17 | */ 18 | function asetrate(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'asetrate', function() { 20 | return new AsetrateFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AsetrateFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AsetrateFilter.prototype.withSample_rate = this.sample_rate; 38 | } 39 | 40 | /** 41 | * Set the output sample rate. Default is 44100 Hz. 42 | * 43 | * @param val 44 | */ 45 | sample_rate(val) { 46 | this._sample_rate = val; 47 | return this; 48 | } 49 | 50 | 51 | /** 52 | * Creates this filter configuration and registers it in the ffmpeg instance. 53 | * @return {ffmpegCommand} The ffmpeg instance. 54 | */ 55 | build() { 56 | let opt = {}; 57 | if (this._sample_rate) { 58 | opt['sample_rate'] = this._sample_rate; 59 | } 60 | 61 | addFilter(this.ffmpeg, { 62 | filter: 'asetrate', 63 | options: opt 64 | }); 65 | return this.ffmpeg; 66 | } 67 | } 68 | 69 | module.exports.asetrate = asetrate; 70 | -------------------------------------------------------------------------------- /lib/field.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the field function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().field() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the field function. 17 | */ 18 | function field(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'field', function() { 20 | return new FieldFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class FieldFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | FieldFilter.prototype.withType = this.type; 38 | } 39 | 40 | /** 41 | * Specify whether to extract the top (if the value is 0 or 42 | * top) or the bottom field (if the value is 1 or 43 | * bottom). 44 | * 45 | * @param val 46 | */ 47 | type(val) { 48 | this._type = val; 49 | return this; 50 | } 51 | 52 | 53 | /** 54 | * Creates this filter configuration and registers it in the ffmpeg instance. 55 | * @return {ffmpegCommand} The ffmpeg instance. 56 | */ 57 | build() { 58 | let opt = {}; 59 | if (this._type) { 60 | opt['type'] = this._type; 61 | } 62 | 63 | addFilter(this.ffmpeg, { 64 | filter: 'field', 65 | options: opt 66 | }); 67 | return this.ffmpeg; 68 | } 69 | } 70 | 71 | module.exports.field = field; 72 | -------------------------------------------------------------------------------- /lib/hwupload_cuda.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the hwupload_cuda function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().hwupload_cuda() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the hwupload_cuda function. 17 | */ 18 | function hwupload_cuda(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'hwupload_cuda', function() { 20 | return new Hwupload_cudaFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class Hwupload_cudaFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | Hwupload_cudaFilter.prototype.withDevice = this.device; 38 | } 39 | 40 | /** 41 | * The number of the CUDA device to use 42 | * 43 | * @param val 44 | */ 45 | device(val) { 46 | this._device = val; 47 | return this; 48 | } 49 | 50 | 51 | /** 52 | * Creates this filter configuration and registers it in the ffmpeg instance. 53 | * @return {ffmpegCommand} The ffmpeg instance. 54 | */ 55 | build() { 56 | let opt = {}; 57 | if (this._device) { 58 | opt['device'] = this._device; 59 | } 60 | 61 | addFilter(this.ffmpeg, { 62 | filter: 'hwupload_cuda', 63 | options: opt 64 | }); 65 | return this.ffmpeg; 66 | } 67 | } 68 | 69 | module.exports.hwupload_cuda = hwupload_cuda; 70 | -------------------------------------------------------------------------------- /lib/format.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the format function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().format() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the format function. 17 | */ 18 | function format(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'format', function() { 20 | return new FormatFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class FormatFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | FormatFilter.prototype.withPix_fmts = this.pix_fmts; 38 | } 39 | 40 | /** 41 | * A ’|’-separated list of pixel format names, such as 42 | * "pix_fmts=yuv420p|monow|rgb24". 43 | * 44 | * 45 | * @param val 46 | */ 47 | pix_fmts(val) { 48 | this._pix_fmts = val; 49 | return this; 50 | } 51 | 52 | 53 | /** 54 | * Creates this filter configuration and registers it in the ffmpeg instance. 55 | * @return {ffmpegCommand} The ffmpeg instance. 56 | */ 57 | build() { 58 | let opt = {}; 59 | if (this._pix_fmts) { 60 | opt['pix_fmts'] = this._pix_fmts; 61 | } 62 | 63 | addFilter(this.ffmpeg, { 64 | filter: 'format', 65 | options: opt 66 | }); 67 | return this.ffmpeg; 68 | } 69 | } 70 | 71 | module.exports.format = format; 72 | -------------------------------------------------------------------------------- /lib/ainterleave.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the ainterleave function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().ainterleave() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the ainterleave function. 17 | */ 18 | function ainterleave(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'ainterleave', function() { 20 | return new AinterleaveFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AinterleaveFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AinterleaveFilter.prototype.withNb_inputs = this.nb_inputs; 38 | } 39 | 40 | /** 41 | * Set the number of different inputs, it is 2 by default. 42 | * 43 | * @param val 44 | */ 45 | nb_inputs(val) { 46 | this._nb_inputs = val; 47 | return this; 48 | } 49 | 50 | 51 | /** 52 | * Creates this filter configuration and registers it in the ffmpeg instance. 53 | * @return {ffmpegCommand} The ffmpeg instance. 54 | */ 55 | build() { 56 | let opt = {}; 57 | if (this._nb_inputs) { 58 | opt['nb_inputs'] = this._nb_inputs; 59 | } 60 | 61 | addFilter(this.ffmpeg, { 62 | filter: 'ainterleave', 63 | options: opt 64 | }); 65 | return this.ffmpeg; 66 | } 67 | } 68 | 69 | module.exports.ainterleave = ainterleave; 70 | -------------------------------------------------------------------------------- /lib/framestep.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the framestep function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().framestep() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the framestep function. 17 | */ 18 | function framestep(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'framestep', function() { 20 | return new FramestepFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class FramestepFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | FramestepFilter.prototype.withStep = this.step; 38 | } 39 | 40 | /** 41 | * Select frame after every step frames. 42 | * Allowed values are positive integers higher than 0. Default value is 1. 43 | * 44 | * @param val 45 | */ 46 | step(val) { 47 | this._step = val; 48 | return this; 49 | } 50 | 51 | 52 | /** 53 | * Creates this filter configuration and registers it in the ffmpeg instance. 54 | * @return {ffmpegCommand} The ffmpeg instance. 55 | */ 56 | build() { 57 | let opt = {}; 58 | if (this._step) { 59 | opt['step'] = this._step; 60 | } 61 | 62 | addFilter(this.ffmpeg, { 63 | filter: 'framestep', 64 | options: opt 65 | }); 66 | return this.ffmpeg; 67 | } 68 | } 69 | 70 | module.exports.framestep = framestep; 71 | -------------------------------------------------------------------------------- /lib/showpalette.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the showpalette function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().showpalette() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the showpalette function. 17 | */ 18 | function showpalette(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'showpalette', function() { 20 | return new ShowpaletteFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ShowpaletteFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | ShowpaletteFilter.prototype.withS = this.s; 38 | } 39 | 40 | /** 41 | * Set the size of the box used to represent one palette color entry. Default is 42 | * 30 (for a 30x30 pixel box). 43 | * 44 | * @param val 45 | */ 46 | s(val) { 47 | this._s = val; 48 | return this; 49 | } 50 | 51 | 52 | /** 53 | * Creates this filter configuration and registers it in the ffmpeg instance. 54 | * @return {ffmpegCommand} The ffmpeg instance. 55 | */ 56 | build() { 57 | let opt = {}; 58 | if (this._s) { 59 | opt['s'] = this._s; 60 | } 61 | 62 | addFilter(this.ffmpeg, { 63 | filter: 'showpalette', 64 | options: opt 65 | }); 66 | return this.ffmpeg; 67 | } 68 | } 69 | 70 | module.exports.showpalette = showpalette; 71 | -------------------------------------------------------------------------------- /lib/fieldorder.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the fieldorder function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().fieldorder() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the fieldorder function. 17 | */ 18 | function fieldorder(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'fieldorder', function() { 20 | return new FieldorderFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class FieldorderFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | FieldorderFilter.prototype.withOrder = this.order; 38 | } 39 | 40 | /** 41 | * The output field order. Valid values are tff for top field first or bff 42 | * for bottom field first. 43 | * 44 | * @param val 45 | */ 46 | order(val) { 47 | this._order = val; 48 | return this; 49 | } 50 | 51 | 52 | /** 53 | * Creates this filter configuration and registers it in the ffmpeg instance. 54 | * @return {ffmpegCommand} The ffmpeg instance. 55 | */ 56 | build() { 57 | let opt = {}; 58 | if (this._order) { 59 | opt['order'] = this._order; 60 | } 61 | 62 | addFilter(this.ffmpeg, { 63 | filter: 'fieldorder', 64 | options: opt 65 | }); 66 | return this.ffmpeg; 67 | } 68 | } 69 | 70 | module.exports.fieldorder = fieldorder; 71 | -------------------------------------------------------------------------------- /lib/midequalizer.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the midequalizer function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().midequalizer() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the midequalizer function. 17 | */ 18 | function midequalizer(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'midequalizer', function() { 20 | return new MidequalizerFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class MidequalizerFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | MidequalizerFilter.prototype.withPlanes = this.planes; 38 | } 39 | 40 | /** 41 | * Set which planes to process. Default is 15, which is all available planes. 42 | * 43 | * @param val 44 | */ 45 | planes(val) { 46 | this._planes = val; 47 | return this; 48 | } 49 | 50 | 51 | /** 52 | * Creates this filter configuration and registers it in the ffmpeg instance. 53 | * @return {ffmpegCommand} The ffmpeg instance. 54 | */ 55 | build() { 56 | let opt = {}; 57 | if (this._planes) { 58 | opt['planes'] = this._planes; 59 | } 60 | 61 | addFilter(this.ffmpeg, { 62 | filter: 'midequalizer', 63 | options: opt 64 | }); 65 | return this.ffmpeg; 66 | } 67 | } 68 | 69 | module.exports.midequalizer = midequalizer; 70 | -------------------------------------------------------------------------------- /lib/noformat.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the noformat function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().noformat() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the noformat function. 17 | */ 18 | function noformat(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'noformat', function() { 20 | return new NoformatFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class NoformatFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | NoformatFilter.prototype.withPix_fmts = this.pix_fmts; 38 | } 39 | 40 | /** 41 | * A ’|’-separated list of pixel format names, such as 42 | * apix_fmts=yuv420p|monow|rgb24". 43 | * 44 | * 45 | * @param val 46 | */ 47 | pix_fmts(val) { 48 | this._pix_fmts = val; 49 | return this; 50 | } 51 | 52 | 53 | /** 54 | * Creates this filter configuration and registers it in the ffmpeg instance. 55 | * @return {ffmpegCommand} The ffmpeg instance. 56 | */ 57 | build() { 58 | let opt = {}; 59 | if (this._pix_fmts) { 60 | opt['pix_fmts'] = this._pix_fmts; 61 | } 62 | 63 | addFilter(this.ffmpeg, { 64 | filter: 'noformat', 65 | options: opt 66 | }); 67 | return this.ffmpeg; 68 | } 69 | } 70 | 71 | module.exports.noformat = noformat; 72 | -------------------------------------------------------------------------------- /lib/threshold.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the threshold function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().threshold() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the threshold function. 17 | */ 18 | function threshold(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'threshold', function() { 20 | return new ThresholdFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ThresholdFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | ThresholdFilter.prototype.withPlanes = this.planes; 38 | } 39 | 40 | /** 41 | * Set which planes will be processed, unprocessed planes will be copied. 42 | * By default value 0xf, all planes will be processed. 43 | * 44 | * @param val 45 | */ 46 | planes(val) { 47 | this._planes = val; 48 | return this; 49 | } 50 | 51 | 52 | /** 53 | * Creates this filter configuration and registers it in the ffmpeg instance. 54 | * @return {ffmpegCommand} The ffmpeg instance. 55 | */ 56 | build() { 57 | let opt = {}; 58 | if (this._planes) { 59 | opt['planes'] = this._planes; 60 | } 61 | 62 | addFilter(this.ffmpeg, { 63 | filter: 'threshold', 64 | options: opt 65 | }); 66 | return this.ffmpeg; 67 | } 68 | } 69 | 70 | module.exports.threshold = threshold; 71 | -------------------------------------------------------------------------------- /lib/arealtime.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the arealtime function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().arealtime() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the arealtime function. 17 | */ 18 | function arealtime(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'arealtime', function() { 20 | return new ArealtimeFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ArealtimeFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | ArealtimeFilter.prototype.withLimit = this.limit; 38 | } 39 | 40 | /** 41 | * Time limit for the pauses. Any pause longer than that will be considered 42 | * a timestamp discontinuity and reset the timer. Default is 2 seconds. 43 | * 44 | * @param val 45 | */ 46 | limit(val) { 47 | this._limit = val; 48 | return this; 49 | } 50 | 51 | 52 | /** 53 | * Creates this filter configuration and registers it in the ffmpeg instance. 54 | * @return {ffmpegCommand} The ffmpeg instance. 55 | */ 56 | build() { 57 | let opt = {}; 58 | if (this._limit) { 59 | opt['limit'] = this._limit; 60 | } 61 | 62 | addFilter(this.ffmpeg, { 63 | filter: 'arealtime', 64 | options: opt 65 | }); 66 | return this.ffmpeg; 67 | } 68 | } 69 | 70 | module.exports.arealtime = arealtime; 71 | -------------------------------------------------------------------------------- /lib/ssim.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the ssim function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().ssim() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the ssim function. 17 | */ 18 | function ssim(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'ssim', function() { 20 | return new SsimFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class SsimFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | SsimFilter.prototype.withStats_file = this.stats_file; 38 | } 39 | 40 | /** 41 | * If specified the filter will use the named file to save the SSIM of 42 | * each individual frame. When filename equals "-" the data is sent to 43 | * standard output. 44 | * 45 | * @param val 46 | */ 47 | stats_file(val) { 48 | this._stats_file = val; 49 | return this; 50 | } 51 | 52 | 53 | /** 54 | * Creates this filter configuration and registers it in the ffmpeg instance. 55 | * @return {ffmpegCommand} The ffmpeg instance. 56 | */ 57 | build() { 58 | let opt = {}; 59 | if (this._stats_file) { 60 | opt['stats_file'] = this._stats_file; 61 | } 62 | 63 | addFilter(this.ffmpeg, { 64 | filter: 'ssim', 65 | options: opt 66 | }); 67 | return this.ffmpeg; 68 | } 69 | } 70 | 71 | module.exports.ssim = ssim; 72 | -------------------------------------------------------------------------------- /lib/thumbnail.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the thumbnail function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().thumbnail() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the thumbnail function. 17 | */ 18 | function thumbnail(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'thumbnail', function() { 20 | return new ThumbnailFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ThumbnailFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | ThumbnailFilter.prototype.withN = this.n; 38 | } 39 | 40 | /** 41 | * Set the frames batch size to analyze; in a set of n frames, the filter 42 | * will pick one of them, and then handle the next batch of n frames until 43 | * the end. Default is 100. 44 | * 45 | * @param val 46 | */ 47 | n(val) { 48 | this._n = val; 49 | return this; 50 | } 51 | 52 | 53 | /** 54 | * Creates this filter configuration and registers it in the ffmpeg instance. 55 | * @return {ffmpegCommand} The ffmpeg instance. 56 | */ 57 | build() { 58 | let opt = {}; 59 | if (this._n) { 60 | opt['n'] = this._n; 61 | } 62 | 63 | addFilter(this.ffmpeg, { 64 | filter: 'thumbnail', 65 | options: opt 66 | }); 67 | return this.ffmpeg; 68 | } 69 | } 70 | 71 | module.exports.thumbnail = thumbnail; 72 | -------------------------------------------------------------------------------- /lib/channelsplit.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the channelsplit function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().channelsplit() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the channelsplit function. 17 | */ 18 | function channelsplit(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'channelsplit', function() { 20 | return new ChannelsplitFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ChannelsplitFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | ChannelsplitFilter.prototype.withChannel_layout = this.channel_layout; 38 | } 39 | 40 | /** 41 | * The channel layout of the input stream. The default is "stereo". 42 | * 43 | * @param val 44 | */ 45 | channel_layout(val) { 46 | this._channel_layout = val; 47 | return this; 48 | } 49 | 50 | 51 | /** 52 | * Creates this filter configuration and registers it in the ffmpeg instance. 53 | * @return {ffmpegCommand} The ffmpeg instance. 54 | */ 55 | build() { 56 | let opt = {}; 57 | if (this._channel_layout) { 58 | opt['channel_layout'] = this._channel_layout; 59 | } 60 | 61 | addFilter(this.ffmpeg, { 62 | filter: 'channelsplit', 63 | options: opt 64 | }); 65 | return this.ffmpeg; 66 | } 67 | } 68 | 69 | module.exports.channelsplit = channelsplit; 70 | -------------------------------------------------------------------------------- /lib/maskedmerge.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the maskedmerge function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().maskedmerge() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the maskedmerge function. 17 | */ 18 | function maskedmerge(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'maskedmerge', function() { 20 | return new MaskedmergeFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class MaskedmergeFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | MaskedmergeFilter.prototype.withPlanes = this.planes; 38 | } 39 | 40 | /** 41 | * Set which planes will be processed as bitmap, unprocessed planes will be 42 | * copied from first stream. 43 | * By default value 0xf, all planes will be processed. 44 | * 45 | * @param val 46 | */ 47 | planes(val) { 48 | this._planes = val; 49 | return this; 50 | } 51 | 52 | 53 | /** 54 | * Creates this filter configuration and registers it in the ffmpeg instance. 55 | * @return {ffmpegCommand} The ffmpeg instance. 56 | */ 57 | build() { 58 | let opt = {}; 59 | if (this._planes) { 60 | opt['planes'] = this._planes; 61 | } 62 | 63 | addFilter(this.ffmpeg, { 64 | filter: 'maskedmerge', 65 | options: opt 66 | }); 67 | return this.ffmpeg; 68 | } 69 | } 70 | 71 | module.exports.maskedmerge = maskedmerge; 72 | -------------------------------------------------------------------------------- /lib/lut3d.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the lut3d function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().lut3d() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the lut3d function. 17 | */ 18 | function lut3d(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'lut3d', function() { 20 | return new Lut3dFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class Lut3dFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | Lut3dFilter.prototype.withFile = this.file; 38 | Lut3dFilter.prototype.withInterp = this.interp; 39 | } 40 | 41 | /** 42 | * 43 | * @param val 44 | */ 45 | file(val) { 46 | this._file = val; 47 | return this; 48 | } 49 | 50 | /** 51 | * 52 | * @param val 53 | */ 54 | interp(val) { 55 | this._interp = val; 56 | return this; 57 | } 58 | 59 | 60 | /** 61 | * Creates this filter configuration and registers it in the ffmpeg instance. 62 | * @return {ffmpegCommand} The ffmpeg instance. 63 | */ 64 | build() { 65 | let opt = {}; 66 | if (this._file) { 67 | opt['file'] = this._file; 68 | } 69 | if (this._interp) { 70 | opt['interp'] = this._interp; 71 | } 72 | 73 | addFilter(this.ffmpeg, { 74 | filter: 'lut3d', 75 | options: opt 76 | }); 77 | return this.ffmpeg; 78 | } 79 | } 80 | 81 | module.exports.lut3d = lut3d; 82 | -------------------------------------------------------------------------------- /lib/stereo3d.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the stereo3d function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().stereo3d() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the stereo3d function. 17 | */ 18 | function stereo3d(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'stereo3d', function() { 20 | return new Stereo3dFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class Stereo3dFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | Stereo3dFilter.prototype.withIn = this._in; 38 | Stereo3dFilter.prototype.withOut = this.out; 39 | } 40 | 41 | /** 42 | * 43 | * @param val 44 | */ 45 | _in(val) { 46 | this.__in = val; 47 | return this; 48 | } 49 | 50 | /** 51 | * 52 | * @param val 53 | */ 54 | out(val) { 55 | this._out = val; 56 | return this; 57 | } 58 | 59 | 60 | /** 61 | * Creates this filter configuration and registers it in the ffmpeg instance. 62 | * @return {ffmpegCommand} The ffmpeg instance. 63 | */ 64 | build() { 65 | let opt = {}; 66 | if (this.__in) { 67 | opt['in'] = this.__in; 68 | } 69 | if (this._out) { 70 | opt['out'] = this._out; 71 | } 72 | 73 | addFilter(this.ffmpeg, { 74 | filter: 'stereo3d', 75 | options: opt 76 | }); 77 | return this.ffmpeg; 78 | } 79 | } 80 | 81 | module.exports.stereo3d = stereo3d; 82 | -------------------------------------------------------------------------------- /lib/removelogo.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the removelogo function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().removelogo() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the removelogo function. 17 | */ 18 | function removelogo(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'removelogo', function() { 20 | return new RemovelogoFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class RemovelogoFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | RemovelogoFilter.prototype.withFilename = this.filename; 38 | } 39 | 40 | /** 41 | * Set the filter bitmap file, which can be any image format supported by 42 | * libavformat. The width and height of the image file must match those of the 43 | * video stream being processed. 44 | * 45 | * @param val 46 | */ 47 | filename(val) { 48 | this._filename = val; 49 | return this; 50 | } 51 | 52 | 53 | /** 54 | * Creates this filter configuration and registers it in the ffmpeg instance. 55 | * @return {ffmpegCommand} The ffmpeg instance. 56 | */ 57 | build() { 58 | let opt = {}; 59 | if (this._filename) { 60 | opt['filename'] = this._filename; 61 | } 62 | 63 | addFilter(this.ffmpeg, { 64 | filter: 'removelogo', 65 | options: opt 66 | }); 67 | return this.ffmpeg; 68 | } 69 | } 70 | 71 | module.exports.removelogo = removelogo; 72 | -------------------------------------------------------------------------------- /lib/w3fdif.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the w3fdif function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().w3fdif() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the w3fdif function. 17 | */ 18 | function w3fdif(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'w3fdif', function() { 20 | return new W3fdifFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class W3fdifFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | W3fdifFilter.prototype.withFilter = this.filter; 38 | W3fdifFilter.prototype.withDeint = this.deint; 39 | } 40 | 41 | /** 42 | * 43 | * @param val 44 | */ 45 | filter(val) { 46 | this._filter = val; 47 | return this; 48 | } 49 | 50 | /** 51 | * 52 | * @param val 53 | */ 54 | deint(val) { 55 | this._deint = val; 56 | return this; 57 | } 58 | 59 | 60 | /** 61 | * Creates this filter configuration and registers it in the ffmpeg instance. 62 | * @return {ffmpegCommand} The ffmpeg instance. 63 | */ 64 | build() { 65 | let opt = {}; 66 | if (this._filter) { 67 | opt['filter'] = this._filter; 68 | } 69 | if (this._deint) { 70 | opt['deint'] = this._deint; 71 | } 72 | 73 | addFilter(this.ffmpeg, { 74 | filter: 'w3fdif', 75 | options: opt 76 | }); 77 | return this.ffmpeg; 78 | } 79 | } 80 | 81 | module.exports.w3fdif = w3fdif; 82 | -------------------------------------------------------------------------------- /lib/colormatrix.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the colormatrix function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().colormatrix() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the colormatrix function. 17 | */ 18 | function colormatrix(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'colormatrix', function() { 20 | return new ColormatrixFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ColormatrixFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | ColormatrixFilter.prototype.withSrc = this.src; 38 | ColormatrixFilter.prototype.withDst = this.dst; 39 | } 40 | 41 | /** 42 | * 43 | * @param val 44 | */ 45 | src(val) { 46 | this._src = val; 47 | return this; 48 | } 49 | 50 | /** 51 | * 52 | * @param val 53 | */ 54 | dst(val) { 55 | this._dst = val; 56 | return this; 57 | } 58 | 59 | 60 | /** 61 | * Creates this filter configuration and registers it in the ffmpeg instance. 62 | * @return {ffmpegCommand} The ffmpeg instance. 63 | */ 64 | build() { 65 | let opt = {}; 66 | if (this._src) { 67 | opt['src'] = this._src; 68 | } 69 | if (this._dst) { 70 | opt['dst'] = this._dst; 71 | } 72 | 73 | addFilter(this.ffmpeg, { 74 | filter: 'colormatrix', 75 | options: opt 76 | }); 77 | return this.ffmpeg; 78 | } 79 | } 80 | 81 | module.exports.colormatrix = colormatrix; 82 | -------------------------------------------------------------------------------- /lib/tinterlace.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the tinterlace function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().tinterlace() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the tinterlace function. 17 | */ 18 | function tinterlace(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'tinterlace', function() { 20 | return new TinterlaceFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class TinterlaceFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | TinterlaceFilter.prototype.withMode = this.mode; 38 | TinterlaceFilter.prototype.withFlags = this.flags; 39 | } 40 | 41 | /** 42 | * 43 | * @param val 44 | */ 45 | mode(val) { 46 | this._mode = val; 47 | return this; 48 | } 49 | 50 | /** 51 | * 52 | * @param val 53 | */ 54 | flags(val) { 55 | this._flags = val; 56 | return this; 57 | } 58 | 59 | 60 | /** 61 | * Creates this filter configuration and registers it in the ffmpeg instance. 62 | * @return {ffmpegCommand} The ffmpeg instance. 63 | */ 64 | build() { 65 | let opt = {}; 66 | if (this._mode) { 67 | opt['mode'] = this._mode; 68 | } 69 | if (this._flags) { 70 | opt['flags'] = this._flags; 71 | } 72 | 73 | addFilter(this.ffmpeg, { 74 | filter: 'tinterlace', 75 | options: opt 76 | }); 77 | return this.ffmpeg; 78 | } 79 | } 80 | 81 | module.exports.tinterlace = tinterlace; 82 | -------------------------------------------------------------------------------- /lib/transpose.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the transpose function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().transpose() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the transpose function. 17 | */ 18 | function transpose(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'transpose', function() { 20 | return new TransposeFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class TransposeFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | TransposeFilter.prototype.withDir = this.dir; 38 | TransposeFilter.prototype.withPassthrough = this.passthrough; 39 | } 40 | 41 | /** 42 | * 43 | * @param val 44 | */ 45 | dir(val) { 46 | this._dir = val; 47 | return this; 48 | } 49 | 50 | /** 51 | * 52 | * @param val 53 | */ 54 | passthrough(val) { 55 | this._passthrough = val; 56 | return this; 57 | } 58 | 59 | 60 | /** 61 | * Creates this filter configuration and registers it in the ffmpeg instance. 62 | * @return {ffmpegCommand} The ffmpeg instance. 63 | */ 64 | build() { 65 | let opt = {}; 66 | if (this._dir) { 67 | opt['dir'] = this._dir; 68 | } 69 | if (this._passthrough) { 70 | opt['passthrough'] = this._passthrough; 71 | } 72 | 73 | addFilter(this.ffmpeg, { 74 | filter: 'transpose', 75 | options: opt 76 | }); 77 | return this.ffmpeg; 78 | } 79 | } 80 | 81 | module.exports.transpose = transpose; 82 | -------------------------------------------------------------------------------- /lib/adelay.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the adelay function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().adelay() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the adelay function. 17 | */ 18 | function adelay(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'adelay', function() { 20 | return new AdelayFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AdelayFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AdelayFilter.prototype.withDelays = this.delays; 38 | } 39 | 40 | /** 41 | * Set list of delays in milliseconds for each channel separated by ’|’. 42 | * At least one delay greater than 0 should be provided. 43 | * Unused delays will be silently ignored. If number of given delays is 44 | * smaller than number of channels all remaining channels will not be delayed. 45 | * If you want to delay exact number of samples, append ’S’ to number. 46 | * 47 | * @param val 48 | */ 49 | delays(val) { 50 | this._delays = val; 51 | return this; 52 | } 53 | 54 | 55 | /** 56 | * Creates this filter configuration and registers it in the ffmpeg instance. 57 | * @return {ffmpegCommand} The ffmpeg instance. 58 | */ 59 | build() { 60 | let opt = {}; 61 | if (this._delays) { 62 | opt['delays'] = this._delays; 63 | } 64 | 65 | addFilter(this.ffmpeg, { 66 | filter: 'adelay', 67 | options: opt 68 | }); 69 | return this.ffmpeg; 70 | } 71 | } 72 | 73 | module.exports.adelay = adelay; 74 | -------------------------------------------------------------------------------- /lib/cover_rect.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the cover_rect function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().cover_rect() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the cover_rect function. 17 | */ 18 | function cover_rect(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'cover_rect', function() { 20 | return new Cover_rectFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class Cover_rectFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | Cover_rectFilter.prototype.withCover = this.cover; 38 | Cover_rectFilter.prototype.withMode = this.mode; 39 | } 40 | 41 | /** 42 | * Filepath of the optional cover image, needs to be in yuv420. 43 | * 44 | * 45 | * @param val 46 | */ 47 | cover(val) { 48 | this._cover = val; 49 | return this; 50 | } 51 | 52 | /** 53 | * 54 | * @param val 55 | */ 56 | mode(val) { 57 | this._mode = val; 58 | return this; 59 | } 60 | 61 | 62 | /** 63 | * Creates this filter configuration and registers it in the ffmpeg instance. 64 | * @return {ffmpegCommand} The ffmpeg instance. 65 | */ 66 | build() { 67 | let opt = {}; 68 | if (this._cover) { 69 | opt['cover'] = this._cover; 70 | } 71 | if (this._mode) { 72 | opt['mode'] = this._mode; 73 | } 74 | 75 | addFilter(this.ffmpeg, { 76 | filter: 'cover_rect', 77 | options: opt 78 | }); 79 | return this.ffmpeg; 80 | } 81 | } 82 | 83 | module.exports.cover_rect = cover_rect; 84 | -------------------------------------------------------------------------------- /lib/shuffleframes.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the shuffleframes function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().shuffleframes() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the shuffleframes function. 17 | */ 18 | function shuffleframes(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'shuffleframes', function() { 20 | return new ShuffleframesFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ShuffleframesFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | ShuffleframesFilter.prototype.withMapping = this.mapping; 38 | } 39 | 40 | /** 41 | * Set the destination indexes of input frames. 42 | * This is space or ’|’ separated list of indexes that maps input frames to output 43 | * frames. Number of indexes also sets maximal value that each index may have. 44 | * ’-1’ index have special meaning and that is to drop frame. 45 | * 46 | * @param val 47 | */ 48 | mapping(val) { 49 | this._mapping = val; 50 | return this; 51 | } 52 | 53 | 54 | /** 55 | * Creates this filter configuration and registers it in the ffmpeg instance. 56 | * @return {ffmpegCommand} The ffmpeg instance. 57 | */ 58 | build() { 59 | let opt = {}; 60 | if (this._mapping) { 61 | opt['mapping'] = this._mapping; 62 | } 63 | 64 | addFilter(this.ffmpeg, { 65 | filter: 'shuffleframes', 66 | options: opt 67 | }); 68 | return this.ffmpeg; 69 | } 70 | } 71 | 72 | module.exports.shuffleframes = shuffleframes; 73 | -------------------------------------------------------------------------------- /lib/pp7.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the pp7 function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().pp7() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the pp7 function. 17 | */ 18 | function pp7(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'pp7', function() { 20 | return new Pp7Filter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class Pp7Filter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | Pp7Filter.prototype.withQp = this.qp; 38 | Pp7Filter.prototype.withMode = this.mode; 39 | } 40 | 41 | /** 42 | * Force a constant quantization parameter. It accepts an integer in range 43 | * 0 to 63. If not set, the filter will use the QP from the video stream 44 | * (if available). 45 | * 46 | * 47 | * @param val 48 | */ 49 | qp(val) { 50 | this._qp = val; 51 | return this; 52 | } 53 | 54 | /** 55 | * 56 | * @param val 57 | */ 58 | mode(val) { 59 | this._mode = val; 60 | return this; 61 | } 62 | 63 | 64 | /** 65 | * Creates this filter configuration and registers it in the ffmpeg instance. 66 | * @return {ffmpegCommand} The ffmpeg instance. 67 | */ 68 | build() { 69 | let opt = {}; 70 | if (this._qp) { 71 | opt['qp'] = this._qp; 72 | } 73 | if (this._mode) { 74 | opt['mode'] = this._mode; 75 | } 76 | 77 | addFilter(this.ffmpeg, { 78 | filter: 'pp7', 79 | options: opt 80 | }); 81 | return this.ffmpeg; 82 | } 83 | } 84 | 85 | module.exports.pp7 = pp7; 86 | -------------------------------------------------------------------------------- /lib/vibrato.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the vibrato function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().vibrato() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the vibrato function. 17 | */ 18 | function vibrato(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'vibrato', function() { 20 | return new VibratoFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class VibratoFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | VibratoFilter.prototype.withF = this.f; 38 | VibratoFilter.prototype.withD = this.d; 39 | } 40 | 41 | /** 42 | * Modulation frequency in Hertz. 43 | * Range is 0.1 - 20000.0. Default value is 5.0 Hz. 44 | * 45 | * 46 | * @param val 47 | */ 48 | f(val) { 49 | this._f = val; 50 | return this; 51 | } 52 | 53 | /** 54 | * Depth of modulation as a percentage. Range is 0.0 - 1.0. 55 | * Default value is 0.5. 56 | * 57 | * @param val 58 | */ 59 | d(val) { 60 | this._d = val; 61 | return this; 62 | } 63 | 64 | 65 | /** 66 | * Creates this filter configuration and registers it in the ffmpeg instance. 67 | * @return {ffmpegCommand} The ffmpeg instance. 68 | */ 69 | build() { 70 | let opt = {}; 71 | if (this._f) { 72 | opt['f'] = this._f; 73 | } 74 | if (this._d) { 75 | opt['d'] = this._d; 76 | } 77 | 78 | addFilter(this.ffmpeg, { 79 | filter: 'vibrato', 80 | options: opt 81 | }); 82 | return this.ffmpeg; 83 | } 84 | } 85 | 86 | module.exports.vibrato = vibrato; 87 | -------------------------------------------------------------------------------- /lib/astreamselect.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the astreamselect function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().astreamselect() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the astreamselect function. 17 | */ 18 | function astreamselect(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'astreamselect', function() { 20 | return new AstreamselectFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AstreamselectFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AstreamselectFilter.prototype.withInputs = this.inputs; 38 | AstreamselectFilter.prototype.withMap = this.map; 39 | } 40 | 41 | /** 42 | * Set number of inputs. Default is 2. 43 | * 44 | * 45 | * @param val 46 | */ 47 | inputs(val) { 48 | this._inputs = val; 49 | return this; 50 | } 51 | 52 | /** 53 | * Set input indexes to remap to outputs. 54 | * 55 | * @param val 56 | */ 57 | map(val) { 58 | this._map = val; 59 | return this; 60 | } 61 | 62 | 63 | /** 64 | * Creates this filter configuration and registers it in the ffmpeg instance. 65 | * @return {ffmpegCommand} The ffmpeg instance. 66 | */ 67 | build() { 68 | let opt = {}; 69 | if (this._inputs) { 70 | opt['inputs'] = this._inputs; 71 | } 72 | if (this._map) { 73 | opt['map'] = this._map; 74 | } 75 | 76 | addFilter(this.ffmpeg, { 77 | filter: 'astreamselect', 78 | options: opt 79 | }); 80 | return this.ffmpeg; 81 | } 82 | } 83 | 84 | module.exports.astreamselect = astreamselect; 85 | -------------------------------------------------------------------------------- /lib/telecine.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the telecine function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().telecine() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the telecine function. 17 | */ 18 | function telecine(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'telecine', function() { 20 | return new TelecineFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class TelecineFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | TelecineFilter.prototype.withFirst_field = this.first_field; 38 | TelecineFilter.prototype.withPattern = this.pattern; 39 | } 40 | 41 | /** 42 | * 43 | * @param val 44 | */ 45 | first_field(val) { 46 | this._first_field = val; 47 | return this; 48 | } 49 | 50 | /** 51 | * A string of numbers representing the pulldown pattern you wish to apply. 52 | * The default value is 23. 53 | * 54 | * @param val 55 | */ 56 | pattern(val) { 57 | this._pattern = val; 58 | return this; 59 | } 60 | 61 | 62 | /** 63 | * Creates this filter configuration and registers it in the ffmpeg instance. 64 | * @return {ffmpegCommand} The ffmpeg instance. 65 | */ 66 | build() { 67 | let opt = {}; 68 | if (this._first_field) { 69 | opt['first_field'] = this._first_field; 70 | } 71 | if (this._pattern) { 72 | opt['pattern'] = this._pattern; 73 | } 74 | 75 | addFilter(this.ffmpeg, { 76 | filter: 'telecine', 77 | options: opt 78 | }); 79 | return this.ffmpeg; 80 | } 81 | } 82 | 83 | module.exports.telecine = telecine; 84 | -------------------------------------------------------------------------------- /lib/crystalizer.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the crystalizer function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().crystalizer() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the crystalizer function. 17 | */ 18 | function crystalizer(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'crystalizer', function() { 20 | return new CrystalizerFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class CrystalizerFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | CrystalizerFilter.prototype.withI = this.i; 38 | CrystalizerFilter.prototype.withC = this.c; 39 | } 40 | 41 | /** 42 | * Sets the intensity of effect (default: 2.0). Must be in range between 0.0 43 | * (unchanged sound) to 10.0 (maximum effect). 44 | * 45 | * 46 | * @param val 47 | */ 48 | i(val) { 49 | this._i = val; 50 | return this; 51 | } 52 | 53 | /** 54 | * Enable clipping. By default is enabled. 55 | * 56 | * @param val 57 | */ 58 | c(val) { 59 | this._c = val; 60 | return this; 61 | } 62 | 63 | 64 | /** 65 | * Creates this filter configuration and registers it in the ffmpeg instance. 66 | * @return {ffmpegCommand} The ffmpeg instance. 67 | */ 68 | build() { 69 | let opt = {}; 70 | if (this._i) { 71 | opt['i'] = this._i; 72 | } 73 | if (this._c) { 74 | opt['c'] = this._c; 75 | } 76 | 77 | addFilter(this.ffmpeg, { 78 | filter: 'crystalizer', 79 | options: opt 80 | }); 81 | return this.ffmpeg; 82 | } 83 | } 84 | 85 | module.exports.crystalizer = crystalizer; 86 | -------------------------------------------------------------------------------- /lib/hstack.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the hstack function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().hstack() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the hstack function. 17 | */ 18 | function hstack(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'hstack', function() { 20 | return new HstackFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class HstackFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | HstackFilter.prototype.withInputs = this.inputs; 38 | HstackFilter.prototype.withShortest = this.shortest; 39 | } 40 | 41 | /** 42 | * Set number of input streams. Default is 2. 43 | * 44 | * 45 | * @param val 46 | */ 47 | inputs(val) { 48 | this._inputs = val; 49 | return this; 50 | } 51 | 52 | /** 53 | * If set to 1, force the output to terminate when the shortest input 54 | * terminates. Default value is 0. 55 | * 56 | * @param val 57 | */ 58 | shortest(val) { 59 | this._shortest = val; 60 | return this; 61 | } 62 | 63 | 64 | /** 65 | * Creates this filter configuration and registers it in the ffmpeg instance. 66 | * @return {ffmpegCommand} The ffmpeg instance. 67 | */ 68 | build() { 69 | let opt = {}; 70 | if (this._inputs) { 71 | opt['inputs'] = this._inputs; 72 | } 73 | if (this._shortest) { 74 | opt['shortest'] = this._shortest; 75 | } 76 | 77 | addFilter(this.ffmpeg, { 78 | filter: 'hstack', 79 | options: opt 80 | }); 81 | return this.ffmpeg; 82 | } 83 | } 84 | 85 | module.exports.hstack = hstack; 86 | -------------------------------------------------------------------------------- /lib/vstack.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the vstack function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().vstack() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the vstack function. 17 | */ 18 | function vstack(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'vstack', function() { 20 | return new VstackFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class VstackFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | VstackFilter.prototype.withInputs = this.inputs; 38 | VstackFilter.prototype.withShortest = this.shortest; 39 | } 40 | 41 | /** 42 | * Set number of input streams. Default is 2. 43 | * 44 | * 45 | * @param val 46 | */ 47 | inputs(val) { 48 | this._inputs = val; 49 | return this; 50 | } 51 | 52 | /** 53 | * If set to 1, force the output to terminate when the shortest input 54 | * terminates. Default value is 0. 55 | * 56 | * @param val 57 | */ 58 | shortest(val) { 59 | this._shortest = val; 60 | return this; 61 | } 62 | 63 | 64 | /** 65 | * Creates this filter configuration and registers it in the ffmpeg instance. 66 | * @return {ffmpegCommand} The ffmpeg instance. 67 | */ 68 | build() { 69 | let opt = {}; 70 | if (this._inputs) { 71 | opt['inputs'] = this._inputs; 72 | } 73 | if (this._shortest) { 74 | opt['shortest'] = this._shortest; 75 | } 76 | 77 | addFilter(this.ffmpeg, { 78 | filter: 'vstack', 79 | options: opt 80 | }); 81 | return this.ffmpeg; 82 | } 83 | } 84 | 85 | module.exports.vstack = vstack; 86 | -------------------------------------------------------------------------------- /lib/aperms.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the aperms function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().aperms() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the aperms function. 17 | */ 18 | function aperms(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'aperms', function() { 20 | return new ApermsFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ApermsFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | ApermsFilter.prototype.withMode = this.mode; 38 | ApermsFilter.prototype.withSeed = this.seed; 39 | } 40 | 41 | /** 42 | * 43 | * @param val 44 | */ 45 | mode(val) { 46 | this._mode = val; 47 | return this; 48 | } 49 | 50 | /** 51 | * Set the seed for the random mode, must be an integer included between 52 | * 0 and UINT32_MAX. If not specified, or if explicitly set to 53 | * -1, the filter will try to use a good random seed on a best effort 54 | * basis. 55 | * 56 | * @param val 57 | */ 58 | seed(val) { 59 | this._seed = val; 60 | return this; 61 | } 62 | 63 | 64 | /** 65 | * Creates this filter configuration and registers it in the ffmpeg instance. 66 | * @return {ffmpegCommand} The ffmpeg instance. 67 | */ 68 | build() { 69 | let opt = {}; 70 | if (this._mode) { 71 | opt['mode'] = this._mode; 72 | } 73 | if (this._seed) { 74 | opt['seed'] = this._seed; 75 | } 76 | 77 | addFilter(this.ffmpeg, { 78 | filter: 'aperms', 79 | options: opt 80 | }); 81 | return this.ffmpeg; 82 | } 83 | } 84 | 85 | module.exports.aperms = aperms; 86 | -------------------------------------------------------------------------------- /lib/asendcmd.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the asendcmd function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().asendcmd() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the asendcmd function. 17 | */ 18 | function asendcmd(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'asendcmd', function() { 20 | return new AsendcmdFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AsendcmdFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AsendcmdFilter.prototype.withCommands = this.commands; 38 | AsendcmdFilter.prototype.withFilename = this.filename; 39 | } 40 | 41 | /** 42 | * Set the commands to be read and sent to the other filters. 43 | * 44 | * @param val 45 | */ 46 | commands(val) { 47 | this._commands = val; 48 | return this; 49 | } 50 | 51 | /** 52 | * Set the filename of the commands to be read and sent to the other 53 | * filters. 54 | * 55 | * @param val 56 | */ 57 | filename(val) { 58 | this._filename = val; 59 | return this; 60 | } 61 | 62 | 63 | /** 64 | * Creates this filter configuration and registers it in the ffmpeg instance. 65 | * @return {ffmpegCommand} The ffmpeg instance. 66 | */ 67 | build() { 68 | let opt = {}; 69 | if (this._commands) { 70 | opt['commands'] = this._commands; 71 | } 72 | if (this._filename) { 73 | opt['filename'] = this._filename; 74 | } 75 | 76 | addFilter(this.ffmpeg, { 77 | filter: 'asendcmd', 78 | options: opt 79 | }); 80 | return this.ffmpeg; 81 | } 82 | } 83 | 84 | module.exports.asendcmd = asendcmd; 85 | -------------------------------------------------------------------------------- /generator/filter.hdb: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the {{filterName}} function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().{{filterName}}() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the {{filterName}} function. 17 | */ 18 | function {{toIdentifier filterName}}(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, '{{toIdentifier filterName}}', function() { 20 | return new {{toIdentifier (capitalize filterName)}}Filter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class {{toIdentifier (capitalize filterName)}}Filter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | {{#each params}} 38 | {{capitalize ../filterName}}Filter.prototype.with{{toIdentifier (capitalize paramName)}} = this.{{toIdentifier paramName}}; 39 | {{/each}} 40 | } 41 | 42 | {{#each params}} 43 | /** 44 | * {{formatComment description}} 45 | * @param val 46 | */ 47 | {{toIdentifier name}}(val) { 48 | this._{{toIdentifier name}} = val; 49 | return this; 50 | } 51 | 52 | {{/each}} 53 | 54 | /** 55 | * Creates this filter configuration and registers it in the ffmpeg instance. 56 | * @return {ffmpegCommand} The ffmpeg instance. 57 | */ 58 | build() { 59 | let opt = {}; 60 | {{#each params}} 61 | if (this._{{toIdentifier paramName}}) { 62 | opt['{{paramName}}'] = this._{{toIdentifier paramName}}; 63 | } 64 | {{/each}} 65 | 66 | addFilter(this.ffmpeg, { 67 | filter: '{{filterName}}', 68 | options: opt 69 | }); 70 | return this.ffmpeg; 71 | } 72 | } 73 | 74 | module.exports.{{toIdentifier filterName}} = {{toIdentifier filterName}}; 75 | -------------------------------------------------------------------------------- /lib/ocv.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the ocv function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().ocv() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the ocv function. 17 | */ 18 | function ocv(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'ocv', function() { 20 | return new OcvFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class OcvFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | OcvFilter.prototype.withFilter_name = this.filter_name; 38 | OcvFilter.prototype.withFilter_params = this.filter_params; 39 | } 40 | 41 | /** 42 | * The name of the libopencv filter to apply. 43 | * 44 | * 45 | * @param val 46 | */ 47 | filter_name(val) { 48 | this._filter_name = val; 49 | return this; 50 | } 51 | 52 | /** 53 | * The parameters to pass to the libopencv filter. If not specified, the default 54 | * values are assumed. 55 | * 56 | * 57 | * @param val 58 | */ 59 | filter_params(val) { 60 | this._filter_params = val; 61 | return this; 62 | } 63 | 64 | 65 | /** 66 | * Creates this filter configuration and registers it in the ffmpeg instance. 67 | * @return {ffmpegCommand} The ffmpeg instance. 68 | */ 69 | build() { 70 | let opt = {}; 71 | if (this._filter_name) { 72 | opt['filter_name'] = this._filter_name; 73 | } 74 | if (this._filter_params) { 75 | opt['filter_params'] = this._filter_params; 76 | } 77 | 78 | addFilter(this.ffmpeg, { 79 | filter: 'ocv', 80 | options: opt 81 | }); 82 | return this.ffmpeg; 83 | } 84 | } 85 | 86 | module.exports.ocv = ocv; 87 | -------------------------------------------------------------------------------- /lib/yadif.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the yadif function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().yadif() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the yadif function. 17 | */ 18 | function yadif(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'yadif', function() { 20 | return new YadifFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class YadifFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | YadifFilter.prototype.withMode = this.mode; 38 | YadifFilter.prototype.withParity = this.parity; 39 | YadifFilter.prototype.withDeint = this.deint; 40 | } 41 | 42 | /** 43 | * 44 | * @param val 45 | */ 46 | mode(val) { 47 | this._mode = val; 48 | return this; 49 | } 50 | 51 | /** 52 | * 53 | * @param val 54 | */ 55 | parity(val) { 56 | this._parity = val; 57 | return this; 58 | } 59 | 60 | /** 61 | * 62 | * @param val 63 | */ 64 | deint(val) { 65 | this._deint = val; 66 | return this; 67 | } 68 | 69 | 70 | /** 71 | * Creates this filter configuration and registers it in the ffmpeg instance. 72 | * @return {ffmpegCommand} The ffmpeg instance. 73 | */ 74 | build() { 75 | let opt = {}; 76 | if (this._mode) { 77 | opt['mode'] = this._mode; 78 | } 79 | if (this._parity) { 80 | opt['parity'] = this._parity; 81 | } 82 | if (this._deint) { 83 | opt['deint'] = this._deint; 84 | } 85 | 86 | addFilter(this.ffmpeg, { 87 | filter: 'yadif', 88 | options: opt 89 | }); 90 | return this.ffmpeg; 91 | } 92 | } 93 | 94 | module.exports.yadif = yadif; 95 | -------------------------------------------------------------------------------- /lib/bitplanenoise.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the bitplanenoise function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().bitplanenoise() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the bitplanenoise function. 17 | */ 18 | function bitplanenoise(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'bitplanenoise', function() { 20 | return new BitplanenoiseFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class BitplanenoiseFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | BitplanenoiseFilter.prototype.withBitplane = this.bitplane; 38 | BitplanenoiseFilter.prototype.withFilter = this.filter; 39 | } 40 | 41 | /** 42 | * Set which plane to analyze. Default is 1. 43 | * 44 | * 45 | * @param val 46 | */ 47 | bitplane(val) { 48 | this._bitplane = val; 49 | return this; 50 | } 51 | 52 | /** 53 | * Filter out noisy pixels from bitplane set above. 54 | * Default is disabled. 55 | * 56 | * @param val 57 | */ 58 | filter(val) { 59 | this._filter = val; 60 | return this; 61 | } 62 | 63 | 64 | /** 65 | * Creates this filter configuration and registers it in the ffmpeg instance. 66 | * @return {ffmpegCommand} The ffmpeg instance. 67 | */ 68 | build() { 69 | let opt = {}; 70 | if (this._bitplane) { 71 | opt['bitplane'] = this._bitplane; 72 | } 73 | if (this._filter) { 74 | opt['filter'] = this._filter; 75 | } 76 | 77 | addFilter(this.ffmpeg, { 78 | filter: 'bitplanenoise', 79 | options: opt 80 | }); 81 | return this.ffmpeg; 82 | } 83 | } 84 | 85 | module.exports.bitplanenoise = bitplanenoise; 86 | -------------------------------------------------------------------------------- /lib/extrastereo.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the extrastereo function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().extrastereo() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the extrastereo function. 17 | */ 18 | function extrastereo(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'extrastereo', function() { 20 | return new ExtrastereoFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class ExtrastereoFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | ExtrastereoFilter.prototype.withM = this.m; 38 | ExtrastereoFilter.prototype.withC = this.c; 39 | } 40 | 41 | /** 42 | * Sets the difference coefficient (default: 2.5). 0.0 means mono sound 43 | * (average of both channels), with 1.0 sound will be unchanged, with 44 | * -1.0 left and right channels will be swapped. 45 | * 46 | * 47 | * @param val 48 | */ 49 | m(val) { 50 | this._m = val; 51 | return this; 52 | } 53 | 54 | /** 55 | * Enable clipping. By default is enabled. 56 | * 57 | * @param val 58 | */ 59 | c(val) { 60 | this._c = val; 61 | return this; 62 | } 63 | 64 | 65 | /** 66 | * Creates this filter configuration and registers it in the ffmpeg instance. 67 | * @return {ffmpegCommand} The ffmpeg instance. 68 | */ 69 | build() { 70 | let opt = {}; 71 | if (this._m) { 72 | opt['m'] = this._m; 73 | } 74 | if (this._c) { 75 | opt['c'] = this._c; 76 | } 77 | 78 | addFilter(this.ffmpeg, { 79 | filter: 'extrastereo', 80 | options: opt 81 | }); 82 | return this.ffmpeg; 83 | } 84 | } 85 | 86 | module.exports.extrastereo = extrastereo; 87 | -------------------------------------------------------------------------------- /lib/dcshift.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the dcshift function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().dcshift() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the dcshift function. 17 | */ 18 | function dcshift(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'dcshift', function() { 20 | return new DcshiftFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class DcshiftFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | DcshiftFilter.prototype.withShift = this.shift; 38 | DcshiftFilter.prototype.withLimitergain = this.limitergain; 39 | } 40 | 41 | /** 42 | * Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift 43 | * the audio. 44 | * 45 | * 46 | * @param val 47 | */ 48 | shift(val) { 49 | this._shift = val; 50 | return this; 51 | } 52 | 53 | /** 54 | * Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is 55 | * used to prevent clipping. 56 | * 57 | * @param val 58 | */ 59 | limitergain(val) { 60 | this._limitergain = val; 61 | return this; 62 | } 63 | 64 | 65 | /** 66 | * Creates this filter configuration and registers it in the ffmpeg instance. 67 | * @return {ffmpegCommand} The ffmpeg instance. 68 | */ 69 | build() { 70 | let opt = {}; 71 | if (this._shift) { 72 | opt['shift'] = this._shift; 73 | } 74 | if (this._limitergain) { 75 | opt['limitergain'] = this._limitergain; 76 | } 77 | 78 | addFilter(this.ffmpeg, { 79 | filter: 'dcshift', 80 | options: opt 81 | }); 82 | return this.ffmpeg; 83 | } 84 | } 85 | 86 | module.exports.dcshift = dcshift; 87 | -------------------------------------------------------------------------------- /lib/blackframe.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the blackframe function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().blackframe() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the blackframe function. 17 | */ 18 | function blackframe(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'blackframe', function() { 20 | return new BlackframeFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class BlackframeFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | BlackframeFilter.prototype.withAmount = this.amount; 38 | BlackframeFilter.prototype.withThreshold = this.threshold; 39 | } 40 | 41 | /** 42 | * The percentage of the pixels that have to be below the threshold; it defaults to 43 | * 98. 44 | * 45 | * 46 | * @param val 47 | */ 48 | amount(val) { 49 | this._amount = val; 50 | return this; 51 | } 52 | 53 | /** 54 | * The threshold below which a pixel value is considered black; it defaults to 55 | * 32. 56 | * 57 | * 58 | * @param val 59 | */ 60 | threshold(val) { 61 | this._threshold = val; 62 | return this; 63 | } 64 | 65 | 66 | /** 67 | * Creates this filter configuration and registers it in the ffmpeg instance. 68 | * @return {ffmpegCommand} The ffmpeg instance. 69 | */ 70 | build() { 71 | let opt = {}; 72 | if (this._amount) { 73 | opt['amount'] = this._amount; 74 | } 75 | if (this._threshold) { 76 | opt['threshold'] = this._threshold; 77 | } 78 | 79 | addFilter(this.ffmpeg, { 80 | filter: 'blackframe', 81 | options: opt 82 | }); 83 | return this.ffmpeg; 84 | } 85 | } 86 | 87 | module.exports.blackframe = blackframe; 88 | -------------------------------------------------------------------------------- /lib/asidedata.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the asidedata function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().asidedata() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the asidedata function. 17 | */ 18 | function asidedata(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'asidedata', function() { 20 | return new AsidedataFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AsidedataFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AsidedataFilter.prototype.withMode = this.mode; 38 | AsidedataFilter.prototype.withType = this.type; 39 | } 40 | 41 | /** 42 | * 43 | * @param val 44 | */ 45 | mode(val) { 46 | this._mode = val; 47 | return this; 48 | } 49 | 50 | /** 51 | * Set side data type used with all modes. Must be set for select mode. For 52 | * the list of frame side data types, refer to the AVFrameSideDataType enum 53 | * in libavutil/frame.h. For example, to choose 54 | * AV_FRAME_DATA_PANSCAN side data, you must specify PANSCAN. 55 | * 56 | * 57 | * @param val 58 | */ 59 | type(val) { 60 | this._type = val; 61 | return this; 62 | } 63 | 64 | 65 | /** 66 | * Creates this filter configuration and registers it in the ffmpeg instance. 67 | * @return {ffmpegCommand} The ffmpeg instance. 68 | */ 69 | build() { 70 | let opt = {}; 71 | if (this._mode) { 72 | opt['mode'] = this._mode; 73 | } 74 | if (this._type) { 75 | opt['type'] = this._type; 76 | } 77 | 78 | addFilter(this.ffmpeg, { 79 | filter: 'asidedata', 80 | options: opt 81 | }); 82 | return this.ffmpeg; 83 | } 84 | } 85 | 86 | module.exports.asidedata = asidedata; 87 | -------------------------------------------------------------------------------- /lib/bs2b.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the bs2b function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().bs2b() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the bs2b function. 17 | */ 18 | function bs2b(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'bs2b', function() { 20 | return new Bs2bFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class Bs2bFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | Bs2bFilter.prototype.withProfile = this.profile; 38 | Bs2bFilter.prototype.withFcut = this.fcut; 39 | Bs2bFilter.prototype.withFeed = this.feed; 40 | } 41 | 42 | /** 43 | * 44 | * @param val 45 | */ 46 | profile(val) { 47 | this._profile = val; 48 | return this; 49 | } 50 | 51 | /** 52 | * Cut frequency (in Hz). 53 | * 54 | * 55 | * @param val 56 | */ 57 | fcut(val) { 58 | this._fcut = val; 59 | return this; 60 | } 61 | 62 | /** 63 | * Feed level (in Hz). 64 | * 65 | * 66 | * @param val 67 | */ 68 | feed(val) { 69 | this._feed = val; 70 | return this; 71 | } 72 | 73 | 74 | /** 75 | * Creates this filter configuration and registers it in the ffmpeg instance. 76 | * @return {ffmpegCommand} The ffmpeg instance. 77 | */ 78 | build() { 79 | let opt = {}; 80 | if (this._profile) { 81 | opt['profile'] = this._profile; 82 | } 83 | if (this._fcut) { 84 | opt['fcut'] = this._fcut; 85 | } 86 | if (this._feed) { 87 | opt['feed'] = this._feed; 88 | } 89 | 90 | addFilter(this.ffmpeg, { 91 | filter: 'bs2b', 92 | options: opt 93 | }); 94 | return this.ffmpeg; 95 | } 96 | } 97 | 98 | module.exports.bs2b = bs2b; 99 | -------------------------------------------------------------------------------- /lib/interlace.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the interlace function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().interlace() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the interlace function. 17 | */ 18 | function interlace(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'interlace', function() { 20 | return new InterlaceFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class InterlaceFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | InterlaceFilter.prototype.withScan = this.scan; 38 | InterlaceFilter.prototype.withLowpass = this.lowpass; 39 | } 40 | 41 | /** 42 | * This determines whether the interlaced frame is taken from the even 43 | * (tff - default) or odd (bff) lines of the progressive frame. 44 | * 45 | * 46 | * @param val 47 | */ 48 | scan(val) { 49 | this._scan = val; 50 | return this; 51 | } 52 | 53 | /** 54 | * Enable (default) or disable the vertical lowpass filter to avoid twitter 55 | * interlacing and reduce moire patterns. 56 | * 57 | * @param val 58 | */ 59 | lowpass(val) { 60 | this._lowpass = val; 61 | return this; 62 | } 63 | 64 | 65 | /** 66 | * Creates this filter configuration and registers it in the ffmpeg instance. 67 | * @return {ffmpegCommand} The ffmpeg instance. 68 | */ 69 | build() { 70 | let opt = {}; 71 | if (this._scan) { 72 | opt['scan'] = this._scan; 73 | } 74 | if (this._lowpass) { 75 | opt['lowpass'] = this._lowpass; 76 | } 77 | 78 | addFilter(this.ffmpeg, { 79 | filter: 'interlace', 80 | options: opt 81 | }); 82 | return this.ffmpeg; 83 | } 84 | } 85 | 86 | module.exports.interlace = interlace; 87 | -------------------------------------------------------------------------------- /lib/utils.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | /** 3 | * Name of the property that is added to the ffmpeg instance and which will 4 | * holds the list of filters that are to be applied. 5 | * @type {String} 6 | * @static 7 | */ 8 | const FILTERS_ARR_NAME = '_fluent-ffmpeg-filters'; 9 | 10 | /** 11 | * Augment the ffmpegCommand with the filterFunc function having the name 12 | * filterName. 13 | * @param {FfmpegCommand} ffmpegCommand [description] 14 | * @param {String} filterName The name of the function 15 | * @param {Function} filterFunc The function to add 16 | * 17 | */ 18 | function registerFilter(ffmpegCommand, filterName, filterFunc) { 19 | assert(ffmpegCommand); 20 | assert(filterName); 21 | assert(filterFunc); 22 | 23 | ffmpegCommand.prototype[filterName] = filterFunc; 24 | 25 | if (!ffmpegCommand.prototype.applyVideoFilters) { 26 | ffmpegCommand.prototype.applyVideoFilters = function() { 27 | this.videoFilters(getFilters(this)); 28 | return this; 29 | }; 30 | } 31 | 32 | if (!ffmpegCommand.prototype.applyAudioFilters) { 33 | ffmpegCommand.prototype.applyAudioFilters = function() { 34 | this.audioFilters(getFilters(this)); 35 | return this; 36 | }; 37 | } 38 | 39 | if (!ffmpegCommand.prototype.applyComplexFilter) { 40 | ffmpegCommand.prototype.applyComplexFilter = function() { 41 | this.complexFilter(getFilters(this)); 42 | return this; 43 | }; 44 | } 45 | } 46 | /** 47 | * Register a filter configuration in the ffmpeg instance. 48 | * @param {FfmpegCommand} ffmpeg The ffmpeg instance. 49 | * @param {Object} filterObj The configuration of a ffmpeg filter. 50 | */ 51 | function addFilter(ffmpeg, filterObj) { 52 | assert(ffmpeg); 53 | assert(filterObj); 54 | assert(filterObj.filter); 55 | 56 | const filters = getFilters(ffmpeg); 57 | filters.push(filterObj); 58 | } 59 | 60 | /** 61 | * Returns the array of filter configurations registered in the ffmpeg instance. 62 | * @param {FfmpegCommand} ffmpeg The ffmpeg instance. 63 | * @return {Object[]} the array of filter configurations registered in the ffmpeg instance. 64 | */ 65 | function getFilters(ffmpeg) { 66 | 67 | if (!ffmpeg[FILTERS_ARR_NAME]) { 68 | ffmpeg[FILTERS_ARR_NAME] = []; 69 | } 70 | 71 | return ffmpeg[FILTERS_ARR_NAME]; 72 | } 73 | 74 | module.exports.addFilter = addFilter; 75 | module.exports.registerFilter = registerFilter; 76 | module.exports.getFilters = getFilters; 77 | -------------------------------------------------------------------------------- /lib/haldclut.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the haldclut function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().haldclut() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the haldclut function. 17 | */ 18 | function haldclut(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'haldclut', function() { 20 | return new HaldclutFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class HaldclutFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | HaldclutFilter.prototype.withShortest = this.shortest; 38 | HaldclutFilter.prototype.withRepeatlast = this.repeatlast; 39 | } 40 | 41 | /** 42 | * Force termination when the shortest input terminates. Default is 0. 43 | * 44 | * @param val 45 | */ 46 | shortest(val) { 47 | this._shortest = val; 48 | return this; 49 | } 50 | 51 | /** 52 | * Continue applying the last CLUT after the end of the stream. A value of 53 | * 0 disable the filter after the last frame of the CLUT is reached. 54 | * Default is 1. 55 | * 56 | * @param val 57 | */ 58 | repeatlast(val) { 59 | this._repeatlast = val; 60 | return this; 61 | } 62 | 63 | 64 | /** 65 | * Creates this filter configuration and registers it in the ffmpeg instance. 66 | * @return {ffmpegCommand} The ffmpeg instance. 67 | */ 68 | build() { 69 | let opt = {}; 70 | if (this._shortest) { 71 | opt['shortest'] = this._shortest; 72 | } 73 | if (this._repeatlast) { 74 | opt['repeatlast'] = this._repeatlast; 75 | } 76 | 77 | addFilter(this.ffmpeg, { 78 | filter: 'haldclut', 79 | options: opt 80 | }); 81 | return this.ffmpeg; 82 | } 83 | } 84 | 85 | module.exports.haldclut = haldclut; 86 | -------------------------------------------------------------------------------- /lib/scale_npp.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the scale_npp function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().scale_npp() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the scale_npp function. 17 | */ 18 | function scale_npp(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'scale_npp', function() { 20 | return new Scale_nppFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class Scale_nppFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | Scale_nppFilter.prototype.withFormat = this.format; 38 | Scale_nppFilter.prototype.withInterp_algo = this.interp_algo; 39 | } 40 | 41 | /** 42 | * The pixel format of the output CUDA frames. If set to the string "same" (the 43 | * default), the input format will be kept. Note that automatic format negotiation 44 | * and conversion is not yet supported for hardware frames 45 | * 46 | * 47 | * @param val 48 | */ 49 | format(val) { 50 | this._format = val; 51 | return this; 52 | } 53 | 54 | /** 55 | * 56 | * @param val 57 | */ 58 | interp_algo(val) { 59 | this._interp_algo = val; 60 | return this; 61 | } 62 | 63 | 64 | /** 65 | * Creates this filter configuration and registers it in the ffmpeg instance. 66 | * @return {ffmpegCommand} The ffmpeg instance. 67 | */ 68 | build() { 69 | let opt = {}; 70 | if (this._format) { 71 | opt['format'] = this._format; 72 | } 73 | if (this._interp_algo) { 74 | opt['interp_algo'] = this._interp_algo; 75 | } 76 | 77 | addFilter(this.ffmpeg, { 78 | filter: 'scale_npp', 79 | options: opt 80 | }); 81 | return this.ffmpeg; 82 | } 83 | } 84 | 85 | module.exports.scale_npp = scale_npp; 86 | -------------------------------------------------------------------------------- /lib/silencedetect.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the silencedetect function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().silencedetect() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the silencedetect function. 17 | */ 18 | function silencedetect(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'silencedetect', function() { 20 | return new SilencedetectFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class SilencedetectFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | SilencedetectFilter.prototype.withDuration = this.duration; 38 | SilencedetectFilter.prototype.withNoise = this.noise; 39 | } 40 | 41 | /** 42 | * Set silence duration until notification (default is 2 seconds). 43 | * 44 | * 45 | * @param val 46 | */ 47 | duration(val) { 48 | this._duration = val; 49 | return this; 50 | } 51 | 52 | /** 53 | * Set noise tolerance. Can be specified in dB (in case "dB" is appended to the 54 | * specified value) or amplitude ratio. Default is -60dB, or 0.001. 55 | * 56 | * @param val 57 | */ 58 | noise(val) { 59 | this._noise = val; 60 | return this; 61 | } 62 | 63 | 64 | /** 65 | * Creates this filter configuration and registers it in the ffmpeg instance. 66 | * @return {ffmpegCommand} The ffmpeg instance. 67 | */ 68 | build() { 69 | let opt = {}; 70 | if (this._duration) { 71 | opt['duration'] = this._duration; 72 | } 73 | if (this._noise) { 74 | opt['noise'] = this._noise; 75 | } 76 | 77 | addFilter(this.ffmpeg, { 78 | filter: 'silencedetect', 79 | options: opt 80 | }); 81 | return this.ffmpeg; 82 | } 83 | } 84 | 85 | module.exports.silencedetect = silencedetect; 86 | -------------------------------------------------------------------------------- /test/utilsTest.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const ffmpeg = require('fluent-ffmpeg'); 3 | const registerFilter = require('../lib/utils').registerFilter; 4 | const getFilters = require('../lib/utils').getFilters; 5 | const addFilter = require('../lib/utils').addFilter; 6 | 7 | describe('utils', function() { 8 | describe('#registerFilter()', function() { 9 | it('should add the filter and applyFilters() functions to ffmpeg', function() { 10 | 11 | registerFilter(ffmpeg, 'testFilter', function () { return 'Hello'}); 12 | const instance = ffmpeg(); 13 | assert(instance.testFilter); 14 | assert(typeof instance.testFilter === 'function'); 15 | assert(instance.applyComplexFilter); 16 | assert(typeof instance.applyComplexFilter === 'function'); 17 | assert(instance.applyAudioFilters); 18 | assert(typeof instance.applyAudioFilters === 'function'); 19 | assert(instance.applyVideoFilters); 20 | assert(typeof instance.applyVideoFilters === 'function'); 21 | assert.equal(instance.testFilter(), 'Hello'); 22 | }); 23 | }); 24 | 25 | describe('#addFilter()', function() { 26 | it('should fail while adding an invalid filter object', function() { 27 | const instance = ffmpeg(); 28 | 29 | registerFilter(ffmpeg, 'testFilter', function () { return 'Hello'}); 30 | 31 | assert.throws(() => addFilter(instance, {name:'testFilter'}, Error)); 32 | }); 33 | it('should add the valid filter object', function() { 34 | const instance = ffmpeg(); 35 | 36 | registerFilter(ffmpeg, 'testFilter', function () { return 'Hello'}); 37 | 38 | addFilter(instance, {filter:'testFilter'}); 39 | }); 40 | }); 41 | 42 | describe('#getFilters()', function() { 43 | it('should return the empty list of filters', function() { 44 | 45 | const instance = ffmpeg(); 46 | 47 | let filters = getFilters(instance); 48 | assert(filters); 49 | assert(Array.isArray(filters)); 50 | assert.equal(filters.length, 0); 51 | }); 52 | it('should return the list of added filters', function() { 53 | 54 | const instance = ffmpeg(); 55 | 56 | registerFilter(ffmpeg, 'testFilter', () => 'Hello'); 57 | addFilter(instance, {filter:'testFilter'}); 58 | filters = getFilters(instance); 59 | assert(Array.isArray(filters)); 60 | assert.equal(filters.length, 1); 61 | 62 | addFilter(instance, {filter:'testFilter'}); 63 | assert.equal(filters.length, 2); 64 | }); 65 | }); 66 | }); 67 | -------------------------------------------------------------------------------- /lib/random.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the random function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().random() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the random function. 17 | */ 18 | function random(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'random', function() { 20 | return new RandomFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class RandomFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | RandomFilter.prototype.withFrames = this.frames; 38 | RandomFilter.prototype.withSeed = this.seed; 39 | } 40 | 41 | /** 42 | * Set size in number of frames of internal cache, in range from 2 to 43 | * 512. Default is 30. 44 | * 45 | * 46 | * @param val 47 | */ 48 | frames(val) { 49 | this._frames = val; 50 | return this; 51 | } 52 | 53 | /** 54 | * Set seed for random number generator, must be an integer included between 55 | * 0 and UINT32_MAX. If not specified, or if explicitly set to 56 | * less than 0, the filter will try to use a good random seed on a 57 | * best effort basis. 58 | * 59 | * @param val 60 | */ 61 | seed(val) { 62 | this._seed = val; 63 | return this; 64 | } 65 | 66 | 67 | /** 68 | * Creates this filter configuration and registers it in the ffmpeg instance. 69 | * @return {ffmpegCommand} The ffmpeg instance. 70 | */ 71 | build() { 72 | let opt = {}; 73 | if (this._frames) { 74 | opt['frames'] = this._frames; 75 | } 76 | if (this._seed) { 77 | opt['seed'] = this._seed; 78 | } 79 | 80 | addFilter(this.ffmpeg, { 81 | filter: 'random', 82 | options: opt 83 | }); 84 | return this.ffmpeg; 85 | } 86 | } 87 | 88 | module.exports.random = random; 89 | -------------------------------------------------------------------------------- /lib/tremolo.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the tremolo function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().tremolo() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the tremolo function. 17 | */ 18 | function tremolo(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'tremolo', function() { 20 | return new TremoloFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class TremoloFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | TremoloFilter.prototype.withF = this.f; 38 | TremoloFilter.prototype.withD = this.d; 39 | } 40 | 41 | /** 42 | * Modulation frequency in Hertz. Modulation frequencies in the subharmonic range 43 | * (20 Hz or lower) will result in a tremolo effect. 44 | * This filter may also be used as a ring modulator by specifying 45 | * a modulation frequency higher than 20 Hz. 46 | * Range is 0.1 - 20000.0. Default value is 5.0 Hz. 47 | * 48 | * 49 | * @param val 50 | */ 51 | f(val) { 52 | this._f = val; 53 | return this; 54 | } 55 | 56 | /** 57 | * Depth of modulation as a percentage. Range is 0.0 - 1.0. 58 | * Default value is 0.5. 59 | * 60 | * @param val 61 | */ 62 | d(val) { 63 | this._d = val; 64 | return this; 65 | } 66 | 67 | 68 | /** 69 | * Creates this filter configuration and registers it in the ffmpeg instance. 70 | * @return {ffmpegCommand} The ffmpeg instance. 71 | */ 72 | build() { 73 | let opt = {}; 74 | if (this._f) { 75 | opt['f'] = this._f; 76 | } 77 | if (this._d) { 78 | opt['d'] = this._d; 79 | } 80 | 81 | addFilter(this.ffmpeg, { 82 | filter: 'tremolo', 83 | options: opt 84 | }); 85 | return this.ffmpeg; 86 | } 87 | } 88 | 89 | module.exports.tremolo = tremolo; 90 | -------------------------------------------------------------------------------- /lib/allpass.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the allpass function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().allpass() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the allpass function. 17 | */ 18 | function allpass(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'allpass', function() { 20 | return new AllpassFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class AllpassFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | AllpassFilter.prototype.withFrequency = this.frequency; 38 | AllpassFilter.prototype.withWidth_type = this.width_type; 39 | AllpassFilter.prototype.withWidth = this.width; 40 | } 41 | 42 | /** 43 | * Set frequency in Hz. 44 | * 45 | * 46 | * @param val 47 | */ 48 | frequency(val) { 49 | this._frequency = val; 50 | return this; 51 | } 52 | 53 | /** 54 | * 55 | * @param val 56 | */ 57 | width_type(val) { 58 | this._width_type = val; 59 | return this; 60 | } 61 | 62 | /** 63 | * Specify the band-width of a filter in width_type units. 64 | * 65 | * @param val 66 | */ 67 | width(val) { 68 | this._width = val; 69 | return this; 70 | } 71 | 72 | 73 | /** 74 | * Creates this filter configuration and registers it in the ffmpeg instance. 75 | * @return {ffmpegCommand} The ffmpeg instance. 76 | */ 77 | build() { 78 | let opt = {}; 79 | if (this._frequency) { 80 | opt['frequency'] = this._frequency; 81 | } 82 | if (this._width_type) { 83 | opt['width_type'] = this._width_type; 84 | } 85 | if (this._width) { 86 | opt['width'] = this._width; 87 | } 88 | 89 | addFilter(this.ffmpeg, { 90 | filter: 'allpass', 91 | options: opt 92 | }); 93 | return this.ffmpeg; 94 | } 95 | } 96 | 97 | module.exports.allpass = allpass; 98 | -------------------------------------------------------------------------------- /lib/readeia608.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the readeia608 function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().readeia608() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the readeia608 function. 17 | */ 18 | function readeia608(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'readeia608', function() { 20 | return new Readeia608Filter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class Readeia608Filter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | Readeia608Filter.prototype.withLavfi_readeia608_X_cc = this.lavfi_readeia608_X_cc; 38 | Readeia608Filter.prototype.withLavfi_readeia608_X_line = this.lavfi_readeia608_X_line; 39 | } 40 | 41 | /** 42 | * The two bytes stored as EIA-608 data (printed in hexadecimal). 43 | * 44 | * 45 | * @param val 46 | */ 47 | lavfi_readeia608_X_cc(val) { 48 | this._lavfi_readeia608_X_cc = val; 49 | return this; 50 | } 51 | 52 | /** 53 | * The number of the line on which the EIA-608 data was identified and read. 54 | * 55 | * @param val 56 | */ 57 | lavfi_readeia608_X_line(val) { 58 | this._lavfi_readeia608_X_line = val; 59 | return this; 60 | } 61 | 62 | 63 | /** 64 | * Creates this filter configuration and registers it in the ffmpeg instance. 65 | * @return {ffmpegCommand} The ffmpeg instance. 66 | */ 67 | build() { 68 | let opt = {}; 69 | if (this._lavfi_readeia608_X_cc) { 70 | opt['lavfi.readeia608.X.cc'] = this._lavfi_readeia608_X_cc; 71 | } 72 | if (this._lavfi_readeia608_X_line) { 73 | opt['lavfi.readeia608.X.line'] = this._lavfi_readeia608_X_line; 74 | } 75 | 76 | addFilter(this.ffmpeg, { 77 | filter: 'readeia608', 78 | options: opt 79 | }); 80 | return this.ffmpeg; 81 | } 82 | } 83 | 84 | module.exports.readeia608 = readeia608; 85 | -------------------------------------------------------------------------------- /lib/uspp.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the uspp function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().uspp() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the uspp function. 17 | */ 18 | function uspp(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'uspp', function() { 20 | return new UsppFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class UsppFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | UsppFilter.prototype.withQuality = this.quality; 38 | UsppFilter.prototype.withQp = this.qp; 39 | } 40 | 41 | /** 42 | * Set quality. This option defines the number of levels for averaging. It accepts 43 | * an integer in the range 0-8. If set to 0, the filter will have no 44 | * effect. A value of 8 means the higher quality. For each increment of 45 | * that value the speed drops by a factor of approximately 2. Default value is 46 | * 3. 47 | * 48 | * 49 | * @param val 50 | */ 51 | quality(val) { 52 | this._quality = val; 53 | return this; 54 | } 55 | 56 | /** 57 | * Force a constant quantization parameter. If not set, the filter will use the QP 58 | * from the video stream (if available). 59 | * 60 | * @param val 61 | */ 62 | qp(val) { 63 | this._qp = val; 64 | return this; 65 | } 66 | 67 | 68 | /** 69 | * Creates this filter configuration and registers it in the ffmpeg instance. 70 | * @return {ffmpegCommand} The ffmpeg instance. 71 | */ 72 | build() { 73 | let opt = {}; 74 | if (this._quality) { 75 | opt['quality'] = this._quality; 76 | } 77 | if (this._qp) { 78 | opt['qp'] = this._qp; 79 | } 80 | 81 | addFilter(this.ffmpeg, { 82 | filter: 'uspp', 83 | options: opt 84 | }); 85 | return this.ffmpeg; 86 | } 87 | } 88 | 89 | module.exports.uspp = uspp; 90 | -------------------------------------------------------------------------------- /lib/loop.js: -------------------------------------------------------------------------------- 1 | const addFilter = require('./utils').addFilter; 2 | const registerFilter = require('./utils').registerFilter; 3 | 4 | /** 5 | * Augment FfmpegCommand with the loop function. 6 | * 7 | * 8 | * @example 9 | * ffmpeg().loop() 10 | * ... // call filter configuration functions 11 | * .build() // end filter configuration 12 | * ... 13 | * .applyFilters() // called once all filters have been configured 14 | * 15 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 16 | * @return {FfmpegCommand} The ffmpegCommand augmented with the loop function. 17 | */ 18 | function loop(ffmpegCommand) { 19 | registerFilter(ffmpegCommand, 'loop', function() { 20 | return new LoopFilter(this); 21 | }); 22 | return ffmpegCommand; 23 | } 24 | 25 | /** 26 | * Class exposing methods to configure the vstack filter in a builder pattern way. 27 | * 28 | * See {@link http://ffmpeg.org/ffmpeg-filters.html#vstack} for a description 29 | * of each configuration option. 30 | */ 31 | class LoopFilter { 32 | /** 33 | * @param {FfmpegCommand} ffmpegCommand The fluent-ffmpeg constructor. 34 | */ 35 | constructor (ffmpeg) { 36 | this.ffmpeg = ffmpeg; 37 | LoopFilter.prototype.withLoop = this.loop; 38 | LoopFilter.prototype.withSize = this.size; 39 | LoopFilter.prototype.withStart = this.start; 40 | } 41 | 42 | /** 43 | * Set the number of loops. 44 | * 45 | * 46 | * @param val 47 | */ 48 | loop(val) { 49 | this._loop = val; 50 | return this; 51 | } 52 | 53 | /** 54 | * Set maximal size in number of frames. 55 | * 56 | * 57 | * @param val 58 | */ 59 | size(val) { 60 | this._size = val; 61 | return this; 62 | } 63 | 64 | /** 65 | * Set first frame of loop. 66 | * 67 | * @param val 68 | */ 69 | start(val) { 70 | this._start = val; 71 | return this; 72 | } 73 | 74 | 75 | /** 76 | * Creates this filter configuration and registers it in the ffmpeg instance. 77 | * @return {ffmpegCommand} The ffmpeg instance. 78 | */ 79 | build() { 80 | let opt = {}; 81 | if (this._loop) { 82 | opt['loop'] = this._loop; 83 | } 84 | if (this._size) { 85 | opt['size'] = this._size; 86 | } 87 | if (this._start) { 88 | opt['start'] = this._start; 89 | } 90 | 91 | addFilter(this.ffmpeg, { 92 | filter: 'loop', 93 | options: opt 94 | }); 95 | return this.ffmpeg; 96 | } 97 | } 98 | 99 | module.exports.loop = loop; 100 | --------------------------------------------------------------------------------