// instrument by jscoverage, do not modifly this file
(function () {
  var BASE;
  if (typeof global === 'object') {
    BASE = global;
  } else if (typeof window === 'object') {
    BASE = window;
  } else {
    throw new Error('[jscoverage] unknow ENV!');
  }
  if (!BASE._$jscoverage) {
    BASE._$jscoverage = {};
    BASE._$jscoverage_cond = {};
    BASE._$jscoverage_done = function (file, line, express) {
      if (arguments.length === 2) {
        BASE._$jscoverage[file][line] ++;
      } else {
        BASE._$jscoverage_cond[file][line] ++;
        return express;
      }
    };
    BASE._$jscoverage_init = function (base, file, lines) {
      var tmp = [];
      for (var i = 0; i < lines.length; i ++) {
        tmp[lines[i]] = 0;
      }
      base[file] = tmp;
    };
  }
})();
_$jscoverage_init(_$jscoverage, "lib/options/custom.js",[4,11,36,42,43,46,48,49,50,53,54,57,58,60,61,63,66,68,91,101,103,104,105,108,109,112,113,115,116,118,121,123,191,193,195,196,199,201,202,203,204,206,207,210]);
_$jscoverage_init(_$jscoverage_cond, "lib/options/custom.js",[42,48,53,60,60,103,108,115,115,195,201,206]);
_$jscoverage["lib/options/custom.js"].source = ["/*jshint node:true*/","'use strict';","","var utils = require('../utils');","","","/*"," *! Custom options methods"," */","","module.exports = function(proto) {","  /**","   * Add custom input option(s)","   *","   * When passing a single string or an array, each string containing two","   * words is split (eg. inputOptions('-option value') is supported) for","   * compatibility reasons.  This is not the case when passing more than","   * one argument.","   *","   * @example","   * command.inputOptions('option1');","   *","   * @example","   * command.inputOptions('option1', 'option2');","   *","   * @example","   * command.inputOptions(['option1', 'option2']);","   *","   * @method FfmpegCommand#inputOptions","   * @category Custom options","   * @aliases addInputOption,addInputOptions,withInputOption,withInputOptions,inputOption","   *","   * @param {...String} options option string(s) or string array","   * @return FfmpegCommand","   */","  proto.addInputOption =","  proto.addInputOptions =","  proto.withInputOption =","  proto.withInputOptions =","  proto.inputOption =","  proto.inputOptions = function(options) {","    if (!this._currentInput) {","      throw new Error('No input specified');","    }","","    var doSplit = true;","","    if (arguments.length > 1) {","      options = [].slice.call(arguments);","      doSplit = false;","    }","","    if (!Array.isArray(options)) {","      options = [options];","    }","","    this._currentInput.options(options.reduce(function(options, option) {","      var split = option.split(' ');","","      if (doSplit && split.length === 2) {","        options.push(split[0], split[1]);","      } else {","        options.push(option);","      }","","      return options;","    }, []));","    return this;","  };","","","  /**","   * Add custom output option(s)","   *","   * @example","   * command.outputOptions('option1');","   *","   * @example","   * command.outputOptions('option1', 'option2');","   *","   * @example","   * command.outputOptions(['option1', 'option2']);","   *","   * @method FfmpegCommand#outputOptions","   * @category Custom options","   * @aliases addOutputOption,addOutputOptions,addOption,addOptions,withOutputOption,withOutputOptions,withOption,withOptions,outputOption","   *","   * @param {...String} options option string(s) or string array","   * @return FfmpegCommand","   */","  proto.addOutputOption =","  proto.addOutputOptions =","  proto.addOption =","  proto.addOptions =","  proto.withOutputOption =","  proto.withOutputOptions =","  proto.withOption =","  proto.withOptions =","  proto.outputOption =","  proto.outputOptions = function(options) {","    var doSplit = true;","","    if (arguments.length > 1) {","      options = [].slice.call(arguments);","      doSplit = false;","    }","","    if (!Array.isArray(options)) {","      options = [options];","    }","","    this._currentOutput.options(options.reduce(function(options, option) {","      var split = option.split(' ');","","      if (doSplit && split.length === 2) {","        options.push(split[0], split[1]);","      } else {","        options.push(option);","      }","","      return options;","    }, []));","    return this;","  };","","","  /**","   * Specify a complex filtergraph","   *","   * Calling this method will override any previously set filtergraph, but you can set","   * as many filters as needed in one call.","   *","   * @example <caption>Overlay an image over a video (using a filtergraph string)</caption>","   *   ffmpeg()","   *     .input('video.avi')","   *     .input('image.png')","   *     .complexFilter('[0:v][1:v]overlay[out]', ['out']);","   *","   * @example <caption>Overlay an image over a video (using a filter array)</caption>","   *   ffmpeg()","   *     .input('video.avi')","   *     .input('image.png')","   *     .complexFilter([{","   *       filter: 'overlay',","   *       inputs: ['0:v', '1:v'],","   *       outputs: ['out']","   *     }], ['out']);","   *","   * @example <caption>Split video into RGB channels and output a 3x1 video with channels side to side</caption>","   *  ffmpeg()","   *    .input('video.avi')","   *    .complexFilter([","   *      // Duplicate video stream 3 times into streams a, b, and c","   *      { filter: 'split', options: '3', outputs: ['a', 'b', 'c'] },","   *","   *      // Create stream 'red' by cancelling green and blue channels from stream 'a'","   *      { filter: 'lutrgb', options: { g: 0, b: 0 }, inputs: 'a', outputs: 'red' },","   *","   *      // Create stream 'green' by cancelling red and blue channels from stream 'b'","   *      { filter: 'lutrgb', options: { r: 0, b: 0 }, inputs: 'b', outputs: 'green' },","   *","   *      // Create stream 'blue' by cancelling red and green channels from stream 'c'","   *      { filter: 'lutrgb', options: { r: 0, g: 0 }, inputs: 'c', outputs: 'blue' },","   *","   *      // Pad stream 'red' to 3x width, keeping the video on the left, and name output 'padded'","   *      { filter: 'pad', options: { w: 'iw*3', h: 'ih' }, inputs: 'red', outputs: 'padded' },","   *","   *      // Overlay 'green' onto 'padded', moving it to the center, and name output 'redgreen'","   *      { filter: 'overlay', options: { x: 'w', y: 0 }, inputs: ['padded', 'green'], outputs: 'redgreen'},","   *","   *      // Overlay 'blue' onto 'redgreen', moving it to the right","   *      { filter: 'overlay', options: { x: '2*w', y: 0 }, inputs: ['redgreen', 'blue']},","   *    ]);","   *","   * @method FfmpegCommand#complexFilter","   * @category Custom options","   * @aliases filterGraph","   *","   * @param {String|Array} spec filtergraph string or array of filter specification","   *   objects, each having the following properties:","   * @param {String} spec.filter filter name","   * @param {String|Array} [spec.inputs] (array of) input stream specifier(s) for the filter,","   *   defaults to ffmpeg automatically choosing the first unused matching streams","   * @param {String|Array} [spec.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} [spec.options] filter options, can be omitted to not set any options","   * @param {Array} [map] (array of) stream specifier(s) from the graph to include in","   *   ffmpeg output, defaults to ffmpeg automatically choosing the first matching streams.","   * @return FfmpegCommand","   */","  proto.filterGraph =","  proto.complexFilter = function(spec, map) {","    this._complexFilters.clear();","","    if (!Array.isArray(spec)) {","      spec = [spec];","    }","","    this._complexFilters('-filter_complex', utils.makeFilterStrings(spec).join(';'));","","    if (Array.isArray(map)) {","      var self = this;","      map.forEach(function(streamSpec) {","        self._complexFilters('-map', streamSpec.replace(utils.streamRegexp, '[$1]'));","      });","    } else if (typeof map === 'string') {","      this._complexFilters('-map', map.replace(utils.streamRegexp, '[$1]'));","    }","","    return this;","  };","};",""];
"use strict";

_$jscoverage_done("lib/options/custom.js", 4);
var utils = require("../utils");

_$jscoverage_done("lib/options/custom.js", 11);
module.exports = function(proto) {
    _$jscoverage_done("lib/options/custom.js", 36);
    proto.addInputOption = proto.addInputOptions = proto.withInputOption = proto.withInputOptions = proto.inputOption = proto.inputOptions = function(options) {
        _$jscoverage_done("lib/options/custom.js", 42);
        if (_$jscoverage_done("lib/options/custom.js", 42, !this._currentInput)) {
            _$jscoverage_done("lib/options/custom.js", 43);
            throw new Error("No input specified");
        }
        _$jscoverage_done("lib/options/custom.js", 46);
        var doSplit = true;
        _$jscoverage_done("lib/options/custom.js", 48);
        if (_$jscoverage_done("lib/options/custom.js", 48, arguments.length > 1)) {
            _$jscoverage_done("lib/options/custom.js", 49);
            options = [].slice.call(arguments);
            _$jscoverage_done("lib/options/custom.js", 50);
            doSplit = false;
        }
        _$jscoverage_done("lib/options/custom.js", 53);
        if (_$jscoverage_done("lib/options/custom.js", 53, !Array.isArray(options))) {
            _$jscoverage_done("lib/options/custom.js", 54);
            options = [ options ];
        }
        _$jscoverage_done("lib/options/custom.js", 57);
        this._currentInput.options(options.reduce(function(options, option) {
            _$jscoverage_done("lib/options/custom.js", 58);
            var split = option.split(" ");
            _$jscoverage_done("lib/options/custom.js", 60);
            if (_$jscoverage_done("lib/options/custom.js", 60, doSplit) && _$jscoverage_done("lib/options/custom.js", 60, split.length === 2)) {
                _$jscoverage_done("lib/options/custom.js", 61);
                options.push(split[0], split[1]);
            } else {
                _$jscoverage_done("lib/options/custom.js", 63);
                options.push(option);
            }
            _$jscoverage_done("lib/options/custom.js", 66);
            return options;
        }, []));
        _$jscoverage_done("lib/options/custom.js", 68);
        return this;
    };
    _$jscoverage_done("lib/options/custom.js", 91);
    proto.addOutputOption = proto.addOutputOptions = proto.addOption = proto.addOptions = proto.withOutputOption = proto.withOutputOptions = proto.withOption = proto.withOptions = proto.outputOption = proto.outputOptions = function(options) {
        _$jscoverage_done("lib/options/custom.js", 101);
        var doSplit = true;
        _$jscoverage_done("lib/options/custom.js", 103);
        if (_$jscoverage_done("lib/options/custom.js", 103, arguments.length > 1)) {
            _$jscoverage_done("lib/options/custom.js", 104);
            options = [].slice.call(arguments);
            _$jscoverage_done("lib/options/custom.js", 105);
            doSplit = false;
        }
        _$jscoverage_done("lib/options/custom.js", 108);
        if (_$jscoverage_done("lib/options/custom.js", 108, !Array.isArray(options))) {
            _$jscoverage_done("lib/options/custom.js", 109);
            options = [ options ];
        }
        _$jscoverage_done("lib/options/custom.js", 112);
        this._currentOutput.options(options.reduce(function(options, option) {
            _$jscoverage_done("lib/options/custom.js", 113);
            var split = option.split(" ");
            _$jscoverage_done("lib/options/custom.js", 115);
            if (_$jscoverage_done("lib/options/custom.js", 115, doSplit) && _$jscoverage_done("lib/options/custom.js", 115, split.length === 2)) {
                _$jscoverage_done("lib/options/custom.js", 116);
                options.push(split[0], split[1]);
            } else {
                _$jscoverage_done("lib/options/custom.js", 118);
                options.push(option);
            }
            _$jscoverage_done("lib/options/custom.js", 121);
            return options;
        }, []));
        _$jscoverage_done("lib/options/custom.js", 123);
        return this;
    };
    _$jscoverage_done("lib/options/custom.js", 191);
    proto.filterGraph = proto.complexFilter = function(spec, map) {
        _$jscoverage_done("lib/options/custom.js", 193);
        this._complexFilters.clear();
        _$jscoverage_done("lib/options/custom.js", 195);
        if (_$jscoverage_done("lib/options/custom.js", 195, !Array.isArray(spec))) {
            _$jscoverage_done("lib/options/custom.js", 196);
            spec = [ spec ];
        }
        _$jscoverage_done("lib/options/custom.js", 199);
        this._complexFilters("-filter_complex", utils.makeFilterStrings(spec).join(";"));
        _$jscoverage_done("lib/options/custom.js", 201);
        if (_$jscoverage_done("lib/options/custom.js", 201, Array.isArray(map))) {
            _$jscoverage_done("lib/options/custom.js", 202);
            var self = this;
            _$jscoverage_done("lib/options/custom.js", 203);
            map.forEach(function(streamSpec) {
                _$jscoverage_done("lib/options/custom.js", 204);
                self._complexFilters("-map", streamSpec.replace(utils.streamRegexp, "[$1]"));
            });
        } else {
            _$jscoverage_done("lib/options/custom.js", 206);
            if (_$jscoverage_done("lib/options/custom.js", 206, typeof map === "string")) {
                _$jscoverage_done("lib/options/custom.js", 207);
                this._complexFilters("-map", map.replace(utils.streamRegexp, "[$1]"));
            }
        }
        _$jscoverage_done("lib/options/custom.js", 210);
        return this;
    };
};