Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ pillow = "*"
pydantic = ">=1.10.8"
tokenizers = ">=0.14.0"
langchain-text-splitters = ">=0.3.8"
ffmpeg-python = "*"
ffmpeg-python = {version = "*", optional = true}

[tool.poetry.extras]
video = ["ffmpeg-python"]

[tool.poetry.group.test.dependencies]
pytest = "^7.4.2"
Expand Down
13 changes: 13 additions & 0 deletions voyageai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@
)
from voyageai.version import VERSION


def _is_ffmpeg_available() -> bool:
"""Check if ffmpeg-python is installed."""
try:
import ffmpeg # noqa: F401

return True
except ImportError:
return False


HAS_VIDEO = _is_ffmpeg_available()

if TYPE_CHECKING:
import requests
from aiohttp import ClientSession
Expand Down
4 changes: 2 additions & 2 deletions voyageai/video_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ def _load_video_bytes(video: Union[str, PathLike[str], bytes, Video]) -> bytes:
def _ensure_ffmpeg_available() -> None:
if ffmpeg is None:
raise ImportError(
"ffmpeg-python is required for video optimization. "
"Install `ffmpeg-python` and ensure `ffmpeg` is available on PATH."
"The 'ffmpeg-python' package is required for video optimization. "
"Install it with: pip install voyageai[video]"
)
if shutil.which("ffmpeg") is None:
raise EnvironmentError(
Expand Down