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

Registering SIGINT handler to cleanly exit application doesn't work because ffmpeg gets killed right away #644

Closed
rightaway opened this issue Jan 12, 2017 · 6 comments

Comments

@rightaway
Copy link

In my application I've done process.on('SIGINT', mySigintHandler) to cleanly exit the application when the current tasks have finished rather than killing the application immediately and leaving the tasks in an inconsistent state.

However, as soon as I do ctrl+c in the console, the application doesn't cleanly exit because ffmpeg is killed right away. The error messages I get depend on when exactly it's killed. A few examples

ffmpeg exited with code 1: /tmp/video100.mp4: Immediate exit requested
ffmpeg exited with code 1: /tmp/video100.mp4: Input/output error
ffmpeg exited with code 255: Press [q] to stop, [?] for help

How can I disable the automatic terminating of ffmpeg so that I can kill them from my SIGINT handler? This would be a useful feature to add if it's not possible currently.

@njoyard
Copy link
Member

njoyard commented Mar 3, 2017

What are you doing in your handler ?

@rightaway
Copy link
Author

It's just a one liner, it sets a flag to instruct the main application loop that it can cleanly end before the next iteration of the loop.

@kanopy-andres
Copy link

Hi, i'm having the same issue. A solution would be to have the spawn method take detached: true, optionally. This will help thanks to what's written in the options.detached parameters below: https://nodejs.org/api/child_process.html#child_process_options_detached

Basically, you send a signal to your process, it won't propagate to your child if you give him the detached :true attribute.

@njoyard
Copy link
Member

njoyard commented Mar 31, 2018

Closing as this is getting a bit old.
Feel free to submit a PR to allow passing spawn options :)

@njoyard njoyard closed this as completed Mar 31, 2018
@tan-tan-kanarek
Copy link

I have the same issue, need a detached process.
I found it easier to implement spawn myself without fluent-ffmpeg than implementing a PR.
I also couldn't use fluent-ffmpeg when I needed global options before the inputs such as -protocol_whitelist, -safe, if concat, -f lavfi, etc.

@tan-tan-kanarek
Copy link

OK, I did PR - #1073
Using this branch you can add process options, see docs: https://github.com/peechpro/node-fluent-ffmpeg/tree/process-options#child-process-options

However, that didn't help me with SIGTERM on docker, I assume because the stdout and stderr are piped to the parent process which nullifies the detached option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants