lib/utils.js
function(filters) {
    return filters.map(function(filterSpec) {
      if (typeof filterSpec === 'string') {
        return filterSpec;
      }

      var filterString = '';

      // Filter string format is:
      // [input1][input2]...filter[output1][output2]...
      // The 'filter' part can optionaly have arguments:
      //   filter=arg1:arg2:arg3
      //   filter=arg1=v1:arg2=v2:arg3=v3

      // Add inputs
      if (Array.isArray(filterSpec.inputs)) {
        filterString += filterSpec.inputs.map(function(streamSpec) {
          return streamSpec.replace(streamRegexp, '[$1]');
        }).join('');
      } else if (typeof filterSpec.inputs === 'string') {
        filterString += filterSpec.inputs.replace(streamRegexp, '[$1]');
      }

      // Add filter
      filterString += filterSpec.filter;

      // Add options
      if (filterSpec.options) {
        if (typeof filterSpec.options === 'string' || typeof filterSpec.options === 'number') {
          // Option string
          filterString += '=' + filterSpec.options;
        } else if (Array.isArray(filterSpec.options)) {
          // Option array (unnamed options)
          filterString += '=' + filterSpec.options.map(function(option) {
            if (typeof option === 'string' && option.match(filterEscapeRegexp)) {
              return '\'' + option + '\'';
            } else {
              return option;
            }
          }).join(':');
        } else if (Object.keys(filterSpec.options).length) {
          // Option object (named options)
          filterString += '=' + Object.keys(filterSpec.options).map(function(option) {
            var value = filterSpec.options[option];

            if (typeof value === 'string' && value.match(filterEscapeRegexp)) {
              value = '\'' + value + '\'';
            }

            return option + '=' + value;
          }).join(':');
        }
      }

      // Add outputs
      if (Array.isArray(filterSpec.outputs)) {
        filterString += filterSpec.outputs.map(function(streamSpec) {
          return streamSpec.replace(streamRegexp, '[$1]');
        }).join('');
      } else if (typeof filterSpec.outputs === 'string') {
        filterString += filterSpec.outputs.replace(streamRegexp, '[$1]');
      }

      return filterString;
    });
  }
function(filters) {
    return filters.map(function(filterSpec) {
      if (typeof filterSpec === 'string') {
        return filterSpec;
      }

      var filterString = '';

      // Filter string format is:
      // [input1][input2]...filter[output1][output2]...
      // The 'filter' part can optionaly have arguments:
      //   filter=arg1:arg2:arg3
      //   filter=arg1=v1:arg2=v2:arg3=v3

      // Add inputs
      if (Array.isArray(filterSpec.inputs)) {
        filterString += filterSpec.inputs.map(function(streamSpec) {
          return streamSpec.replace(streamRegexp, '[$1]');
        }).join('');
      } else if (typeof filterSpec.inputs === 'string') {
        filterString += filterSpec.inputs.replace(streamRegexp, '[$1]');
      }

      // Add filter
      filterString += filterSpec.filter;

      // Add options
      if (filterSpec.options) {
        if (typeof filterSpec.options === 'string' || typeof filterSpec.options === 'number') {
          // Option string
          filterString += '=' + filterSpec.options;
        } else if (Array.isArray(filterSpec.options)) {
          // Option array (unnamed options)
          filterString += '=' + filterSpec.options.map(function(option) {
            if (typeof option === 'string' && option.match(filterEscapeRegexp)) {
              return '\'' + option + '\'';
            } else {
              return option;
            }
          }).join(':');
        } else if (Object.keys(filterSpec.options).length) {
          // Option object (named options)
          filterString += '=' + Object.keys(filterSpec.options).map(function(option) {
            var value = filterSpec.options[option];

            if (typeof value === 'string' && value.match(filterEscapeRegexp)) {
              value = '\'' + value + '\'';
            }

            return option + '=' + value;
          }).join(':');
        }
      }

      // Add outputs
      if (Array.isArray(filterSpec.outputs)) {
        filterString += filterSpec.outputs.map(function(streamSpec) {
          return streamSpec.replace(streamRegexp, '[$1]');
        }).join('');
      } else if (typeof filterSpec.outputs === 'string') {
        filterString += filterSpec.outputs.replace(streamRegexp, '[$1]');
      }

      return filterString;
    });
  }
function ( filters ) { return filters . map ( function ( filterSpec ) { if ( typeof filterSpec === 'string' ) { return filterSpec ; } var filterString = '' ; // Filter string format is: // [input1][input2]...filter[output1][output2]... // The 'filter' part can optionaly have arguments: //   filter=arg1:arg2:arg3 //   filter=arg1=v1:arg2=v2:arg3=v3 // Add inputs if ( Array . isArray ( filterSpec . inputs ) ) { filterString += filterSpec . inputs . map ( function ( streamSpec ) { return streamSpec . replace ( streamRegexp , '[$1]' ) ; } ) . join ( '' ) ; } else if ( typeof filterSpec . inputs === 'string' ) { filterString += filterSpec . inputs . replace ( streamRegexp , '[$1]' ) ; } // Add filter filterString += filterSpec . filter ; // Add options if ( filterSpec . options ) { if ( typeof filterSpec . options === 'string' || typeof filterSpec . options === 'number' ) { // Option string filterString += '=' + filterSpec . options ; } else if ( Array . isArray ( filterSpec . options ) ) { // Option array (unnamed options) filterString += '=' + filterSpec . options . map ( function ( option ) { if ( typeof option === 'string' && option . match ( filterEscapeRegexp ) ) { return '\'' + option + '\'' ; } else { return option ; } } ) . join ( ':' ) ; } else if ( Object . keys ( filterSpec . options ) . length ) { // Option object (named options) filterString += '=' + Object . keys ( filterSpec . options ) . map ( function ( option ) { var value = filterSpec . options [ option ] ; if ( typeof value === 'string' && value . match ( filterEscapeRegexp ) ) { value = '\'' + value + '\'' ; } return option + '=' + value ; } ) . join ( ':' ) ; } } // Add outputs if ( Array . isArray ( filterSpec . outputs ) ) { filterString += filterSpec . outputs . map ( function ( streamSpec ) { return streamSpec . replace ( streamRegexp , '[$1]' ) ; } ) . join ( '' ) ; } else if ( typeof filterSpec . outputs === 'string' ) { filterString += filterSpec . outputs . replace ( streamRegexp , '[$1]' ) ; } return filterString ; } ) ; }
Generate filter strings

@param {String[]|Object[]} filters filter specifications. When using objects,
each must have the following properties:
@param {String} filters.filter filter name
@param {String|Array} [filters.inputs] (array of) input stream specifier(s) for the filter,
defaults to ffmpeg automatically choosing the first unused matching streams
@param {String|Array} [filters.outputs] (array of) output stream specifier(s) for the filter,
defaults to ffmpeg automatically assigning the output to the output file
@param {Object|String|Array} [filters.options] filter options, can be omitted to not set any options
@return String[]
@private
Generate filter strings