2222from .models import MergeMode , Orientation , VideoFile
2323from .probe import probe_files
2424from .scanner import scan_video_files
25+ from .utils import subprocess_window_kwargs
26+ from . import __version__
2527
2628
2729HTML = r"""<!doctype html>
@@ -925,7 +927,7 @@ def _open_desktop_window(url: str) -> None:
925927 "Desktop GUI requires pywebview. Install dependencies with `pip install -r requirements.txt`."
926928 ) from exc
927929
928- webview .create_window ("VideoMergingTool" , url , width = 1280 , height = 820 , min_size = (900 , 620 ))
930+ webview .create_window (f "VideoMergingTool { __version__ } " , url , width = 1280 , height = 820 , min_size = (900 , 620 ))
929931 webview .start ()
930932
931933
@@ -969,7 +971,7 @@ def _deps(self) -> None:
969971 try :
970972 logger = _gui_logger (state )
971973 tools = resolve_tools (logger , True , default_tools_dir ())
972- encoders = detect_ffmpeg_encoders (tools )
974+ encoders = detect_ffmpeg_encoders (tools , timeout = 3 )
973975 gpu_encoders = sorted (
974976 encoder
975977 for encoder in encoders
@@ -1182,6 +1184,7 @@ def _terminate_process(process: subprocess.Popen[str]) -> None:
11821184 stdout = subprocess .DEVNULL ,
11831185 stderr = subprocess .DEVNULL ,
11841186 check = False ,
1187+ ** subprocess_window_kwargs (),
11851188 )
11861189 else :
11871190 os .killpg (process .pid , signal .SIGTERM )
@@ -1201,7 +1204,7 @@ def _terminate_process(process: subprocess.Popen[str]) -> None:
12011204
12021205def _process_group_kwargs () -> dict [str , object ]:
12031206 if os .name == "nt" :
1204- return {"creationflags" : subprocess .CREATE_NEW_PROCESS_GROUP }
1207+ return {"creationflags" : subprocess .CREATE_NEW_PROCESS_GROUP | getattr ( subprocess , "CREATE_NO_WINDOW" , 0 ) }
12051208 return {"start_new_session" : True }
12061209
12071210
@@ -1220,6 +1223,8 @@ def _pick_folder(kind: str) -> str:
12201223 title = "Select output folder" if kind == "output" else "Select source video folder"
12211224 if platform .system () == "Darwin" :
12221225 return _pick_folder_macos (title )
1226+ if platform .system () == "Windows" :
1227+ return _pick_folder_windows (title ) or _pick_folder_tk (title )
12231228 return _pick_folder_tk (title )
12241229
12251230
@@ -1233,6 +1238,43 @@ def _pick_folder_macos(title: str) -> str:
12331238 text = True ,
12341239 encoding = "utf-8" ,
12351240 errors = "replace" ,
1241+ ** subprocess_window_kwargs (),
1242+ )
1243+ if result .returncode == 0 :
1244+ return result .stdout .strip ()
1245+ except Exception :
1246+ return ""
1247+ return ""
1248+
1249+
1250+ def _pick_folder_windows (title : str ) -> str :
1251+ escaped_title = title .replace ("'" , "''" )
1252+ script = f"""
1253+ Add-Type -AssemblyName System.Windows.Forms
1254+ $dialog = New-Object System.Windows.Forms.OpenFileDialog
1255+ $dialog.Title = '{ escaped_title } '
1256+ $dialog.CheckFileExists = $false
1257+ $dialog.ValidateNames = $false
1258+ $dialog.FileName = 'Select this folder'
1259+ $dialog.Filter = 'Folders|*.folder'
1260+ if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {{
1261+ $selected = $dialog.FileName
1262+ if (Test-Path -LiteralPath $selected -PathType Container) {{
1263+ Write-Output $selected
1264+ }} else {{
1265+ Write-Output (Split-Path -Parent $selected)
1266+ }}
1267+ }}
1268+ """
1269+ try :
1270+ result = subprocess .run (
1271+ ["powershell" , "-NoProfile" , "-STA" , "-ExecutionPolicy" , "Bypass" , "-Command" , script ],
1272+ stdout = subprocess .PIPE ,
1273+ stderr = subprocess .PIPE ,
1274+ text = True ,
1275+ encoding = "utf-8" ,
1276+ errors = "replace" ,
1277+ ** subprocess_window_kwargs (),
12361278 )
12371279 if result .returncode == 0 :
12381280 return result .stdout .strip ()
0 commit comments