From e7cded75112aa481d4a341ca58e03e9b85935eec Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 27 Mar 2020 12:12:35 -0400 Subject: [PATCH] check ffmpeg/ffmprobe paths in a thread --- lbry/file_analysis.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lbry/file_analysis.py b/lbry/file_analysis.py index f5941872c..7e083991c 100644 --- a/lbry/file_analysis.py +++ b/lbry/file_analysis.py @@ -73,6 +73,10 @@ class VideoFileAnalyzer: log.debug("Using %s at %s", version.splitlines()[0].split(" Copyright")[0], self._which_ffmpeg) return version + @staticmethod + def _which_ffmpeg_and_ffmprobe(path): + return shutil.which("ffmpeg", path=path), shutil.which("ffprobe", path=path) + async def _verify_ffmpeg_installed(self): if self._ffmpeg_installed: return @@ -81,17 +85,18 @@ class VideoFileAnalyzer: if hasattr(self._conf, "data_dir"): path += os.path.pathsep + os.path.join(getattr(self._conf, "data_dir"), "ffmpeg", "bin") path += os.path.pathsep + self._env_copy.get("PATH", "") - - self._which_ffmpeg = shutil.which("ffmpeg", path=path) + self._which_ffmpeg, self._which_ffprobe = await asyncio.get_running_loop().run_in_executor( + None, self._which_ffmpeg_and_ffmprobe, path + ) if not self._which_ffmpeg: log.warning("Unable to locate ffmpeg executable. Path: %s", path) raise FileNotFoundError(f"Unable to locate ffmpeg executable. Path: {path}") - self._which_ffprobe = shutil.which("ffprobe", path=path) if not self._which_ffprobe: log.warning("Unable to locate ffprobe executable. Path: %s", path) raise FileNotFoundError(f"Unable to locate ffprobe executable. Path: {path}") if os.path.dirname(self._which_ffmpeg) != os.path.dirname(self._which_ffprobe): log.warning("ffmpeg and ffprobe are in different folders!") + await self._verify_executables() self._ffmpeg_installed = True