From fc3d1ff02296c5b881c570169377ea4df8e992fc Mon Sep 17 00:00:00 2001 From: hoelee Date: Thu, 29 Oct 2026 08:03:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(tracks):=20ffprobe=20/=20ffmpeg=20=E5=AD=90?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E7=BB=9F=E4=B8=80=20CREATE=5FNO=5FWINDOW?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows 上每次探测轨道、取流摘要都会闪一个黑窗(命令行窗口), 批量扫描几百个文件时尤其明显。ffprobe 的 subprocess.run 与 _stream_digest 的 ffmpeg Popen/run 全部加 creationflags=NOWIN, 与 library_run.py / transcode.py 的既有做法保持一致。 scripts.test_tracks 55/55。 --- scripts/tracks.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/tracks.py b/scripts/tracks.py index ab8e1bf..1f39bc2 100644 --- a/scripts/tracks.py +++ b/scripts/tracks.py @@ -43,6 +43,8 @@ import json import os import subprocess +NOWIN = getattr(subprocess, "CREATE_NO_WINDOW", 0) + # The supervisor hands every engine child its OWN resolved ffmpeg/ffprobe # (`rt.config.engine_child_env` → TRANSCODE_FFMPEG/TRANSCODE_FFPROBE, mirroring # `transcode.py:36-37`). Honour them here as well: this module used to call the bare @@ -87,7 +89,7 @@ def probe(path, timeout=180): r = subprocess.run([FFPROBE, "-v", "error", "-print_format", "json", "-show_streams", "-show_format", "-show_chapters", path], capture_output=True, text=True, encoding="utf-8", errors="replace", - timeout=timeout) + timeout=timeout, creationflags=NOWIN) if r.returncode != 0: return None try: @@ -450,7 +452,7 @@ def stream_signature(path, sel, timeout=1800): r = subprocess.run([FFPROBE, "-v", "error", "-select_streams", sel, "-count_packets", "-show_entries", "stream=nb_read_packets", "-of", "csv=p=0", path], capture_output=True, text=True, encoding="utf-8", errors="replace", - timeout=timeout) + timeout=timeout, creationflags=NOWIN) if r.returncode != 0: return None try: @@ -458,7 +460,8 @@ def stream_signature(path, sel, timeout=1800): except Exception: # noqa: BLE001 return None p = subprocess.Popen([FFMPEG, "-v", "error", "-i", path, "-map", "0:" + sel, "-c", "copy", - "-f", "data", "-"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + "-f", "data", "-"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, + creationflags=NOWIN) h = hashlib.md5() try: while True: