Skip to content

Commit ba91d86

Browse files
authored
Revert "Add terminateTimeout option (#8)"
This reverts commit 75f229f.
1 parent 75f229f commit ba91d86

File tree

3 files changed

+7
-51
lines changed

3 files changed

+7
-51
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ var command = ffmpeg('/path/to/file.avi', { option: "value", ... });
8888

8989
The following options are available:
9090
* `source`: input file name or readable stream (ignored if an input file is passed to the constructor)
91-
* `timeout`: ffmpeg process timeout in seconds (defaults to no timeout)
92-
* `terminateTimeout`: ffmpeg terminate timeout in milliseconds (defaults to 20 milliseconds)
91+
* `timeout`: ffmpeg timeout in seconds (defaults to no timeout)
9392
* `preset` or `presets`: directory to load module presets from (defaults to the `lib/presets` directory in fluent-ffmpeg tree)
9493
* `niceness` or `priority`: ffmpeg niceness value, between -20 and 20; ignored on Windows platforms (defaults to 0)
9594
* `logger`: logger object with `debug()`, `info()`, `warn()` and `error()` methods (defaults to no logging)

lib/processor.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,13 @@ module.exports = function(proto) {
483483
self.logger.debug('Output stream closed, scheduling kill for ffmpeg process');
484484

485485
// Don't kill process yet, to give a chance to ffmpeg to
486-
// terminate successfully first. This is necessary because
486+
// terminate successfully first This is necessary because
487487
// under load, the process 'exit' event sometimes happens
488488
// after the output stream 'close' event.
489-
const terminateTimeout = (self.options && self.options.terminateTimeout > 0) ? self.options.terminateTimeout : 20
490489
setTimeout(function() {
491-
emitEnd(new Error('Output stream closed, try increasing terminateTimeout option (' + terminateTimeout + ' ms)'));
490+
emitEnd(new Error('Output stream closed'));
492491
ffmpegProc.kill();
493-
}, terminateTimeout);
492+
}, 20);
494493
});
495494

496495
outputStream.target.on('error', function(err) {

test/processor.test.js

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ describe('Processor', function() {
232232
.on('end', function() {
233233
console.log('end was called, expected a timeout');
234234
assert.ok(false);
235+
done();
235236
})
236237
.saveToFile(testFile);
237238
});
@@ -278,51 +279,6 @@ describe('Processor', function() {
278279
.saveToFile(testFile);
279280
});
280281

281-
it('should kill the process on terminate timeout (terminateTimeout option)', function(done) {
282-
this.timeout(60000);
283-
284-
var testFile = path.join(__dirname, 'assets', 'testTerminateTimeout.avi');
285-
this.files.push(testFile);
286-
287-
const terminateTimeout = 1000 // set terminateTimeout to 1000 ms
288-
var command = this.getCommand({
289-
source: this.testfilebig,
290-
logger: testhelper.logger,
291-
terminateTimeout: terminateTimeout
292-
});
293-
294-
var startCalled = false;
295-
var outputStreamClosed = false;
296-
297-
// Mock output stream
298-
var outputStream = new stream.PassThrough();
299-
outputStream.close = function() {
300-
outputStreamClosed = true;
301-
this.emit('close');
302-
};
303-
304-
command
305-
.usingPreset('divx')
306-
.output(outputStream)
307-
.on('start', function() {
308-
startCalled = true;
309-
setTimeout(function() { outputStream.close(); }, 500); // close the output stream after 500ms (emit 'close' event on output stream before 'exit' event, to simulate a under load system)
310-
})
311-
.on('error', function(err) {
312-
command.kill();
313-
assert.ok(startCalled);
314-
assert.ok(outputStreamClosed);
315-
assert.equal(err.message, 'Output stream closed, try increasing terminateTimeout option (' + terminateTimeout + ' ms)');
316-
// Wait for kill completation before to call done()
317-
setTimeout(function() { done(); }, 500);
318-
})
319-
.on('end', function() {
320-
console.log('end was called, expected an error');
321-
assert.ok(false);
322-
})
323-
.saveToFile(testFile);
324-
});
325-
326282
it('should not keep node process running on completion', function(done) {
327283
var script = `
328284
var ffmpeg = require('.');
@@ -364,6 +320,7 @@ describe('Processor', function() {
364320
.on('end', function() {
365321
console.log('end was called, expected an error');
366322
assert.ok(false);
323+
done();
367324
})
368325
.saveToFile(testFile);
369326
});
@@ -400,6 +357,7 @@ describe('Processor', function() {
400357
.on('end', function() {
401358
console.log('end was called, expected a timeout');
402359
assert.ok(false);
360+
done();
403361
})
404362
.saveToFile(testFile);
405363

0 commit comments

Comments
 (0)