From 807b6e921f663d84b2bf3c094b7493cf0fd7be0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20James?= Date: Wed, 26 Nov 2025 14:49:07 +0100 Subject: [PATCH] whisper-cpp: add FFmpeg support as detailed at https://github.com/ggml-org/whisper.cpp#ffmpeg-support-linux-only note: for whisper-server to work, it must be started with `--convert` (even for natively support formats, such as wav) --- pkgs/by-name/wh/whisper-cpp/package.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkgs/by-name/wh/whisper-cpp/package.nix b/pkgs/by-name/wh/whisper-cpp/package.nix index e54b0c4f5bd8..699e1cab4199 100644 --- a/pkgs/by-name/wh/whisper-cpp/package.nix +++ b/pkgs/by-name/wh/whisper-cpp/package.nix @@ -8,6 +8,7 @@ SDL2, wget, which, + ffmpeg, autoAddDriverRunpath, makeWrapper, nix-update-script, @@ -29,10 +30,13 @@ vulkan-loader, withSDL ? true, + + withFFmpegSupport ? false, }: assert metalSupport -> stdenv.hostPlatform.isDarwin; assert coreMLSupport -> stdenv.hostPlatform.isDarwin; +assert withFFmpegSupport -> stdenv.hostPlatform.isLinux; let # It's necessary to consistently use backendStdenv when building with CUDA support, @@ -108,6 +112,7 @@ effectiveStdenv.mkDerivation (finalAttrs: { buildInputs = optional withSDL SDL2 + ++ optional withFFmpegSupport ffmpeg ++ optionals cudaSupport cudaBuildInputs ++ optionals rocmSupport rocmBuildInputs ++ optionals vulkanSupport vulkanBuildInputs; @@ -122,6 +127,9 @@ effectiveStdenv.mkDerivation (finalAttrs: { (cmakeBool "GGML_NATIVE" false) (cmakeBool "BUILD_SHARED_LIBS" (!effectiveStdenv.hostPlatform.isStatic)) ] + ++ optionals effectiveStdenv.hostPlatform.isLinux [ + (cmakeBool "WHISPER_FFMPEG" withFFmpegSupport) + ] ++ optionals (effectiveStdenv.hostPlatform.isx86 && !effectiveStdenv.hostPlatform.isStatic) [ (cmakeBool "GGML_BACKEND_DL" true) (cmakeBool "GGML_CPU_ALL_VARIANTS" true) @@ -156,6 +164,10 @@ effectiveStdenv.mkDerivation (finalAttrs: { wrapProgram "$out/bin/whisper-cpp-download-ggml-model" \ --prefix PATH : ${lib.makeBinPath [ wget ]} + '' + + lib.optionalString withFFmpegSupport '' + wrapProgram "$out/bin/whisper-server" \ + --prefix PATH : ${lib.makeBinPath [ ffmpeg ]} ''; requiredSystemFeatures = optionals rocmSupport [ "big-parallel" ]; # rocmSupport multiplies build time by the number of GPU targets, which takes arround 30 minutes on a 16-cores system to build