Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions streamrip/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -261,16 +273,17 @@ 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:
https://trac.ffmpeg.org/wiki/Encode/AAC
"""

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"

Expand Down