From c8e9eb6fd2aa17fd7bc81be6ce82b3193a946159 Mon Sep 17 00:00:00 2001 From: JB Date: Mon, 6 Oct 2025 17:05:50 -0700 Subject: [PATCH] feat: Update audio sink to manage ffmpeg cache by platform --- abogen/web/conversion_runner.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/abogen/web/conversion_runner.py b/abogen/web/conversion_runner.py index b9c76ad..37bb02e 100644 --- a/abogen/web/conversion_runner.py +++ b/abogen/web/conversion_runner.py @@ -5,6 +5,7 @@ import math import os import re import subprocess +import sys from contextlib import ExitStack from dataclasses import dataclass from pathlib import Path @@ -312,16 +313,17 @@ def _open_audio_sink( fmt: Optional[str] = None, metadata: Optional[Dict[str, str]] = None, ) -> AudioSink: - ffmpeg_cache = get_internal_cache_path("ffmpeg") - os.makedirs(ffmpeg_cache, exist_ok=True) + ffmpeg_cache_root = get_internal_cache_path("ffmpeg") + platform_cache = os.path.join(ffmpeg_cache_root, sys.platform) + os.makedirs(platform_cache, exist_ok=True) try: import static_ffmpeg.run as static_ffmpeg_run # type: ignore - static_ffmpeg_run.LOCK_FILE = os.path.join(ffmpeg_cache, "lock.file") + static_ffmpeg_run.LOCK_FILE = os.path.join(ffmpeg_cache_root, "lock.file") except Exception: pass - static_ffmpeg.add_paths(download_dir=ffmpeg_cache) + static_ffmpeg.add_paths(weak=True, download_dir=platform_cache) fmt_value = (fmt or job.output_format).lower() if fmt_value in {"wav", "flac"}: