Skip to content

Commit

Permalink
print useful error when ffprobe or ffmpeg is not installed/not in PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
amietn committed Jul 19, 2018
1 parent d3d6117 commit fd76a0b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions vcsi/vcsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ def probe_media(self, path):
path
]

output = subprocess.check_output(ffprobe_command)
self.ffprobe_dict = json.loads(output.decode("utf-8"))
try:
output = subprocess.check_output(ffprobe_command)
self.ffprobe_dict = json.loads(output.decode("utf-8"))
except FileNotFoundError:
error = "Could not find 'ffprobe' executable. Please make sure ffmpeg/ffprobe is installed and is in your PATH."
error_exit(error)

def human_readable_size(self, num, suffix='B'):
"""Converts a number of bytes to a human readable format
Expand Down Expand Up @@ -423,7 +427,11 @@ def make_capture(self, time, width, height, out_path="out.png"):
out_path
]

subprocess.call(ffmpeg_command, stderr=DEVNULL, stdout=DEVNULL)
try:
subprocess.call(ffmpeg_command, stderr=DEVNULL, stdout=DEVNULL)
except FileNotFoundError:
error = "Could not find 'ffmpeg' executable. Please make sure ffmpeg/ffprobe is installed and is in your PATH."
error_exit(error)

def compute_avg_color(self, image_path):
"""Computes the average color of an image
Expand Down

0 comments on commit fd76a0b

Please sign in to comment.