← Files AgentBrokoARCHIVED FILE

src/video_forge/_ffmpeg.py

794 Bytes · Sep 30, 2026 · 23:15 UTC

↓ Download file

"""Locate the ffmpeg / ffprobe binaries.

Prefers an explicit env var, then the winget install path used on this machine,
then whatever is on PATH. Shared by render_video (video) and audio (mux)."""

import os
import shutil

_WINGET = os.path.join(
    os.environ.get("LOCALAPPDATA", ""),
    "Microsoft", "WinGet", "Packages",
    "Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe",
    "ffmpeg-9.0-full_build", "bin",
)


def _find(name, env):
    p = os.environ.get(env)
    if p and os.path.exists(p):
        return p
    cand = os.path.join(_WINGET, name + ".exe")
    if os.path.exists(cand):
        return cand
    found = shutil.which(name)
    return found or name


def ffmpeg_bin():
    return _find("ffmpeg", "FFMPEG")


def ffprobe_bin():
    return _find("ffprobe", "FFPROBE")

SHA-256: a461698ec84a153b54fef3f79301677043e4ddd8efae102db59e6c5051349d42