MCPcopy Create free account
hub / github.com/Breakthrough/PySceneDetect / get_ffmpeg_path

Function get_ffmpeg_path

scenedetect/platform.py:250–277  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

248
249
250def 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
280def get_ffmpeg_version() -> str | None:

Callers 2

video.pyFile · 0.90
get_ffmpeg_versionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected