Safer ffmpeg kill, POST process/service actions, ARM encoder from hardware.env, filter_threads scaling
Made-with: Cursor
This commit is contained in:
@@ -145,15 +145,33 @@ def build_profile() -> dict:
|
||||
return profile
|
||||
|
||||
|
||||
def suggest_video_encoder(profile: dict) -> str:
|
||||
"""在 Linux 上根据 ffmpeg 能力与探测结果给出可选硬件编码器名(供 douyin→YouTube 读取 LIVE_VIDEO_ENCODER)。"""
|
||||
text = run_text(["ffmpeg", "-hide_banner", "-encoders"])
|
||||
if not text:
|
||||
return ""
|
||||
hwaccels = set(profile.get("ffmpeg_hwaccels") or [])
|
||||
if "h264_rkmpp" in text and Path("/dev/mpp_service").exists():
|
||||
return "h264_rkmpp"
|
||||
if "h264_v4l2m2m" in text and "v4l2m2m" in hwaccels:
|
||||
return "h264_v4l2m2m"
|
||||
return ""
|
||||
|
||||
|
||||
def write_outputs(profile: dict) -> None:
|
||||
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
||||
JSON_PATH.write_text(json.dumps(profile, indent=2, ensure_ascii=False), encoding="utf-8")
|
||||
enc = suggest_video_encoder(profile)
|
||||
env_lines = [
|
||||
f"LIVE_HW_DECODER={profile['recommendation']['video_decoder']}",
|
||||
f"LIVE_HDMI_PLAYER={profile['recommendation']['hdmi_player']}",
|
||||
f"LIVE_BROWSER_HWACCEL={profile['recommendation']['browser_hwaccel']}",
|
||||
f"LIVE_STABILITY_MODE={profile['recommendation']['stability_mode']}",
|
||||
]
|
||||
if enc:
|
||||
env_lines.append(f"LIVE_VIDEO_ENCODER={enc}")
|
||||
else:
|
||||
env_lines.append("# LIVE_VIDEO_ENCODER= # optional: h264_v4l2m2m / h264_rkmpp when ffmpeg supports it")
|
||||
ENV_PATH.write_text("\n".join(env_lines) + "\n", encoding="utf-8")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user