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

fix: consume stderr on wait #71

Merged
merged 4 commits into from
Dec 13, 2024
Merged

fix: consume stderr on wait #71

merged 4 commits into from
Dec 13, 2024

Conversation

nathanbabcock
Copy link
Owner

@nathanbabcock nathanbabcock commented Dec 12, 2024

Fixes #70

The stderr channel of the FFmpeg process is configured with Stdio::piped() by default, which is used to parse log messages for the iterator. However, this can cause problems when used with FfmpegChild.wait(). Log messages will continue to fill up that piped stdio channel without ever being consumed. If there aren't too many log messages, the command will finish successfully. There's enough room for several hundred log lines, which is why this bug never surfaced before. However, once the whole buffer is filled, then FFmpeg will hang while it waits for more room to insert log messages (which continues indefinitely).

The solution is to automatically drop consume the piped stderr channel when wait() is called.

@nathanbabcock
Copy link
Owner Author

nathanbabcock commented Dec 12, 2024

One problem with this solution revealed by the CI builds: on Unix, dropping stderr will send a SIGPIPE signal and FFmpeg will immediately exit.

The drop() solution will work as a stopgap on Windows, but it seems like a full solution will require:

  • Adding the stderr(), stdin(), and stdout() methods to FfmpegCommand to parallel std::Command and allow full control over configuring the IO channels
  • Contextual error messages if, after spawning the FfmpegChild, wait() is called in combination with piped stderr, or iter() is called without piped stderr
  • Keep the defaults backwards-compatible (i.e. all channels piped by default, since iter() is the primary use case)

@nathanbabcock nathanbabcock changed the title fix: drop stderr on wait fix: consume stderr on wait Dec 13, 2024
@nathanbabcock nathanbabcock merged commit 5fb9804 into main Dec 13, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

FFmpeg's nearly unlimited output causes ffmpeg-sidecar to hang without a timeout
1 participant