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

Cancel does not cancel ffmpeg.exe #8

Closed
dm413 opened this issue Mar 23, 2019 · 1 comment
Closed

Cancel does not cancel ffmpeg.exe #8

dm413 opened this issue Mar 23, 2019 · 1 comment

Comments

@dm413
Copy link
Contributor

dm413 commented Mar 23, 2019

If I pass a CancellationToken to ConvertAsync (for example), and then call Cancel() on the Token, the ffmpegnet library throws an exception with the message "A task was cancelled". That is good. However, the ffmpeg.exe process is not cancelled, and it continues to run in the background to completion, which can of course take a long time and consume large resources depending on the task.

I suggest that the library should catch the cancel exception, and abort the ffmpeg.exe process, and then rethrow the exception or throw one of your own exceptions. I believe you can abort the ffmpeg.exe process by sending "q" to the input stream of the process. This is better than just killing the process because "q" will leave the output file in a valid state.

@dm413 dm413 mentioned this issue Mar 29, 2019
cmxl pushed a commit that referenced this issue Apr 26, 2019
* Bug fix for issue #8: Cancel does not cancel ffmpeg.exe.
See #8.
When the calling program cancels the task by invoking Cancel() on the CancellationToken, send "q" to standard input of the ffmpeg.exe process.
This causes ffmpeg.exe to stop processing and shut down in an orderly way.
@cmxl
Copy link
Owner

cmxl commented Apr 26, 2019

your help is very much appreciated!
thanks for contributing :)

Edit:
Let me just fix the build. Changes should be included in the next version 👍

@cmxl cmxl closed this as completed Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants