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

Intended way to clean up process #72

Open
FeldrinH opened this issue Dec 22, 2024 · 1 comment
Open

Intended way to clean up process #72

FeldrinH opened this issue Dec 22, 2024 · 1 comment

Comments

@FeldrinH
Copy link

My use case is similar to https://docs.rs/ffmpeg-sidecar/latest/ffmpeg_sidecar/#example, except I start multiple ffmpeg processes over the lifetime of my program.

I noticed that the documentation for spawn says that I should call wait to clean up the process once I am done, however, none of the usage examples in this repo seem to call wait.

What is the correct cleanup logic when using this library?

Is wait called somewhere automatically when I drop FfmpegIterator or do I need to call it manually? If I need to call it manually then what is the intended way to handle calling wait? I am especially thinking of cases where my function returns early due to some error and does not process all the frames.

@nathanbabcock
Copy link
Owner

The short answer is it does not happen automatically, so you should call wait manually if you want to be 100% sure the process gets cleaned up. Preferably after you've consumed the whole iterator and you know the wait call will return right away.

A lot of the examples in the repo don't do this, and it's not really a big deal if you skip it, because these "zombie processes" consume virtually no resources and only stick around until your Rust program ends. However if your Rust program will be long-living and spawning many instances of FFmpeg, it's a good idea to clean them up. There's a little more background about the issue in the Rust docs -- it's not an FFmpeg thing, it's an operating system quirk that applies to all child processes.

I would also recommend using kill() instead for your early exit case without processing all frames.

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