This commit is contained in:
eric
2026-03-19 13:46:02 -05:00
parent f0b1f9cf47
commit 77969c85fe
4 changed files with 132 additions and 5 deletions

View File

@@ -184,9 +184,13 @@ def start_douyin_youtube_ffplay(
if os.path.isfile(_p):
_arnndn_model = os.path.normpath(_p)
break
_ffmpeg_cwd = None
if _arnndn_model:
print(f"[INFO] 使用 RNNoise 降噪模型: {_arnndn_model}")
_af_denoise = f"arnndn=m={_arnndn_model}:mix=0.82,"
# 跨平台:用相对路径避免 Windows 下 C: 冒号破坏 FFmpeg 滤镜解析FFmpeg 以模型所在父目录为 cwd
_arnndn_base = os.path.dirname(os.path.dirname(os.path.abspath(_arnndn_model)))
_af_denoise = "arnndn=m=arnndn-models/cb.rnnn:mix=0.82,"
_ffmpeg_cwd = _arnndn_base
else:
print("[INFO] 未找到 arnndn 模型,使用 afftdn 降噪(可克隆 richardpl/arnndn-models 到 arnndn-models/")
_af_denoise = "afftdn=nf=-26:tn=1,"
@@ -254,15 +258,17 @@ def start_douyin_youtube_ffplay(
stderr_q = queue.Queue()
print(f"[INFO][{datetime.datetime.now():%H:%M:%S}] 启动 YouTube 推流 → {stream_title}")
proc = subprocess.Popen(
ffmpeg_command,
_popen_kw = dict(
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
text=True,
bufsize=1,
universal_newlines=True
universal_newlines=True,
)
if _ffmpeg_cwd:
_popen_kw["cwd"] = _ffmpeg_cwd
proc = subprocess.Popen(ffmpeg_command, **_popen_kw)
proc.last_out_ts = time.time()
reader_t = threading.Thread(target=_stderr_reader_thread, args=(proc, stderr_q))