PR #22742 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22742 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22742.patch
It should also not be set to an av_malloc'd one given it's not an exported option. Fixes issue #22741. >From c75a9c564575866fe10d2951879bc16dba8845eb Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Tue, 7 Apr 2026 13:27:57 -0300 Subject: [PATCH] avfilter/af_whisper: don't set an AVOption accessible field to read only memory It should also not be set to an av_malloc'd one given it's not an exported option. Fixes issue #22741. Signed-off-by: James Almer <[email protected]> --- libavfilter/af_whisper.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libavfilter/af_whisper.c b/libavfilter/af_whisper.c index aebf5c2d1a..36a9208cb9 100644 --- a/libavfilter/af_whisper.c +++ b/libavfilter/af_whisper.c @@ -42,6 +42,7 @@ typedef struct WhisperContext { const AVClass *class; char *model_path; char *language; + char *language_str; bool translate; bool use_gpu; int gpu_device; @@ -152,16 +153,20 @@ static int init(AVFilterContext *ctx) } if (!whisper_is_multilingual(wctx->ctx_wsp)) { - if (!wctx->translate && strcmp(wctx->language, "auto") == 0) { + if (!wctx->translate && strcmp(wctx->language_str, "auto") == 0) { av_log(ctx, AV_LOG_WARNING, "Multilingual model not provided. Non-English audio may not be correctly transcribed.\n"); - } else if (wctx->translate || (strcmp(wctx->language, "auto") != 0 && strcmp(wctx->language, "en") != 0)) { + } else if (wctx->translate || (strcmp(wctx->language_str, "auto") != 0 && strcmp(wctx->language_str, "en") != 0)) { av_log(ctx, AV_LOG_ERROR, "%s requested but multilingual model not provided.\n", wctx->translate ? "Translation" : "Transcription"); return AVERROR(ENOSYS); } - wctx->language = "en"; - } + wctx->language = av_strdup("en"); + } else + wctx->language = av_strdup(wctx->language_str); + + if (!wctx->language) + return AVERROR(ENOMEM); av_log(ctx, AV_LOG_INFO, "Whisper filter initialized: model: %s lang: %s queue: %" PRId64 " ms\n", @@ -191,6 +196,7 @@ static void uninit(AVFilterContext *ctx) } av_freep(&wctx->audio_buffer); + av_freep(&wctx->language); if (wctx->avio_context) avio_closep(&wctx->avio_context); @@ -457,7 +463,7 @@ static int query_formats(const AVFilterContext *ctx, static const AVOption whisper_options[] = { { "model", "Path to the whisper.cpp model file", OFFSET(model_path), AV_OPT_TYPE_STRING,.flags = FLAGS }, - { "language", "Language for transcription ('auto' for auto-detect)", OFFSET(language), AV_OPT_TYPE_STRING, {.str = "auto"}, .flags = FLAGS }, + { "language", "Language for transcription ('auto' for auto-detect)", OFFSET(language_str), AV_OPT_TYPE_STRING, {.str = "auto"}, .flags = FLAGS }, { "translate", "Translate from source language to English", OFFSET(translate), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, .flags = FLAGS }, { "queue", "Audio queue size", OFFSET(queue), AV_OPT_TYPE_DURATION, {.i64 = 3000000}, 20000, HOURS, .flags = FLAGS }, { "use_gpu", "Use GPU for processing", OFFSET(use_gpu), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, .flags = FLAGS }, -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
