🐛 fix(av1-transfer): use bash exec -a instead of executable= to rename ffmpeg process

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 <noreply@anthropic.com>
This commit is contained in:
FlintyLemming
2026-02-28 11:11:20 +08:00
parent c31a459f36
commit eaf6a41041

View File

@@ -20,7 +20,7 @@ import argparse
import ctypes import ctypes
import ctypes.util import ctypes.util
import queue import queue
import shutil import shlex
import subprocess import subprocess
import sys import sys
from concurrent.futures import ThreadPoolExecutor, as_completed 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: if process_name:
# 用 executable 指定真实路径,argv[0] 设为别名 # 用 bash 的 exec -a 重命名 ffmpeg 进程的 argv[0]
# 等效于 shell 的: exec -a <process_name> ffmpeg ... # ffmpeg 通过 PATH 查找,避免 execve 直接调用 symlink 的兼容问题
ffmpeg_exe = shutil.which("ffmpeg") shell_args = " ".join(shlex.quote(str(a)) for a in ffmpeg_args)
if not ffmpeg_exe:
raise RuntimeError("找不到 ffmpeg 可执行文件")
cmd = [process_name] + ffmpeg_args
proc = subprocess.Popen( proc = subprocess.Popen(
cmd, f"exec -a {shlex.quote(process_name)} ffmpeg {shell_args}",
executable=ffmpeg_exe, shell=True,
executable="/bin/bash",
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
) )
else: else:
cmd = ["ffmpeg"] + ffmpeg_args
proc = subprocess.Popen( proc = subprocess.Popen(
cmd, ["ffmpeg"] + ffmpeg_args,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
) )