Skip to content

Whisper Language Detection

Phillippe Pelzer edited this page Nov 24, 2026 · 3 revisions

whisper language detection

The whisper filter transcribes speech with whisper.cpp. The filter itself is upstream FFmpeg. The upstream filter documentation is at ffmpeg.org/ffmpeg-filters.html#whisper.

This page covers one NoMercy patch: the filter reports which language it detected, and how sure it is. Upstream FFmpeg does not expose that.

The word-level timestamps, the prompt and beam search are a second patch. They have their own page: Whisper-Word-Timestamps.

Since: v1.0.39. The language field on every JSON line and the eval and lock modes are FFmpeg 9.1's own additions. They are in since v1.0.50.

Quick example

# Print the detected language as frame metadata
ffmpeg -i speech.wav -af "whisper=model=ggml-base.bin:use_gpu=0,ametadata=mode=print:file=-" -f null -

# Write it into the JSON output instead
ffmpeg -i speech.wav -af "whisper=model=ggml-base.bin:format=json:destination=-" -f null -

Where the result appears

Where What you get
Frame metadata lavfi.whisper.language The language code, for example en.
Frame metadata lavfi.whisper.language_confidence A number from 0 to 1.
format=json output, first line {"detected_language":"en","language_confidence":1.000000}: the language of the stream.
format=json output, every segment line A "language" field: the language whisper used for that window. Since v1.0.50.
The log (info level) detected language: en (confidence: 1.000000).

The metadata keys are set on every frame that carries a transcript. The detected_language line is written once, before the first segment.

The outputs were checked on v1.0.50 with the multilingual model ggml-tiny.bin:

{"detected_language":"en","language_confidence":0.958424}
{"start":0,"end":2000,"text":"And so my fellow Americans!","language":"en"}

The stream-level line and the per-line field can differ. With language=auto or eval, whisper.cpp decides the language again for every window, so a line can name another language than the first line does.

How the language is decided

Situation Result Confidence
You set language=<code> That code. Nothing is detected. 1.0
An English-only model (*.en) with language=auto en. These models cannot detect a language. 1.0
A multilingual model with language=auto (the default), eval or lock The language whisper.cpp picks. The probability whisper.cpp gives that language.

This detection runs once per filter instance. It costs one extra encoder pass. It gives the first JSON line, the metadata keys and the log line.

All three rows were run on v1.0.50, with ggml-tiny.en.bin and ggml-tiny.bin on an English clip.

The three automatic modes

language= What happens per window
auto (the default) whisper.cpp detects the language again for every window.
eval The same as auto. It is FFmpeg 9.1's name for it.
lock The language detected once is used for the rest of the stream. The log says Locked auto-detected language: en.

Use lock for a stream in one language. A window with little speech then cannot flip to another language.

Upstream FFmpeg locks on the first window that has text. This build locks on the language of the stream-level detection, so the first JSON line and the locked language are always the same.

Options

The patch adds no options. It uses the existing language option.

Option Type Default What it does
language string auto Language for transcription: a language code, or auto, eval or lock to detect it.

The full list of filter options is in ffmpeg -h filter=whisper.

Related metadata

The same patched filter sets two more keys. They tell you what the run really used.

Key Meaning
lavfi.whisper.backend The backend that ran: cpu, or the GPU backend. It reports what ran, not what you asked for.
lavfi.whisper.cpu_variant The CPU instruction-set variant ggml chose. See CPU-Instruction-Sets.

For GPU use, see GPU-Acceleration.

Platform notes

The whisper filter is in every platform archive. You need a ggml model file. The release archives do not contain one. Get whisper.cpp models from https://huggingface.co/ggerganov/whisper.cpp.

Clone this wiki locally