From: Georgi Gerganov Date: Sun, 31 May 2026 12:48:05 +0000 (+0300) Subject: common : pass sample rate to `ffmpeg_decode_audio()` X-Git-Tag: upstream/1.9.2~284 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=6c343e7a4ed01a77be70cc4be2f5001cc72521e3;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp common : pass sample rate to `ffmpeg_decode_audio()` --- diff --git a/examples/common-whisper.cpp b/examples/common-whisper.cpp index 8cdd2320..c84e6843 100644 --- a/examples/common-whisper.cpp +++ b/examples/common-whisper.cpp @@ -36,7 +36,7 @@ #ifdef WHISPER_COMMON_FFMPEG // as implemented in ffmpeg-trancode.cpp only embedded in common lib if whisper built with ffmpeg support -extern bool ffmpeg_decode_audio(const std::string & ifname, std::vector & wav_data); +extern bool ffmpeg_decode_audio(const std::string & ifname, std::vector & wav_data, int out_sample_rate = WHISPER_SAMPLE_RATE); #endif // extract f32 PCM frames from an initialized decoder, downmix to mono and keep the stereo split diff --git a/examples/ffmpeg-transcode.cpp b/examples/ffmpeg-transcode.cpp index dc57fe74..7657af69 100644 --- a/examples/ffmpeg-transcode.cpp +++ b/examples/ffmpeg-transcode.cpp @@ -1,7 +1,5 @@ #ifdef WHISPER_COMMON_FFMPEG -#include "whisper.h" - #include #include #include @@ -44,7 +42,7 @@ static size_t wav_header_write(uint8_t * buf, int num_channels, int sample_rate, return 44; } -bool ffmpeg_decode_audio(const std::string & ifname, std::vector & wav_data) { +bool ffmpeg_decode_audio(const std::string & ifname, std::vector & wav_data, int out_sample_rate) { { const char * verbose = getenv("WHISPER_COMMON_FFMPEG_VERBOSE"); if (verbose && strcmp(verbose, "2") == 0) { @@ -116,7 +114,6 @@ bool ffmpeg_decode_audio(const std::string & ifname, std::vector & wav_ // Setup resampler: convert to 16-bit signed PCM, mono, 16000 Hz const enum AVSampleFormat out_sample_fmt = AV_SAMPLE_FMT_S16; - const int out_sample_rate = WHISPER_SAMPLE_RATE; AVChannelLayout out_ch_layout = AV_CHANNEL_LAYOUT_MONO;