FFmpeg
Loading...
Searching...
No Matches
af_whisper.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Vittorio Palmisano
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <stdio.h>
22#include <stdint.h>
23#include <stdlib.h>
24
25#include <whisper.h>
26
27#include "libavutil/avutil.h"
28#include "libavutil/opt.h"
30#include "libavutil/samplefmt.h"
32#include "libavfilter/audio.h"
33#include "libavutil/mem.h"
34#include "libavutil/avstring.h"
35#include "libavutil/internal.h"
36#include "libavformat/avio.h"
37#include "libavutil/thread.h"
38
39#include "formats.h"
40
77
78static void cb_log(enum ggml_log_level level, const char *text, void *user_data)
79{
82 switch (level) {
83 case GGML_LOG_LEVEL_ERROR:
85 break;
86 case GGML_LOG_LEVEL_WARN:
88 break;
89 }
90 av_log(ctx, av_log_level, "%s", text);
91}
92
94{
95 WhisperContext *wctx = ctx->priv;
96
97 static AVOnce init_static_once = AV_ONCE_INIT;
98 ff_thread_once(&init_static_once, ggml_backend_load_all);
99
100 whisper_log_set(cb_log, ctx);
101
102 // Init whisper context
103 if (!wctx->model_path) {
104 av_log(ctx, AV_LOG_ERROR, "No whisper model path specified. Use the 'model' option.\n");
105 return AVERROR(EINVAL);
106 }
107
108 struct whisper_context_params params = whisper_context_default_params();
109 params.use_gpu = wctx->use_gpu;
110 params.gpu_device = wctx->gpu_device;
111
112 wctx->ctx_wsp = whisper_init_from_file_with_params(wctx->model_path, params);
113 if (wctx->ctx_wsp == NULL) {
114 av_log(ctx, AV_LOG_ERROR, "Failed to initialize whisper context from model: %s\n", wctx->model_path);
115 return AVERROR(EIO);
116 }
117
118 // Init buffer
119 wctx->audio_buffer_queue_size = av_rescale(wctx->queue, WHISPER_SAMPLE_RATE, AV_TIME_BASE);
121 if (!wctx->audio_buffer)
122 return AVERROR(ENOMEM);
123
124 // Init VAD model context
125 if (wctx->vad_model_path) {
126 struct whisper_vad_context_params ctx_params = whisper_vad_default_context_params();
127 ctx_params.n_threads = ff_filter_get_nb_threads(ctx);
128 // ctx_params.use_gpu = wctx->use_gpu; TODO (see: whisper_vad_init_context)
129 ctx_params.gpu_device = wctx->gpu_device;
130 wctx->ctx_vad = whisper_vad_init_from_file_with_params(wctx->vad_model_path, ctx_params);
131
132 wctx->vad_params = whisper_vad_default_params();
133 wctx->vad_params.threshold = wctx->vad_threshold;
134 wctx->vad_params.min_speech_duration_ms = av_rescale(wctx->vad_min_speech_duration, 1000, AV_TIME_BASE);
135 wctx->vad_params.min_silence_duration_ms = av_rescale(wctx->vad_min_silence_duration, 1000, AV_TIME_BASE);
136 wctx->vad_params.max_speech_duration_s = av_rescale(wctx->queue, 1, AV_TIME_BASE);
137 wctx->vad_params.speech_pad_ms = 0;
138 wctx->vad_params.samples_overlap = 0;
139 }
140
141 wctx->next_pts = AV_NOPTS_VALUE;
142
143 if (wctx->destination && strcmp("", wctx->destination)) {
144 const char *dst = wctx->destination;
145 if (!strcmp("-", dst))
146 dst = "pipe:1";
148
149 if (ret < 0) {
150 av_log(ctx, AV_LOG_ERROR, "Could not open %s: %s\n", wctx->destination, av_err2str(ret));
151 return ret;
152 }
153
155 }
156
157 // 'eval' and 'lock' both auto-detect; they differ only in whether the
158 // detected language is reused for the following chunks
159 const char *lang = wctx->language_str;
160 wctx->lock_language = !strcmp(lang, "lock");
161 if (wctx->lock_language || !strcmp(lang, "eval"))
162 lang = "auto";
163
164 if (!whisper_is_multilingual(wctx->ctx_wsp)) {
165 if (!wctx->translate && strcmp(lang, "auto") == 0) {
167 "Multilingual model not provided. Non-English audio may not be correctly transcribed.\n");
168 } else if (wctx->translate || (strcmp(lang, "auto") != 0 && strcmp(lang, "en") != 0)) {
170 "%s requested but multilingual model not provided.\n", wctx->translate ? "Translation" : "Transcription");
171 return AVERROR(ENOSYS);
172 }
173 wctx->language = "en";
174 } else
175 wctx->language = lang;
176
178 "Whisper filter initialized: model: %s lang: %s queue: %" PRId64 " ms\n",
179 wctx->model_path, wctx->language, wctx->queue / 1000);
180
181 return 0;
182}
183
185{
186 WhisperContext *wctx = ctx->priv;
187
188 if (wctx->audio_buffer_fill_size > 0) {
190 "Remaining audio buffer %d samples (%d seconds) after stopping\n",
191 wctx->audio_buffer_fill_size, wctx->audio_buffer_fill_size / WHISPER_SAMPLE_RATE);
192 }
193
194 if (wctx->ctx_vad) {
195 whisper_vad_free(wctx->ctx_vad);
196 wctx->ctx_vad = NULL;
197 }
198
199 if (wctx->ctx_wsp) {
200 whisper_free(wctx->ctx_wsp);
201 wctx->ctx_wsp = NULL;
202 }
203
204 av_freep(&wctx->audio_buffer);
206
207 if (wctx->avio_context)
209}
210
212{
213 WhisperContext *wctx = ctx->priv;
214 samples = FFMAX(0, FFMIN(samples, wctx->audio_buffer_fill_size));
215
216 if (!wctx->ctx_wsp || samples == 0)
217 return;
218
219 const int64_t timestamp_ms = wctx->audio_buffer_start_ms;
220 const float duration = (float) samples / WHISPER_SAMPLE_RATE;
221
223 "run transcription at %" PRId64 " ms, %d/%d samples (%.2f seconds)...\n",
224 timestamp_ms, samples, wctx->audio_buffer_fill_size, duration);
225
226 struct whisper_full_params params = whisper_full_default_params(WHISPER_SAMPLING_GREEDY);
227 params.language = wctx->language;
228 params.translate = wctx->translate;
230 params.print_special = 0;
231 params.print_progress = 0;
232 params.print_realtime = 0;
233 params.print_timestamps = 0;
234 params.max_len = wctx->max_len;
235 params.token_timestamps = (wctx->max_len > 0);
236 params.split_on_word = (wctx->max_len > 0);
237
238 if (whisper_full(wctx->ctx_wsp, params, wctx->audio_buffer, samples) != 0) {
239 av_log(ctx, AV_LOG_ERROR, "Failed to process audio with whisper.cpp\n");
240 return;
241 }
242
243 const int lang_id = whisper_full_lang_id(wctx->ctx_wsp);
244 const char *detected_language = lang_id >= 0 ? whisper_lang_str(lang_id) : NULL;
245 const int n_segments = whisper_full_n_segments(wctx->ctx_wsp);
246 char *segments_text = NULL;
247
248 for (int i = 0; i < n_segments; ++i) {
249 const char *text = whisper_full_get_segment_text(wctx->ctx_wsp, i);
250 if (av_isspace(text[0]))
251 text++;
252 char *text_cleaned = av_strireplace(text, "[BLANK_AUDIO]", "");
253
254 if (av_strnlen(text_cleaned, 1) == 0) {
255 av_freep(&text_cleaned);
256 continue;
257 }
258
259 // Skip segments that are parts of [BLANK_AUDIO] when max_len splits them
260 if (wctx->max_len > 0 && (strcmp(text_cleaned, "[") == 0 || strcmp(text_cleaned, "]") == 0 ||
261 strcmp(text_cleaned, "BLANK") == 0 || strcmp(text_cleaned, "_") == 0 ||
262 strcmp(text_cleaned, "AUDIO") == 0)) {
263 av_freep(&text_cleaned);
264 continue;
265 }
266
267 const bool turn = whisper_full_get_segment_speaker_turn_next(wctx->ctx_wsp, i);
268 const int64_t t0_ms = whisper_full_get_segment_t0(wctx->ctx_wsp, i) * 10;
269 const int64_t t1_ms = whisper_full_get_segment_t1(wctx->ctx_wsp, i) * 10;
270
271 av_log(ctx, AV_LOG_DEBUG, " [%" PRId64 "-%" PRId64 "%s]: \"%s\"\n",
272 timestamp_ms + t0_ms, timestamp_ms + t1_ms, turn ? " (turn)" : "", text_cleaned);
273
274 if (segments_text) {
275 char *new_text = av_asprintf("%s%s", segments_text, text_cleaned);
276 av_freep(&segments_text);
277 segments_text = new_text;
278 } else
279 segments_text = av_strdup(text_cleaned);
280
281 if (wctx->avio_context) {
282 const int64_t start_t = timestamp_ms + t0_ms;
283 const int64_t end_t = timestamp_ms + t1_ms;
284 char *buf = NULL;
285
286 if (!av_strcasecmp(wctx->format, "srt")) {
287 buf =
289 ("%d\n%02" PRId64 ":%02" PRId64 ":%02" PRId64 ",%03" PRId64 " --> %02" PRId64 ":%02" PRId64 ":%02" PRId64 ",%03" PRId64 "\n%s\n\n",
290 wctx->index, start_t / 3600000,
291 (start_t / 60000) % 60, (start_t / 1000) % 60,
292 start_t % 1000, end_t / 3600000, (end_t / 60000) % 60,
293 (end_t / 1000) % 60, end_t % 1000, text_cleaned);
294
295 wctx->index++;
296 } else if (!av_strcasecmp(wctx->format, "json")) {
297 buf = av_asprintf("{\"start\":%" PRId64 ",\"end\":%" PRId64 ",\"text\":\"%s\",\"language\":\"%s\"}\n",
298 start_t, end_t, text_cleaned,
299 detected_language ? detected_language : "unknown");
300 } else
301 buf = av_asprintf("%s\n", text_cleaned);
302
303 if (buf) {
304 avio_write(wctx->avio_context, buf, strlen(buf));
305 av_freep(&buf);
306 }
307 }
308
309 av_freep(&text_cleaned);
310 }
311
312 if (wctx->lock_language && segments_text && !av_strcasecmp(wctx->language, "auto")) {
313 const int lang_id = whisper_full_lang_id(wctx->ctx_wsp);
314 if (lang_id >= 0) {
315 char *detected = av_strdup(whisper_lang_str(lang_id));
316 if (detected) {
317 wctx->locked_language = detected;
318 wctx->language = detected;
319 av_log(ctx, AV_LOG_INFO, "Locked auto-detected language: %s\n", detected);
320 }
321 }
322 }
323
324 AVDictionary **metadata = &frame->metadata;
325 if (metadata && segments_text) {
326 av_dict_set(metadata, "lavfi.whisper.text", segments_text, 0);
327 char *duration_text = av_asprintf("%f", duration);
328 av_dict_set(metadata, "lavfi.whisper.duration", duration_text, AV_DICT_DONT_STRDUP_VAL);
329 }
330 av_freep(&segments_text);
331
332 if (wctx->audio_buffer_fill_size > samples) {
333 memcpy(wctx->audio_buffer, wctx->audio_buffer + samples,
334 (wctx->audio_buffer_fill_size - samples) * sizeof(*wctx->audio_buffer));
335 wctx->audio_buffer_start_ms += duration * 1000;
336 }
337 wctx->audio_buffer_fill_size -= samples;
339}
340
342{
343 AVFilterContext *ctx = inlink->dst;
344 WhisperContext *wctx = ctx->priv;
345 AVFilterLink *outlink = ctx->outputs[0];
346
347 const int samples = frame->nb_samples;
348 const float *input_data = (const float *) frame->data[0];
349
350 if (wctx->audio_buffer_fill_size + samples > wctx->audio_buffer_queue_size) {
352 }
353
354 if (!wctx->audio_buffer_fill_size)
356 (AVRational) {1000, 1},
357 (AVRational) {inlink->time_base.den, inlink->time_base.num});
358 memcpy(wctx->audio_buffer + wctx->audio_buffer_fill_size, input_data, samples * sizeof(*wctx->audio_buffer));
359 wctx->audio_buffer_fill_size += samples;
360
361 if (wctx->ctx_vad
363 av_rescale(wctx->vad_min_speech_duration + wctx->vad_min_silence_duration, WHISPER_SAMPLE_RATE, AV_TIME_BASE)) {
364 struct whisper_vad_segments *segments = whisper_vad_segments_from_samples(wctx->ctx_vad,
365 wctx->vad_params,
366 wctx->audio_buffer,
369
370 if (!segments) {
371 av_log(ctx, AV_LOG_ERROR, "failed to detect VAD\n");
372 } else {
373 int n_segments = whisper_vad_segments_n_segments(segments);
374
375 if (n_segments > 0) {
376 const float start_ms = whisper_vad_segments_get_segment_t0(segments, 0) * 10.0;
377 const float end_ms = whisper_vad_segments_get_segment_t1(segments, n_segments - 1) * 10.0;
378 int end_pos = (int) (end_ms * WHISPER_SAMPLE_RATE / 1000);
379
380 if (end_pos <= wctx->audio_buffer_fill_size -
381 av_rescale(wctx->vad_min_silence_duration, WHISPER_SAMPLE_RATE, AV_TIME_BASE)) {
383 "VAD detected %d segments, start: %.0f ms, end: %.0f ms (buffer: %d ms)\n",
384 n_segments, start_ms, end_ms, 1000 * wctx->audio_buffer_fill_size / WHISPER_SAMPLE_RATE);
385 run_transcription(ctx, frame, end_pos);
386 }
387 }
388
389 whisper_vad_free_segments(segments);
390 }
391 } else if (wctx->audio_buffer_fill_size >= wctx->audio_buffer_queue_size)
393
394 wctx->next_pts = frame->pts + av_rescale_q(samples, (AVRational) {
395 1, inlink->sample_rate}
396 , inlink->time_base);
397 return ff_filter_frame(outlink, frame);
398}
399
400static int push_last_frame(AVFilterLink *outlink)
401{
402 AVFilterContext *ctx = outlink->src;
403 WhisperContext *wctx = ctx->priv;
404 AVFrame *frame;
405 int n_out = 1;
406
407 if (ctx->is_disabled || wctx->audio_buffer_fill_size == 0)
408 return 0;
409 frame = ff_get_audio_buffer(outlink, n_out);
410 if (!frame)
411 return AVERROR(ENOMEM);
412
413 av_samples_set_silence(frame->extended_data, 0, n_out, frame->ch_layout.nb_channels, frame->format);
414
415 frame->pts = wctx->next_pts;
416 if (wctx->next_pts != AV_NOPTS_VALUE)
417 wctx->next_pts += av_rescale_q(n_out, (AVRational) {
418 1, outlink->sample_rate}
419 , outlink->time_base);
420
422
423 return ff_filter_frame(outlink, frame);
424}
425
427{
428 AVFilterLink *inlink = ctx->inputs[0];
429 AVFilterLink *outlink = ctx->outputs[0];
430 WhisperContext *wctx = ctx->priv;
431 int64_t pts;
432 int status;
433
434 FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
435
436 if (!wctx->eof && ff_inlink_queued_frames(inlink)) {
437 AVFrame *frame = NULL;
438 int ret;
439
441 if (ret < 0)
442 return ret;
443 if (ret > 0)
444 return filter_frame(inlink, frame);
445 }
446
447 if (!wctx->eof && ff_inlink_acknowledge_status(inlink, &status, &pts))
448 wctx->eof = status == AVERROR_EOF;
449
450 if (wctx->eof) {
451 push_last_frame(outlink);
452
454 return 0;
455 }
456
457 FF_FILTER_FORWARD_WANTED(outlink, inlink);
458
459 return FFERROR_NOT_READY;
460}
461
463 AVFilterFormatsConfig **cfg_in,
464 AVFilterFormatsConfig **cfg_out)
465{
467 AVChannelLayout chlayouts[] = { FF_COUNT2LAYOUT(1), { 0 } };
468 int sample_rates[] = { WHISPER_SAMPLE_RATE, -1 };
469 int ret;
470
472 if (ret < 0)
473 return ret;
474
475 ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, chlayouts);
476 if (ret < 0)
477 return ret;
478
479 return ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, sample_rates);
480}
481
482#define OFFSET(x) offsetof(WhisperContext, x)
483#define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
484#define HOURS 3600000000
485
486static const AVOption whisper_options[] = {
487 { "model", "Path to the whisper.cpp model file", OFFSET(model_path), AV_OPT_TYPE_STRING,.flags = FLAGS },
488 { "language", "Language for transcription ('auto', 'eval' or 'lock' for auto-detect)", OFFSET(language_str), AV_OPT_TYPE_STRING, {.str = "auto"}, .flags = FLAGS },
489 { "translate", "Translate from source language to English", OFFSET(translate), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, .flags = FLAGS },
490 { "queue", "Audio queue size", OFFSET(queue), AV_OPT_TYPE_DURATION, {.i64 = 3000000}, 20000, HOURS, .flags = FLAGS },
491 { "use_gpu", "Use GPU for processing", OFFSET(use_gpu), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, .flags = FLAGS },
492 { "gpu_device", "GPU device to use", OFFSET(gpu_device), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, .flags = FLAGS },
493 { "destination", "Output destination", OFFSET(destination), AV_OPT_TYPE_STRING, {.str = ""}, .flags = FLAGS },
494 { "format", "Output format (text|srt|json)", OFFSET(format), AV_OPT_TYPE_STRING, {.str = "text"},.flags = FLAGS },
495 { "max_len", "Max segment length in characters", OFFSET(max_len), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, .flags = FLAGS },
496 { "vad_model", "Path to the VAD model file", OFFSET(vad_model_path), AV_OPT_TYPE_STRING,.flags = FLAGS },
497 { "vad_threshold", "VAD threshold", OFFSET(vad_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 0.5}, 0.0, 1.0, .flags = FLAGS },
498 { "vad_min_speech_duration", "Minimum speech duration for VAD", OFFSET(vad_min_speech_duration), AV_OPT_TYPE_DURATION, {.i64 = 100000}, 20000, HOURS, .flags = FLAGS },
499 { "vad_min_silence_duration", "Minimum silence duration for VAD", OFFSET(vad_min_silence_duration), AV_OPT_TYPE_DURATION, {.i64 = 500000}, 0, HOURS, .flags = FLAGS },
500 { NULL }
501};
502
503static const AVClass whisper_class = {
504 .class_name = "whisper",
505 .item_name = av_default_item_name,
506 .option = whisper_options,
507 .version = LIBAVUTIL_VERSION_INT,
508};
509
511 .p.name = "whisper",
512 .p.description = NULL_IF_CONFIG_SMALL("Transcribe audio using whisper.cpp."),
513 .p.priv_class = &whisper_class,
515 .init = init,
516 .uninit = uninit,
517 .activate = activate,
518 .priv_size = sizeof(WhisperContext),
522};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:97
SwsAArch64OpImplParams params
Definition ops.c:52
static enum AVSampleFormat sample_fmts[]
Definition adpcmenc.c:933
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
static const char *const format[]
Definition af_aiir.c:445
const FFFilter ff_af_whisper
Definition af_whisper.c:510
#define HOURS
Definition af_whisper.c:484
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition af_whisper.c:341
static void uninit(AVFilterContext *ctx)
Definition af_whisper.c:184
static const AVOption whisper_options[]
Definition af_whisper.c:486
static const AVClass whisper_class
Definition af_whisper.c:503
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition af_whisper.c:462
static int activate(AVFilterContext *ctx)
Definition af_whisper.c:426
#define OFFSET(x)
Definition af_whisper.c:482
static void run_transcription(AVFilterContext *ctx, AVFrame *frame, int samples)
Definition af_whisper.c:211
static void cb_log(enum ggml_log_level level, const char *text, void *user_data)
Definition af_whisper.c:78
static int push_last_frame(AVFilterLink *outlink)
Definition af_whisper.c:400
static AVFormatContext * ctx
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
Definition audio.c:34
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition audio.c:74
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition avfilter.c:1474
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1079
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
Definition avfilter.c:1490
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition avfilter.c:857
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition avfilter.c:1527
Main libavfilter public API header.
int avio_open(AVIOContext **s, const char *filename, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
Definition avio.c:573
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
Definition avio.c:725
Buffered I/O operations.
#define AVIO_FLAG_WRITE
write-only
Definition avio.h:631
#define AVIO_FLAG_DIRECT
Use direct mode.
Definition avio.h:657
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition aviobuf.c:206
char * av_asprintf(const char *fmt,...)
Definition avstring.c:115
Convenience header that includes libavutil's core.
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
static int FUNC user_data(CodedBitstreamContext *ctx, RWContext *rw, MPEG2RawUserData *current)
Public libavutil channel layout APIs header.
#define FLAGS
Definition cmdutils.c:596
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static const int sample_rates[]
Definition dcaenc.h:34
static AVFrame * frame
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:613
static int64_t duration
Definition ffplay.c:359
int ret
Definition ffplay.c:391
int ff_set_common_samplerates_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const int *samplerates)
Definition formats.c:1088
int ff_set_common_channel_layouts_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const AVChannelLayout *fmts)
Definition formats.c:1064
int ff_set_sample_formats_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const enum AVSampleFormat *fmts)
Definition formats.c:1217
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition formats.h:102
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
Definition opt.h:318
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition avfilter.h:188
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
Definition dict.h:79
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition dict.c:87
#define AVERROR_EOF
End of file.
Definition error.h:57
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition error.h:122
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:247
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
AVSampleFormat
Audio sample formats.
Definition samplefmt.h:55
@ AV_SAMPLE_FMT_FLT
float
Definition samplefmt.h:60
@ AV_SAMPLE_FMT_NONE
Definition samplefmt.h:56
int av_samples_set_silence(uint8_t *const *audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
Definition samplefmt.c:247
size_t static size_t av_strnlen(const char *s, size_t len)
Get the count of continuous non zero chars starting from the beginning.
Definition avstring.h:141
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition avstring.c:208
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
Definition avstring.h:218
char * av_strireplace(const char *str, const char *from, const char *to)
Locale-independent strings replace.
Definition avstring.c:230
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
#define AV_TIME_BASE
Internal time base represented as integer.
Definition avutil.h:253
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:279
#define FILTER_OUTPUTS(array)
Definition filters.h:280
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
Definition filters.h:720
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition filters.h:655
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
Definition filters.h:34
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition filters.h:665
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:256
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
#define AVOnce
Definition thread.h:202
static int ff_thread_once(char *control, void(*routine)(void))
Definition thread.h:205
#define AV_ONCE_INIT
Definition thread.h:203
static atomic_int av_log_level
Definition log.c:59
#define FFMIN(a, b)
Definition macros.h:49
#define FFMAX(a, b)
Definition macros.h:47
Memory handling functions.
static void input_data(MLPEncodeContext *ctx, MLPSubstream *s, uint8_t **const samples, int nb_samples)
Wrapper function for inputting data in two different bit-depths.
Definition mlpenc.c:1219
#define av_strdup(s)
Definition ops_static.c:55
AVOptions.
An AVChannelLayout holds information about the channel layout of audio data.
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:279
Lists of formats / etc.
Definition avfilter.h:120
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
Bytestream IO Context.
Definition avio.h:160
int direct
avio_read and avio_write should if possible be satisfied directly instead of going through a buffer,...
Definition avio.h:268
AVOption.
Definition opt.h:428
Rational number (pair of numerator and denominator).
Definition rational.h:58
int audio_buffer_queue_size
Definition af_whisper.c:66
struct whisper_vad_params vad_params
Definition af_whisper.c:63
char * model_path
Definition af_whisper.c:43
char * destination
Definition af_whisper.c:57
int audio_buffer_vad_size
Definition af_whisper.c:68
char * language_str
Definition af_whisper.c:45
int64_t next_pts
Definition af_whisper.c:72
int64_t audio_buffer_start_ms
Definition af_whisper.c:69
char * locked_language
Definition af_whisper.c:46
struct whisper_context * ctx_wsp
Definition af_whisper.c:61
char * vad_model_path
Definition af_whisper.c:51
int64_t vad_min_silence_duration
Definition af_whisper.c:54
float * audio_buffer
Definition af_whisper.c:65
struct whisper_vad_context * ctx_vad
Definition af_whisper.c:62
int64_t vad_min_speech_duration
Definition af_whisper.c:53
int audio_buffer_fill_size
Definition af_whisper.c:67
const char * language
Definition af_whisper.c:44
AVIOContext * avio_context
Definition af_whisper.c:74
float vad_threshold
Definition af_whisper.c:52
int64_t queue
Definition af_whisper.c:56
uint8_t level
Definition svq3.c:208
#define av_malloc_array(a, b)
#define av_freep(p)
#define av_log(a,...)
AVThreadMessageQueue * queue
Definition swscale.c:148
static int64_t pts