news-whisper-api / backend /common /ffmpeg_utils.py
Devang1290
feat: deploy News Whisper on-demand search API (FastAPI + Docker)
2cb327c
raw
history blame contribute delete
766 Bytes
"""
FFmpeg Utilities
================
Shared check for FFmpeg availability, used by both Hindi and English TTS modules.
Usage:
from backend.common import check_ffmpeg
has_ffmpeg = check_ffmpeg()
"""
import subprocess
def check_ffmpeg() -> bool:
"""Check whether FFmpeg is installed and available on the system PATH.
Returns True if the `ffmpeg -version` command exits successfully.
Returns False otherwise (prints install instructions on first failure).
"""
try:
subprocess.run(
["ffmpeg", "-version"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False