mirror of https://github.com/streamlink/streamlink
stream.ffmpegmux: show warning if unavailable
This commit is contained in:
parent
f219e7ff73
commit
cc0f978a34
|
@ -90,12 +90,16 @@ class FFMPEGMuxer(StreamIO):
|
|||
@lru_cache(maxsize=128)
|
||||
def resolve_command(cls, command: Optional[str] = None) -> Optional[str]:
|
||||
if command:
|
||||
return which(command)
|
||||
resolved = None
|
||||
for cmd in cls.__commands__:
|
||||
resolved = which(cmd)
|
||||
if resolved:
|
||||
break
|
||||
resolved = which(command)
|
||||
else:
|
||||
resolved = None
|
||||
for cmd in cls.__commands__:
|
||||
resolved = which(cmd)
|
||||
if resolved:
|
||||
break
|
||||
if not resolved:
|
||||
log.warning("FFmpeg was not found. See the --ffmpeg-ffmpeg option.")
|
||||
log.warning("Muxing streams is unsupported! Only a subset of the available streams can be returned!")
|
||||
return resolved
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -52,6 +52,23 @@ class TestCommand:
|
|||
with patch("streamlink.stream.ffmpegmux.which", return_value=resolved):
|
||||
assert FFMPEGMuxer.is_usable(session) is expected
|
||||
|
||||
def test_log(self, session: Streamlink):
|
||||
with patch("streamlink.stream.ffmpegmux.log") as mock_log, \
|
||||
patch("streamlink.stream.ffmpegmux.which", return_value=None):
|
||||
assert not FFMPEGMuxer.is_usable(session)
|
||||
assert mock_log.warning.call_args_list == [
|
||||
call("FFmpeg was not found. See the --ffmpeg-ffmpeg option."),
|
||||
call("Muxing streams is unsupported! Only a subset of the available streams can be returned!"),
|
||||
]
|
||||
assert not FFMPEGMuxer.is_usable(session)
|
||||
assert len(mock_log.warning.call_args_list) == 2
|
||||
|
||||
def test_no_log(self, session: Streamlink):
|
||||
with patch("streamlink.stream.ffmpegmux.log") as mock_log, \
|
||||
patch("streamlink.stream.ffmpegmux.which", return_value="foo"):
|
||||
assert FFMPEGMuxer.is_usable(session)
|
||||
assert not mock_log.warning.call_args_list
|
||||
|
||||
|
||||
class TestOpen:
|
||||
FFMPEG_ARGS_DEFAULT_BASE = ["-nostats", "-y"]
|
||||
|
|
Loading…
Reference in New Issue