Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cli: add --ffmpeg-validation-timeout option#6716

Merged
bastimeyer merged 1 commit into
streamlink:masterfrom
oliviernes:add-ffmpeg-validation-timeout-option
Nov 10, 2025
Merged

cli: add --ffmpeg-validation-timeout option#6716
bastimeyer merged 1 commit into
streamlink:masterfrom
oliviernes:add-ffmpeg-validation-timeout-option

Conversation

@oliviernes

Copy link
Copy Markdown
Contributor

Add --ffmpeg-validation-timeout CLI option to control FFmpeg version validation

Summary

This 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.

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

  • Added new CLI argument --ffmpeg-validation-timeout.
  • Mapped it to the session option ffmpeg-validation-timeout.
  • Updated FFMPEGMuxer._resolve_command() to use the session-provided timeout.
  • Added tests verifying both default (4.0s) and custom timeout behavior.
  • Added a changelog entry in docs/changelog.md.

Default behavior

If the option is not specified, the timeout remains at 4.0 seconds.

Checklist

  • Added new CLI argument
  • Mapped argument to session options
  • Updated FFMPEG validation logic to use session-provided timeout
  • Verified proper debug output and audio muxing behavior
  • Added tests for default and custom timeout behavior
  • Added changelog entry in docs/changelog.md
  • Maintains backward compatibility

@bastimeyer bastimeyer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/streamlink/stream/ffmpegmux.py Outdated
Comment thread src/streamlink_cli/argparser.py
Comment thread src/streamlink_cli/argparser.py
Comment thread tests/stream/test_ffmpegmux.py Outdated
Comment thread CHANGELOG.md Outdated
@oliviernes

Copy link
Copy Markdown
Contributor Author

Thank you for the review and feedback. I’ve fixed the author/committer metadata and updated the code based on your suggestions.

@bastimeyer bastimeyer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. A couple more changes are required. Test and linting / code-style failures.

Comment thread src/streamlink/session/options.py Outdated
Comment thread src/streamlink/stream/ffmpegmux.py Outdated
Comment thread tests/stream/test_ffmpegmux.py Outdated
Comment thread tests/stream/test_ffmpegmux.py Outdated
@oliviernes oliviernes force-pushed the add-ffmpeg-validation-timeout-option branch from fc0acf5 to 4d568ca Compare November 10, 2025 19:50
@oliviernes

Copy link
Copy Markdown
Contributor Author

Thanks for catching that — updated as suggested

@bastimeyer bastimeyer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).
@oliviernes oliviernes force-pushed the add-ffmpeg-validation-timeout-option branch from 4d568ca to d4d0b22 Compare November 10, 2025 20:46
@oliviernes

Copy link
Copy Markdown
Contributor Author

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.

@bastimeyer bastimeyer merged commit 4e8605d into streamlink:master Nov 10, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants