Skip to content

Commit fae1e78

Browse files
committed
Auto-install imageio-ffmpeg when missing (fixes existing-venv users)
v0.12.6 added imageio-ffmpeg to ML_COMPONENTS.core, but users with venvs created before v0.12.6 won't get it until they reinstall the ML environment. They saw the very error message my own code prints: "ffmpeg not found. Install ffmpeg (e.g. brew install ffmpeg ...) or pip install imageio-ffmpeg for a bundled fallback" Fix: have _resolve_ffmpeg() pip-install imageio-ffmpeg on demand the first time it's needed. ~30 MB platform-specific wheel; cached for all future runs. Same path serves any user (mac/win/linux) on a stale venv, not just macOS. Also extended env:check to include imageio_ffmpeg in the import probe so a stale venv now triggers the setup wizard on app launch.
1 parent 3a2c2e7 commit fae1e78

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

downloader.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -901,18 +901,44 @@ def _resolve_ffmpeg() -> str | None:
901901
1. System ffmpeg in PATH (best — usually fastest, tracks user updates)
902902
2. imageio-ffmpeg's bundled binary (cross-platform fallback for macOS
903903
and any system without ffmpeg installed; pip-installable, no admin
904-
rights needed)
904+
rights needed). If imageio-ffmpeg isn't present (e.g. the user has
905+
a venv from an older AutoNote release that pre-dates this fallback),
906+
install it on demand — it's a single platform-specific wheel under
907+
30 MB and the binary is cached for future runs.
905908
"""
906909
from shutil import which
907910
sys_ff = which("ffmpeg")
908911
if sys_ff:
909912
return sys_ff
913+
914+
def _try_imageio() -> str | None:
915+
try:
916+
import imageio_ffmpeg
917+
return imageio_ffmpeg.get_ffmpeg_exe()
918+
except ImportError:
919+
return None
920+
except Exception as e:
921+
tqdm.write(f" [warn] imageio-ffmpeg get_ffmpeg_exe failed: {e}")
922+
return None
923+
924+
ff = _try_imageio()
925+
if ff:
926+
return ff
927+
928+
# Auto-install on first need. Quiet, fast, idempotent.
929+
tqdm.write(" ffmpeg not found locally — installing imageio-ffmpeg fallback…")
910930
try:
911-
import imageio_ffmpeg
912-
return imageio_ffmpeg.get_ffmpeg_exe()
913-
except Exception:
931+
import subprocess as _sp
932+
_sp.run(
933+
[sys.executable, "-m", "pip", "install", "--quiet", "--disable-pip-version-check", "imageio-ffmpeg"],
934+
check=True, timeout=180,
935+
)
936+
except Exception as e:
937+
tqdm.write(f" [warn] auto-install imageio-ffmpeg failed: {e}")
914938
return None
915939

940+
return _try_imageio()
941+
916942

917943
def _run_ffmpeg_hls(stream_url: str, out_path: Path, progress_cb) -> None:
918944
"""Download an HLS master.m3u8 stream to *out_path* via ffmpeg.

electron/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ function registerIpc() {
996996
if (hasPython) {
997997
try {
998998
const r = spawnSync(VENV_PYTHON,
999-
['-c', 'import tqdm, requests, openai, canvasapi, PIL, fitz, pptx; print("ok")'],
999+
['-c', 'import tqdm, requests, openai, canvasapi, PIL, fitz, pptx, imageio_ffmpeg; print("ok")'],
10001000
{ timeout: 10000, windowsHide: true });
10011001
coreOk = (r.status === 0 && (r.stdout || '').toString().includes('ok'));
10021002
} catch {}

electron/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "auto-note",
3-
"version": "0.12.6",
3+
"version": "0.12.7",
44
"description": "AutoNote — lecture notes generator from Canvas recordings",
55
"homepage": "https://github.com/nodeeeeee/Auto-Note",
66
"author": {

0 commit comments

Comments
 (0)