From eaf6a41041ee752e497b02966a61f85a8bc0e640 Mon Sep 17 00:00:00 2001 From: FlintyLemming Date: Sat, 28 Feb 2026 11:11:20 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(av1-transfer):=20use=20bash?= =?UTF-8?q?=20exec=20-a=20instead=20of=20executable=3D=20to=20rename=20ffm?= =?UTF-8?q?peg=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit subprocess.Popen with executable= fails on linuxbrew due to symlink/execve incompatibility. Use bash exec -a so ffmpeg is resolved via PATH instead. Co-Authored-By: Claude Sonnet 4.6 --- av1-transfer/main.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/av1-transfer/main.py b/av1-transfer/main.py index 32f5e79..b21445e 100644 --- a/av1-transfer/main.py +++ b/av1-transfer/main.py @@ -20,7 +20,7 @@ import argparse import ctypes import ctypes.util import queue -import shutil +import shlex import subprocess import sys from concurrent.futures import ThreadPoolExecutor, as_completed @@ -130,22 +130,19 @@ def transcode_one_file(file_info, overall_bar, slot_bars, slot_queue, process_na ] if process_name: - # 用 executable 指定真实路径,argv[0] 设为别名 - # 等效于 shell 的: exec -a ffmpeg ... - ffmpeg_exe = shutil.which("ffmpeg") - if not ffmpeg_exe: - raise RuntimeError("找不到 ffmpeg 可执行文件") - cmd = [process_name] + ffmpeg_args + # 用 bash 的 exec -a 重命名 ffmpeg 进程的 argv[0] + # ffmpeg 通过 PATH 查找,避免 execve 直接调用 symlink 的兼容问题 + shell_args = " ".join(shlex.quote(str(a)) for a in ffmpeg_args) proc = subprocess.Popen( - cmd, - executable=ffmpeg_exe, + f"exec -a {shlex.quote(process_name)} ffmpeg {shell_args}", + shell=True, + executable="/bin/bash", stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) else: - cmd = ["ffmpeg"] + ffmpeg_args proc = subprocess.Popen( - cmd, + ["ffmpeg"] + ffmpeg_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, )