Skip to content

Commit a11a89d

Browse files
committed
Fixed missing ffmpeg path
Fixes #97 1. Desktop shortcut → pythonw.exe WhisperJAV_Launcher_v1.7.4.py 2. Launcher script → sets PATH, launches pythonw.exe -m whisperjav.webview_gui.main 3. main.py → sets PATH again (redundant but safe fallback)
1 parent a1c387f commit a11a89d

2 files changed

Lines changed: 52 additions & 4 deletions

File tree

installer/generated/custom_template_v1.7.4.nsi.tmpl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,16 +1441,17 @@ Section "Install"
14411441
14421442
; Create desktop shortcut
14431443
; Target: WhisperJAV v1.7.4.lnk on user's desktop
1444-
; Executable: WhisperJAV-GUI.exe (copied from Scripts/whisperjav-gui.exe by post_install)
1445-
; Parameters: none (exe handles everything)
1444+
; Executable: pythonw.exe (no console window)
1445+
; Parameters: launcher script that sets up PATH and launches GUI
14461446
; Icon: whisperjav_icon.ico in installation folder
14471447
; Icon index: 0 (first icon in file)
14481448
; Window state: SW_SHOWNORMAL (normal window)
14491449
; Hotkey: none ("")
14501450
; Description: shown in tooltip and properties
1451+
; Note: Using launcher ensures PATH is set for FFmpeg and other dependencies
14511452
CreateShortCut "$DESKTOP\WhisperJAV v1.7.4.lnk" \
1452-
"$INSTDIR\WhisperJAV-GUI.exe" \
1453-
"" \
1453+
"$INSTDIR\pythonw.exe" \
1454+
'"$INSTDIR\WhisperJAV_Launcher_v1.7.4.py"' \
14541455
"$INSTDIR\whisperjav_icon.ico" \
14551456
0 \
14561457
SW_SHOWNORMAL \

whisperjav/webview_gui/main.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,49 @@ def _ensure_utf8_output():
4545
_ensure_utf8_output()
4646

4747

48+
def _setup_conda_path():
49+
"""
50+
Set up PATH for conda environment dependencies (FFmpeg, DLLs).
51+
52+
When launched directly via pip entry point (WhisperJAV-GUI.exe),
53+
the conda environment's Library\bin is not on PATH. This causes
54+
FFmpeg and other bundled tools to be inaccessible.
55+
56+
This function adds the necessary directories to PATH:
57+
- Library\bin (FFmpeg, DLLs)
58+
- Scripts (other conda tools)
59+
60+
Safe to call multiple times - directories are only added once.
61+
"""
62+
if platform.system() != 'Windows':
63+
return # Only needed on Windows conda installs
64+
65+
# Determine installation root
66+
# sys.prefix is the conda environment root (e.g., %LOCALAPPDATA%\WhisperJAV)
67+
install_root = Path(sys.prefix)
68+
69+
# Key directories to add to PATH
70+
lib_bin_dir = install_root / "Library" / "bin"
71+
scripts_dir = install_root / "Scripts"
72+
73+
# Get current PATH
74+
current_path = os.environ.get("PATH", "")
75+
path_dirs = current_path.split(os.pathsep)
76+
77+
# Add directories if not already present
78+
dirs_to_add = []
79+
for dir_path in [str(lib_bin_dir), str(scripts_dir)]:
80+
# Case-insensitive check on Windows
81+
if not any(d.lower() == dir_path.lower() for d in path_dirs):
82+
if Path(dir_path).exists():
83+
dirs_to_add.append(dir_path)
84+
85+
if dirs_to_add:
86+
new_path = os.pathsep.join(dirs_to_add + [current_path])
87+
os.environ["PATH"] = new_path
88+
print(f"Added to PATH: {', '.join(dirs_to_add)}")
89+
90+
4891
def on_drop_event(e):
4992
"""
5093
Handle file/folder drops from OS into WebView.
@@ -391,6 +434,10 @@ def main():
391434
print(f"WhisperJAV GUI v{version}")
392435
print("=" * 50)
393436

437+
# Set up PATH for conda environment (FFmpeg, DLLs)
438+
# Must be called BEFORE any code that needs FFmpeg
439+
_setup_conda_path()
440+
394441
# Check WebView2 on Windows
395442
if not check_webview2_windows():
396443
show_webview2_error()

0 commit comments

Comments
 (0)