Fix: skip soxr resampler if loudnorm is present
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 16 Jan 2025 20:30:13 +0000 (21:30 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 16 Jan 2025 20:30:13 +0000 (21:30 +0100)
Due to a bug in ffmpeg

music_assistant/helpers/ffmpeg.py

index ebcd70bb7ea7aa492b2ff3d55e9eb5a310867a13..8ff24e84e73b19f2a140e404e2e8782bd929ed26 100644 (file)
@@ -311,8 +311,11 @@ def get_ffmpeg_args(  # noqa: PLR0915
         input_format.sample_rate != output_format.sample_rate
         or input_format.bit_depth > output_format.bit_depth
     ):
-        # prefer resampling with libsoxr due to its high quality
-        if libsoxr_support:
+        # prefer resampling with libsoxr due to its high quality (if its available)
+        # but skip libsoxr if loudnorm filter is present, due to this bug:
+        # https://trac.ffmpeg.org/ticket/11323
+        loudnorm_present = any("loudnorm" in f for f in filter_params)
+        if libsoxr_support and not loudnorm_present:
             resample_filter = "aresample=resampler=soxr:precision=30"
         else:
             resample_filter = "aresample=resampler=swr"