123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- 'use strict';
- var utils = require('../utils');
- module.exports = function(proto) {
-
- proto.mergeAdd =
- proto.addInput =
- proto.input = function(source) {
- var isFile = false;
- var isStream = false;
- if (typeof source !== 'string') {
- if (!('readable' in source) || !(source.readable)) {
- throw new Error('Invalid input');
- }
- var hasInputStream = this._inputs.some(function(input) {
- return input.isStream;
- });
- if (hasInputStream) {
- throw new Error('Only one input stream is supported');
- }
- isStream = true;
- source.pause();
- } else {
- var protocol = source.match(/^([a-z]{2,}):/i);
- isFile = !protocol || protocol[0] === 'file';
- }
- this._inputs.push(this._currentInput = {
- source: source,
- isFile: isFile,
- isStream: isStream,
- options: utils.args()
- });
- return this;
- };
-
- proto.withInputFormat =
- proto.inputFormat =
- proto.fromFormat = function(format) {
- if (!this._currentInput) {
- throw new Error('No input specified');
- }
- this._currentInput.options('-f', format);
- return this;
- };
-
- proto.withInputFps =
- proto.withInputFPS =
- proto.withFpsInput =
- proto.withFPSInput =
- proto.inputFPS =
- proto.inputFps =
- proto.fpsInput =
- proto.FPSInput = function(fps) {
- if (!this._currentInput) {
- throw new Error('No input specified');
- }
- this._currentInput.options('-r', fps);
- return this;
- };
-
- proto.nativeFramerate =
- proto.withNativeFramerate =
- proto.native = function() {
- if (!this._currentInput) {
- throw new Error('No input specified');
- }
- this._currentInput.options('-re');
- return this;
- };
-
- proto.setStartTime =
- proto.seekInput = function(seek) {
- if (!this._currentInput) {
- throw new Error('No input specified');
- }
- this._currentInput.options('-ss', seek);
- return this;
- };
-
- proto.loop = function(duration) {
- if (!this._currentInput) {
- throw new Error('No input specified');
- }
- this._currentInput.options('-loop', '1');
- if (typeof duration !== 'undefined') {
- this.duration(duration);
- }
- return this;
- };
- };
|