Get path to ffmpeg if available on the current system. First looks at PATH, then checks if one is available from the `imageio_ffmpeg` package. Returns None if ffmpeg couldn't be found.
()
| 248 | |
| 249 | |
| 250 | def get_ffmpeg_path() -> str | None: |
| 251 | """Get path to ffmpeg if available on the current system. First looks at PATH, then checks if |
| 252 | one is available from the `imageio_ffmpeg` package. Returns None if ffmpeg couldn't be found. |
| 253 | """ |
| 254 | # Try invoking ffmpeg with the current environment. |
| 255 | try: |
| 256 | subprocess.call(["ffmpeg", "-v", "quiet"]) |
| 257 | return "ffmpeg" |
| 258 | except OSError: |
| 259 | pass # Failed to invoke ffmpeg with current environment, try another possibility. |
| 260 | |
| 261 | # Try invoking ffmpeg using the one from `imageio_ffmpeg` if available. |
| 262 | try: |
| 263 | from imageio_ffmpeg import get_ffmpeg_exe |
| 264 | |
| 265 | subprocess.call([get_ffmpeg_exe(), "-v", "quiet"]) |
| 266 | return get_ffmpeg_exe() |
| 267 | # Gracefully handle case where imageio_ffmpeg is not available. |
| 268 | except ModuleNotFoundError: |
| 269 | pass |
| 270 | # Handle case where path might be wrong/non-existent. |
| 271 | except OSError: |
| 272 | pass |
| 273 | # get_ffmpeg_exe may throw a RuntimeError if the executable is not available. |
| 274 | except RuntimeError: |
| 275 | pass |
| 276 | |
| 277 | return None |
| 278 | |
| 279 | |
| 280 | def get_ffmpeg_version() -> str | None: |
no outgoing calls
no test coverage detected