cli: add --ffmpeg-validation-timeout option#6716
Conversation
bastimeyer
left a comment
There was a problem hiding this comment.
Thanks for the PR. Appreciated...
I've added some comments where changes are required.
Is it intentional that the commit does have different author and committer data? Both seem to be yours, but with different GH accounts attached.
22f14b2 to
fc0acf5
Compare
|
Thank you for the review and feedback. I’ve fixed the author/committer metadata and updated the code based on your suggestions. |
bastimeyer
left a comment
There was a problem hiding this comment.
Thanks for the update. A couple more changes are required. Test and linting / code-style failures.
fc0acf5 to
4d568ca
Compare
|
Thanks for catching that — updated as suggested |
bastimeyer
left a comment
There was a problem hiding this comment.
Looking good. Appreciated...
There's one missed line in the coverage report at if timeout is None: in _resolve_command() because None is turned into the default value of 4.0 above. If you want, you can remove this redundant check and also remove None from the default value of the timeout arg (and just set it to FFMPEG_VERSION_TIMEOUT), but I don't mind because it requires breaking up the function header into multiple lines. Your decision...
diff --git a/src/streamlink/stream/ffmpegmux.py b/src/streamlink/stream/ffmpegmux.py
index ecfffec8..23e8e701 100644
--- a/src/streamlink/stream/ffmpegmux.py
+++ b/src/streamlink/stream/ffmpegmux.py
@@ -118,9 +118,12 @@ class FFMPEGMuxer(StreamIO):
@classmethod
@lru_cache(maxsize=128)
- def _resolve_command(cls, command: str | None = None, validate: bool = True, timeout: float | None = None) -> str | None:
- if timeout is None:
- timeout = cls.FFMPEG_VERSION_TIMEOUT
+ def _resolve_command(
+ cls,
+ command: str | None = None,
+ validate: bool = True,
+ timeout: float = FFMPEG_VERSION_TIMEOUT,
+ ) -> str | None:
if command:
resolved = which(command)
else:Otherwise, I'm just going to merge how it is now.
Thanks again for the PR.
Adds a new CLI argument --ffmpeg-validation-timeout that allows users to configure the timeout used when validating the FFmpeg binary with ffmpeg -version. This is useful for low-power or heavily loaded systems where FFmpeg startup can exceed the default 4.0 seconds, causing false validation failures and errors like: [stream.ffmpegmux][error] Could not validate FFmpeg! [stream.ffmpegmux][warning] No valid FFmpeg binary was found. [stream.ffmpegmux][warning] Muxing streams is unsupported! Changes include: - Added new CLI argument --ffmpeg-validation-timeout. - Mapped it to session option ffmpeg-validation-timeout. - Updated FFMPEGMuxer._resolve_command() to use the session timeout value. - Added tests to verify both default (4.0s) and custom timeout behavior. - Added changelog entry in docs/changelog.md. Default behavior remains unchanged (4.0 seconds if unspecified).
4d568ca to
d4d0b22
Compare
|
I’ve applied the final suggested cleanup: removed the redundant if timeout is None check and set the default directly in the _resolve_command signature. Thanks again for the review. |
Add --ffmpeg-validation-timeout CLI option to control FFmpeg version validation
Summary
This PR adds a new CLI argument
--ffmpeg-validation-timeoutthat allows users to configure the timeout used when validating the FFmpeg binary withffmpeg -version.On slower systems, such as low-power SBCs (e.g., Nanopi-NEO) or heavily loaded machines, the default 4.0-second timeout can cause false validation failures and warnings such as:
[stream.ffmpegmux][error] Could not validate FFmpeg!
[stream.ffmpegmux][warning] No valid FFmpeg binary was found.
[stream.ffmpegmux][warning] Muxing streams is unsupported!
These failures can result in audio not being muxed properly in recorded streams.
Changes in this PR
--ffmpeg-validation-timeout.ffmpeg-validation-timeout.FFMPEGMuxer._resolve_command()to use the session-provided timeout.docs/changelog.md.Default behavior
If the option is not specified, the timeout remains at 4.0 seconds.
Checklist