options_inputs.js.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: options/inputs.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/inputs.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. *! Input-related methods
  24. */
  25. module.exports = function(proto) {
  26. /**
  27. * Add an input to command
  28. *
  29. * Also switches "current input", that is the input that will be affected
  30. * by subsequent input-related methods.
  31. *
  32. * Note: only one stream input is supported for now.
  33. *
  34. * @method FfmpegCommand#input
  35. * @category Input
  36. * @aliases mergeAdd,addInput
  37. *
  38. * @param {String|Readable} source input file path or readable stream
  39. * @return FfmpegCommand
  40. */
  41. proto.mergeAdd =
  42. proto.addInput =
  43. proto.input = function(source) {
  44. var isFile = false;
  45. var isStream = false;
  46. if (typeof source !== 'string') {
  47. if (!('readable' in source) || !(source.readable)) {
  48. throw new Error('Invalid input');
  49. }
  50. var hasInputStream = this._inputs.some(function(input) {
  51. return input.isStream;
  52. });
  53. if (hasInputStream) {
  54. throw new Error('Only one input stream is supported');
  55. }
  56. isStream = true;
  57. source.pause();
  58. } else {
  59. var protocol = source.match(/^([a-z]{2,}):/i);
  60. isFile = !protocol || protocol[0] === 'file';
  61. }
  62. this._inputs.push(this._currentInput = {
  63. source: source,
  64. isFile: isFile,
  65. isStream: isStream,
  66. options: utils.args()
  67. });
  68. return this;
  69. };
  70. /**
  71. * Specify input format for the last specified input
  72. *
  73. * @method FfmpegCommand#inputFormat
  74. * @category Input
  75. * @aliases withInputFormat,fromFormat
  76. *
  77. * @param {String} format input format
  78. * @return FfmpegCommand
  79. */
  80. proto.withInputFormat =
  81. proto.inputFormat =
  82. proto.fromFormat = function(format) {
  83. if (!this._currentInput) {
  84. throw new Error('No input specified');
  85. }
  86. this._currentInput.options('-f', format);
  87. return this;
  88. };
  89. /**
  90. * Specify input FPS for the last specified input
  91. * (only valid for raw video formats)
  92. *
  93. * @method FfmpegCommand#inputFps
  94. * @category Input
  95. * @aliases withInputFps,withInputFPS,withFpsInput,withFPSInput,inputFPS,inputFps,fpsInput
  96. *
  97. * @param {Number} fps input FPS
  98. * @return FfmpegCommand
  99. */
  100. proto.withInputFps =
  101. proto.withInputFPS =
  102. proto.withFpsInput =
  103. proto.withFPSInput =
  104. proto.inputFPS =
  105. proto.inputFps =
  106. proto.fpsInput =
  107. proto.FPSInput = function(fps) {
  108. if (!this._currentInput) {
  109. throw new Error('No input specified');
  110. }
  111. this._currentInput.options('-r', fps);
  112. return this;
  113. };
  114. /**
  115. * Use native framerate for the last specified input
  116. *
  117. * @method FfmpegCommand#native
  118. * @category Input
  119. * @aliases nativeFramerate,withNativeFramerate
  120. *
  121. * @return FfmmegCommand
  122. */
  123. proto.nativeFramerate =
  124. proto.withNativeFramerate =
  125. proto.native = function() {
  126. if (!this._currentInput) {
  127. throw new Error('No input specified');
  128. }
  129. this._currentInput.options('-re');
  130. return this;
  131. };
  132. /**
  133. * Specify input seek time for the last specified input
  134. *
  135. * @method FfmpegCommand#seekInput
  136. * @category Input
  137. * @aliases setStartTime,seekTo
  138. *
  139. * @param {String|Number} seek seek time in seconds or as a '[hh:[mm:]]ss[.xxx]' string
  140. * @return FfmpegCommand
  141. */
  142. proto.setStartTime =
  143. proto.seekInput = function(seek) {
  144. if (!this._currentInput) {
  145. throw new Error('No input specified');
  146. }
  147. this._currentInput.options('-ss', seek);
  148. return this;
  149. };
  150. /**
  151. * Loop over the last specified input
  152. *
  153. * @method FfmpegCommand#loop
  154. * @category Input
  155. *
  156. * @param {String|Number} [duration] loop duration in seconds or as a '[[hh:]mm:]ss[.xxx]' string
  157. * @return FfmpegCommand
  158. */
  159. proto.loop = function(duration) {
  160. if (!this._currentInput) {
  161. throw new Error('No input specified');
  162. }
  163. this._currentInput.options('-loop', '1');
  164. if (typeof duration !== 'undefined') {
  165. this.duration(duration);
  166. }
  167. return this;
  168. };
  169. };
  170. </code></pre>
  171. </article>
  172. </section>
  173. </div>
  174. <nav>
  175. <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>
  176. </nav>
  177. <br clear="both">
  178. <footer>
  179. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Sun May 01 2016 12:10:37 GMT+0200 (CEST)
  180. </footer>
  181. <script> prettyPrint(); </script>
  182. <script src="scripts/linenumber.js"> </script>
  183. </body>
  184. </html>