mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
get_ffmpeg_tool_path moved to ffmpeg utils
This commit is contained in:
parent
9a04ace92b
commit
4e0ae38a12
3 changed files with 30 additions and 27 deletions
|
|
@ -38,11 +38,13 @@ from .plugin_tools import filter_pyblish_plugins, source_hash
|
|||
from .path_tools import (
|
||||
version_up,
|
||||
get_version_from_path,
|
||||
get_last_version_from_path,
|
||||
get_ffmpeg_tool_path
|
||||
get_last_version_from_path
|
||||
)
|
||||
|
||||
from .ffmpeg_utils import ffprobe_streams
|
||||
from .ffmpeg_utils import (
|
||||
get_ffmpeg_tool_path,
|
||||
ffprobe_streams
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"get_avalon_database",
|
||||
|
|
@ -74,9 +76,9 @@ __all__ = [
|
|||
"version_up",
|
||||
"get_version_from_path",
|
||||
"get_last_version_from_path",
|
||||
"get_ffmpeg_tool_path",
|
||||
|
||||
"ffprobe_streams",
|
||||
"get_ffmpeg_tool_path",
|
||||
|
||||
"source_hash",
|
||||
"_subprocess"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,35 @@
|
|||
import os
|
||||
import logging
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
from . import get_ffmpeg_tool_path
|
||||
from . import get_paths_from_environ
|
||||
|
||||
log = logging.getLogger("FFmpeg utils")
|
||||
|
||||
|
||||
def get_ffmpeg_tool_path(tool="ffmpeg"):
|
||||
"""Find path to ffmpeg tool in FFMPEG_PATH paths.
|
||||
|
||||
Function looks for tool in paths set in FFMPEG_PATH environment. If tool
|
||||
exists then returns it's full path.
|
||||
|
||||
Args:
|
||||
tool (string): tool name
|
||||
|
||||
Returns:
|
||||
(str): tool name itself when tool path was not found. (FFmpeg path
|
||||
may be set in PATH environment variable)
|
||||
"""
|
||||
dir_paths = get_paths_from_environ("FFMPEG_PATH")
|
||||
for dir_path in dir_paths:
|
||||
for file_name in os.listdir(dir_path):
|
||||
base, _ext = os.path.splitext(file_name)
|
||||
if base.lower() == tool.lower():
|
||||
return os.path.join(dir_path, tool)
|
||||
return tool
|
||||
|
||||
|
||||
def ffprobe_streams(path_to_file, logger=None):
|
||||
"""Load streams from entered filepath via ffprobe.
|
||||
|
||||
|
|
|
|||
|
|
@ -5,28 +5,6 @@ import logging
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_ffmpeg_tool_path(tool="ffmpeg"):
|
||||
"""Find path to ffmpeg tool in FFMPEG_PATH paths.
|
||||
|
||||
Function looks for tool in paths set in FFMPEG_PATH environment. If tool
|
||||
exists then returns it's full path.
|
||||
|
||||
Args:
|
||||
tool (string): tool name
|
||||
|
||||
Returns:
|
||||
(str): tool name itself when tool path was not found. (FFmpeg path
|
||||
may be set in PATH environment variable)
|
||||
"""
|
||||
dir_paths = get_paths_from_environ("FFMPEG_PATH")
|
||||
for dir_path in dir_paths:
|
||||
for file_name in os.listdir(dir_path):
|
||||
base, _ext = os.path.splitext(file_name)
|
||||
if base.lower() == tool.lower():
|
||||
return os.path.join(dir_path, tool)
|
||||
return tool
|
||||
|
||||
|
||||
def _rreplace(s, a, b, n=1):
|
||||
"""Replace a with b in string s from right side n times."""
|
||||
return b.join(s.rsplit(a, n))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue