Skip to content

Commit

Permalink
better error if ffplay not found
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Nov 15, 2020
1 parent 263eadb commit dc5c3b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/pylivestream/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def listener(self):

TIMEOUT = 0.5

FFPLAY = shutil.which("ffplay")
if not FFPLAY:
exe = shutil.which("ffplay")
if not exe:
raise FileNotFoundError("FFplay not found, cannot start listener")

cmd = [FFPLAY, "-loglevel", "error", "-timeout", "5", "-autoexit", "rtmp://localhost"]
cmd = [exe, "-loglevel", "error", "-timeout", "5", "-autoexit", "rtmp://localhost"]

print(
"starting Localhost RTMP listener. \n\n",
Expand Down
8 changes: 7 additions & 1 deletion src/pylivestream/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
import typing as T
import importlib.resources
import shutil

from .ffmpeg import get_meta

Expand Down Expand Up @@ -50,8 +51,13 @@ def check_device(cmd: T.Sequence[str]) -> bool:
def check_display(fn: Path = None) -> bool:
"""see if it's possible to display something with a test file"""

exe = shutil.which("ffplay")

if not exe:
raise FileNotFoundError("FFplay not found")

def _check_disp(fn: Path) -> int:
cmd = ["ffplay", "-loglevel", "error", "-t", "1.0", "-autoexit", str(fn)]
cmd = [exe, "-loglevel", "error", "-t", "1.0", "-autoexit", str(fn)]
return subprocess.run(cmd, timeout=10).returncode

if fn:
Expand Down

0 comments on commit dc5c3b9

Please sign in to comment.