Find ffmpeg binary, preferring static-ffmpeg from pip.
()
| 68 | |
| 69 | |
| 70 | def find_ffmpeg() -> str: |
| 71 | """Find ffmpeg binary, preferring static-ffmpeg from pip.""" |
| 72 | # Try static-ffmpeg first |
| 73 | try: |
| 74 | import static_ffmpeg # pyright: ignore[reportMissingTypeStubs] |
| 75 | |
| 76 | static_ffmpeg.add_paths() # pyright: ignore[reportUnknownMemberType] |
| 77 | except ImportError: |
| 78 | pass |
| 79 | |
| 80 | ffmpeg = shutil.which("ffmpeg") |
| 81 | if ffmpeg: |
| 82 | return ffmpeg |
| 83 | |
| 84 | # Fallback: common locations |
| 85 | for path in [ |
| 86 | r"C:\Users\niteris\bin\ffmpeg.EXE", |
| 87 | "/usr/bin/ffmpeg", |
| 88 | "/usr/local/bin/ffmpeg", |
| 89 | ]: |
| 90 | if os.path.isfile(path): |
| 91 | return path |
| 92 | |
| 93 | print( |
| 94 | "ERROR: ffmpeg not found. Install with: pip install static-ffmpeg", |
| 95 | file=sys.stderr, |
| 96 | ) |
| 97 | sys.exit(1) |
| 98 | |
| 99 | |
| 100 | def run_ffmpeg(ffmpeg: str, args: list[str], desc: str = "") -> None: |