custom.js.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: options/custom.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: options/custom.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>/*jshint node:true*/
  20. 'use strict';
  21. var utils = require('../utils');
  22. /*
  23. *! Custom options methods
  24. */
  25. module.exports = function(proto) {
  26. /**
  27. * Add custom input option(s)
  28. *
  29. * When passing a single string or an array, each string containing two
  30. * words is split (eg. inputOptions('-option value') is supported) for
  31. * compatibility reasons. This is not the case when passing more than
  32. * one argument.
  33. *
  34. * @example
  35. * command.inputOptions('option1');
  36. *
  37. * @example
  38. * command.inputOptions('option1', 'option2');
  39. *
  40. * @example
  41. * command.inputOptions(['option1', 'option2']);
  42. *
  43. * @method FfmpegCommand#inputOptions
  44. * @category Custom options
  45. * @aliases addInputOption,addInputOptions,withInputOption,withInputOptions,inputOption
  46. *
  47. * @param {...String} options option string(s) or string array
  48. * @return FfmpegCommand
  49. */
  50. proto.addInputOption =
  51. proto.addInputOptions =
  52. proto.withInputOption =
  53. proto.withInputOptions =
  54. proto.inputOption =
  55. proto.inputOptions = function(options) {
  56. if (!this._currentInput) {
  57. throw new Error('No input specified');
  58. }
  59. var doSplit = true;
  60. if (arguments.length > 1) {
  61. options = [].slice.call(arguments);
  62. doSplit = false;
  63. }
  64. if (!Array.isArray(options)) {
  65. options = [options];
  66. }
  67. this._currentInput.options(options.reduce(function(options, option) {
  68. var split = option.split(' ');
  69. if (doSplit &amp;&amp; split.length === 2) {
  70. options.push(split[0], split[1]);
  71. } else {
  72. options.push(option);
  73. }
  74. return options;
  75. }, []));
  76. return this;
  77. };
  78. /**
  79. * Add custom output option(s)
  80. *
  81. * @example
  82. * command.outputOptions('option1');
  83. *
  84. * @example
  85. * command.outputOptions('option1', 'option2');
  86. *
  87. * @example
  88. * command.outputOptions(['option1', 'option2']);
  89. *
  90. * @method FfmpegCommand#outputOptions
  91. * @category Custom options
  92. * @aliases addOutputOption,addOutputOptions,addOption,addOptions,withOutputOption,withOutputOptions,withOption,withOptions,outputOption
  93. *
  94. * @param {...String} options option string(s) or string array
  95. * @return FfmpegCommand
  96. */
  97. proto.addOutputOption =
  98. proto.addOutputOptions =
  99. proto.addOption =
  100. proto.addOptions =
  101. proto.withOutputOption =
  102. proto.withOutputOptions =
  103. proto.withOption =
  104. proto.withOptions =
  105. proto.outputOption =
  106. proto.outputOptions = function(options) {
  107. var doSplit = true;
  108. if (arguments.length > 1) {
  109. options = [].slice.call(arguments);
  110. doSplit = false;
  111. }
  112. if (!Array.isArray(options)) {
  113. options = [options];
  114. }
  115. this._currentOutput.options(options.reduce(function(options, option) {
  116. var split = option.split(' ');
  117. if (doSplit &amp;&amp; split.length === 2) {
  118. options.push(split[0], split[1]);
  119. } else {
  120. options.push(option);
  121. }
  122. return options;
  123. }, []));
  124. return this;
  125. };
  126. /**
  127. * Specify a complex filtergraph
  128. *
  129. * Calling this method will override any previously set filtergraph, but you can set
  130. * as many filters as needed in one call.
  131. *
  132. * @example &lt;caption>Overlay an image over a video (using a filtergraph string)&lt;/caption>
  133. * ffmpeg()
  134. * .input('video.avi')
  135. * .input('image.png')
  136. * .complexFilter('[0:v][1:v]overlay[out]', ['out']);
  137. *
  138. * @example &lt;caption>Overlay an image over a video (using a filter array)&lt;/caption>
  139. * ffmpeg()
  140. * .input('video.avi')
  141. * .input('image.png')
  142. * .complexFilter([{
  143. * filter: 'overlay',
  144. * inputs: ['0:v', '1:v'],
  145. * outputs: ['out']
  146. * }], ['out']);
  147. *
  148. * @example &lt;caption>Split video into RGB channels and output a 3x1 video with channels side to side&lt;/caption>
  149. * ffmpeg()
  150. * .input('video.avi')
  151. * .complexFilter([
  152. * // Duplicate video stream 3 times into streams a, b, and c
  153. * { filter: 'split', options: '3', outputs: ['a', 'b', 'c'] },
  154. *
  155. * // Create stream 'red' by cancelling green and blue channels from stream 'a'
  156. * { filter: 'lutrgb', options: { g: 0, b: 0 }, inputs: 'a', outputs: 'red' },
  157. *
  158. * // Create stream 'green' by cancelling red and blue channels from stream 'b'
  159. * { filter: 'lutrgb', options: { r: 0, b: 0 }, inputs: 'b', outputs: 'green' },
  160. *
  161. * // Create stream 'blue' by cancelling red and green channels from stream 'c'
  162. * { filter: 'lutrgb', options: { r: 0, g: 0 }, inputs: 'c', outputs: 'blue' },
  163. *
  164. * // Pad stream 'red' to 3x width, keeping the video on the left, and name output 'padded'
  165. * { filter: 'pad', options: { w: 'iw*3', h: 'ih' }, inputs: 'red', outputs: 'padded' },
  166. *
  167. * // Overlay 'green' onto 'padded', moving it to the center, and name output 'redgreen'
  168. * { filter: 'overlay', options: { x: 'w', y: 0 }, inputs: ['padded', 'green'], outputs: 'redgreen'},
  169. *
  170. * // Overlay 'blue' onto 'redgreen', moving it to the right
  171. * { filter: 'overlay', options: { x: '2*w', y: 0 }, inputs: ['redgreen', 'blue']},
  172. * ]);
  173. *
  174. * @method FfmpegCommand#complexFilter
  175. * @category Custom options
  176. * @aliases filterGraph
  177. *
  178. * @param {String|Array} spec filtergraph string or array of filter specification
  179. * objects, each having the following properties:
  180. * @param {String} spec.filter filter name
  181. * @param {String|Array} [spec.inputs] (array of) input stream specifier(s) for the filter,
  182. * defaults to ffmpeg automatically choosing the first unused matching streams
  183. * @param {String|Array} [spec.outputs] (array of) output stream specifier(s) for the filter,
  184. * defaults to ffmpeg automatically assigning the output to the output file
  185. * @param {Object|String|Array} [spec.options] filter options, can be omitted to not set any options
  186. * @param {Array} [map] (array of) stream specifier(s) from the graph to include in
  187. * ffmpeg output, defaults to ffmpeg automatically choosing the first matching streams.
  188. * @return FfmpegCommand
  189. */
  190. proto.filterGraph =
  191. proto.complexFilter = function(spec, map) {
  192. this._complexFilters.clear();
  193. if (!Array.isArray(spec)) {
  194. spec = [spec];
  195. }
  196. this._complexFilters('-filter_complex', utils.makeFilterStrings(spec).join(';'));
  197. if (Array.isArray(map)) {
  198. var self = this;
  199. map.forEach(function(streamSpec) {
  200. self._complexFilters('-map', streamSpec.replace(utils.streamRegexp, '[$1]'));
  201. });
  202. } else if (typeof map === 'string') {
  203. this._complexFilters('-map', map.replace(utils.streamRegexp, '[$1]'));
  204. }
  205. return this;
  206. };
  207. };
  208. </code></pre>
  209. </article>
  210. </section>
  211. </div>
  212. <nav>
  213. <h2><a href="index.html">Index</a></h2><ul><li><a href="index.html#installation">Installation</a></li><ul></ul><li><a href="index.html#usage">Usage</a></li><ul><li><a href="index.html#prerequisites">Prerequisites</a></li><li><a href="index.html#creating-an-ffmpeg-command">Creating an FFmpeg command</a></li><li><a href="index.html#specifying-inputs">Specifying inputs</a></li><li><a href="index.html#input-options">Input options</a></li><li><a href="index.html#audio-options">Audio options</a></li><li><a href="index.html#video-options">Video options</a></li><li><a href="index.html#video-frame-size-options">Video frame size options</a></li><li><a href="index.html#specifying-multiple-outputs">Specifying multiple outputs</a></li><li><a href="index.html#output-options">Output options</a></li><li><a href="index.html#miscellaneous-options">Miscellaneous options</a></li><li><a href="index.html#setting-event-handlers">Setting event handlers</a></li><li><a href="index.html#starting-ffmpeg-processing">Starting FFmpeg processing</a></li><li><a href="index.html#controlling-the-ffmpeg-process">Controlling the FFmpeg process</a></li><li><a href="index.html#reading-video-metadata">Reading video metadata</a></li><li><a href="index.html#querying-ffmpeg-capabilities">Querying ffmpeg capabilities</a></li><li><a href="index.html#cloning-an-ffmpegcommand">Cloning an FfmpegCommand</a></li></ul><li><a href="index.html#contributing">Contributing</a></li><ul><li><a href="index.html#code-contributions">Code contributions</a></li><li><a href="index.html#documentation-contributions">Documentation contributions</a></li><li><a href="index.html#updating-the-documentation">Updating the documentation</a></li><li><a href="index.html#running-tests">Running tests</a></li></ul><li><a href="index.html#main-contributors">Main contributors</a></li><ul></ul><li><a href="index.html#license">License</a></li><ul></ul></ul><h3>Classes</h3><ul><li><a href="FfmpegCommand.html">FfmpegCommand</a></li><ul><li> <a href="FfmpegCommand.html#audio-methods">Audio methods</a></li><li> <a href="FfmpegCommand.html#capabilities-methods">Capabilities methods</a></li><li> <a href="FfmpegCommand.html#custom-options-methods">Custom options methods</a></li><li> <a href="FfmpegCommand.html#input-methods">Input methods</a></li><li> <a href="FfmpegCommand.html#metadata-methods">Metadata methods</a></li><li> <a href="FfmpegCommand.html#miscellaneous-methods">Miscellaneous methods</a></li><li> <a href="FfmpegCommand.html#other-methods">Other methods</a></li><li> <a href="FfmpegCommand.html#output-methods">Output methods</a></li><li> <a href="FfmpegCommand.html#processing-methods">Processing methods</a></li><li> <a href="FfmpegCommand.html#video-methods">Video methods</a></li><li> <a href="FfmpegCommand.html#video-size-methods">Video size methods</a></li></ul></ul>
  214. </nav>
  215. <br clear="both">
  216. <footer>
  217. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Tue Jul 08 2014 21:22:19 GMT+0200 (CEST)
  218. </footer>
  219. <script> prettyPrint(); </script>
  220. <script src="scripts/linenumber.js"> </script>
  221. </body>
  222. </html>