From 06334e5c05e62d56117dcb34ed01e23e20483abe Mon Sep 17 00:00:00 2001 From: berettavexee Date: Sun, 14 Jun 2026 21:12:28 +0200 Subject: [PATCH] fix(converter): fall back to native aac encoder when libfdk_aac unavailable libfdk_aac is not included in most standard FFmpeg builds. Detect availability once at import time and use the built-in aac encoder as fallback. Co-Authored-By: Claude Sonnet 4.6 --- streamrip/converter.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/streamrip/converter.py b/streamrip/converter.py index aa4aa2aa..9887e903 100644 --- a/streamrip/converter.py +++ b/streamrip/converter.py @@ -13,6 +13,18 @@ SAMPLING_RATES = {44100, 48000, 88200, 96000, 176400, 192000} +def _check_libfdk_aac() -> bool: + try: + import subprocess + result = subprocess.run( + ["ffmpeg", "-encoders"], capture_output=True, text=True, timeout=5 + ) + return "libfdk_aac" in result.stdout + except Exception: + return False + +_LIBFDK_AAC_AVAILABLE = _check_libfdk_aac() + class Converter: """Base class for audio codecs.""" @@ -261,8 +273,9 @@ def get_quality_arg(self, _: int) -> str: class AAC(Converter): - """Class for libfdk_aac converter. + """Class for AAC converter. + Uses libfdk_aac if available, falls back to the native FFmpeg aac encoder. Default ffmpeg_arg: `-b:a 256k`. See available options: @@ -270,7 +283,7 @@ class AAC(Converter): """ codec_name = "aac" - codec_lib = "libfdk_aac" + codec_lib = "libfdk_aac" if _LIBFDK_AAC_AVAILABLE else "aac" container = "m4a" default_ffmpeg_arg = "-b:a 256k"