Spaces:
Sleeping
Sleeping
| """ | |
| 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 | |