Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support process options #1073

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,21 @@ command.clone()
command.save('/path/to/output-original-size.mp4');
```

### Child Process Options

You can pass child-process options to the spawn method.
See [child_process.spawn](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).

```js
// Create a detached process command to convert source.avi to MP4
var command = ffmpeg('/path/to/source.avi')
.withProcessOptions({
detached: true
})
.format('mp4')
.save('/path/to/output.mp4');
```


## Contributing

Expand Down
31 changes: 24 additions & 7 deletions lib/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,16 +431,18 @@ module.exports = function(proto) {
return emitEnd(err);
}

var options = Object.assign({
captureStdout: !outputStream,
niceness: self.options.niceness,
cwd: self.options.cwd,
windowsHide: true
}, self.options.processOptions || {});

// Run ffmpeg
self._spawnFfmpeg(
args,
{
captureStdout: !outputStream,
niceness: self.options.niceness,
cwd: self.options.cwd,
windowsHide: true
},

options,

function processCB(ffmpegProc, stdoutRing, stderrRing) {
self.ffmpegProc = ffmpegProc;
self.emit('start', 'ffmpeg ' + args.join(' '));
Expand Down Expand Up @@ -641,6 +643,21 @@ module.exports = function(proto) {
};


/**
* Add process options to spawn
*
* @method FfmpegCommand#withProcessOptions
* @category Processing
*
* @see [child_process.spawn](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)
* @return FfmpegCommand
*/
proto.withProcessOptions = function(options) {
options = options || {};
this.options.processOptions = options;
return this;
};

/**
* Kill current ffmpeg process, if any
*
Expand Down