forked from LBRYCommunity/lbry-sdk
check ffmpeg/ffmprobe paths in a thread
This commit is contained in:
parent
33fbd715c0
commit
e7cded7511
1 changed files with 8 additions and 3 deletions
|
@ -73,6 +73,10 @@ class VideoFileAnalyzer:
|
||||||
log.debug("Using %s at %s", version.splitlines()[0].split(" Copyright")[0], self._which_ffmpeg)
|
log.debug("Using %s at %s", version.splitlines()[0].split(" Copyright")[0], self._which_ffmpeg)
|
||||||
return version
|
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):
|
async def _verify_ffmpeg_installed(self):
|
||||||
if self._ffmpeg_installed:
|
if self._ffmpeg_installed:
|
||||||
return
|
return
|
||||||
|
@ -81,17 +85,18 @@ class VideoFileAnalyzer:
|
||||||
if hasattr(self._conf, "data_dir"):
|
if hasattr(self._conf, "data_dir"):
|
||||||
path += os.path.pathsep + os.path.join(getattr(self._conf, "data_dir"), "ffmpeg", "bin")
|
path += os.path.pathsep + os.path.join(getattr(self._conf, "data_dir"), "ffmpeg", "bin")
|
||||||
path += os.path.pathsep + self._env_copy.get("PATH", "")
|
path += os.path.pathsep + self._env_copy.get("PATH", "")
|
||||||
|
self._which_ffmpeg, self._which_ffprobe = await asyncio.get_running_loop().run_in_executor(
|
||||||
self._which_ffmpeg = shutil.which("ffmpeg", path=path)
|
None, self._which_ffmpeg_and_ffmprobe, path
|
||||||
|
)
|
||||||
if not self._which_ffmpeg:
|
if not self._which_ffmpeg:
|
||||||
log.warning("Unable to locate ffmpeg executable. Path: %s", path)
|
log.warning("Unable to locate ffmpeg executable. Path: %s", path)
|
||||||
raise FileNotFoundError(f"Unable to locate ffmpeg executable. Path: {path}")
|
raise FileNotFoundError(f"Unable to locate ffmpeg executable. Path: {path}")
|
||||||
self._which_ffprobe = shutil.which("ffprobe", path=path)
|
|
||||||
if not self._which_ffprobe:
|
if not self._which_ffprobe:
|
||||||
log.warning("Unable to locate ffprobe executable. Path: %s", path)
|
log.warning("Unable to locate ffprobe executable. Path: %s", path)
|
||||||
raise FileNotFoundError(f"Unable to locate ffprobe executable. Path: {path}")
|
raise FileNotFoundError(f"Unable to locate ffprobe executable. Path: {path}")
|
||||||
if os.path.dirname(self._which_ffmpeg) != os.path.dirname(self._which_ffprobe):
|
if os.path.dirname(self._which_ffmpeg) != os.path.dirname(self._which_ffprobe):
|
||||||
log.warning("ffmpeg and ffprobe are in different folders!")
|
log.warning("ffmpeg and ffprobe are in different folders!")
|
||||||
|
|
||||||
await self._verify_executables()
|
await self._verify_executables()
|
||||||
self._ffmpeg_installed = True
|
self._ffmpeg_installed = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue