Skip to content

Commit 8c4e236

Browse files
committed
Fix #93: don't crash when ffmpeg is missing
The `available` check would raise an exception (not just return False) when ffmpeg/avconv is not available.
1 parent c8bedf7 commit 8c4e236

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

audioread/ffdec.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,21 @@ def popen_multiple(commands, command_args, *args, **kwargs):
9999

100100

101101
def available():
102-
"""Detect if the FFmpeg backend can be used on this system."""
103-
proc = popen_multiple(
104-
COMMANDS,
105-
['-version'],
106-
stdout=subprocess.PIPE,
107-
stderr=subprocess.PIPE,
108-
creationflags=PROC_FLAGS,
109-
)
110-
proc.wait()
111-
return (proc.returncode == 0)
102+
"""Detect whether the FFmpeg backend can be used on this system.
103+
"""
104+
try:
105+
proc = popen_multiple(
106+
COMMANDS,
107+
['-version'],
108+
stdout=subprocess.PIPE,
109+
stderr=subprocess.PIPE,
110+
creationflags=PROC_FLAGS,
111+
)
112+
except OSError:
113+
return False
114+
else:
115+
proc.wait()
116+
return proc.returncode == 0
112117

113118

114119
# For Windows error switch management, we need a lock to keep the mode

0 commit comments

Comments
 (0)