0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

FFmpeg 8.0に追加されたWhisperを試してみる

Last updated at Posted at 2025-08-30

概要

2025/8/22にリリースされたFFmpeg 8.0でWhisper.cppがオーディオフィルタとしてサポートされるようになりました。
あまり使い方が広まっていないようなので、とりあえず試す人向けに簡単に紹介します。

  • すでにWhisperを使用している方にとっては、あえてFFmpeg内臓版を使うメリットはあまりないと考えます。
  • また、これから初めてWhisperを文字起こしを目的に使う方も、FFmpeg内臓のWhisperではなく、オリジナルのWhisperやその派生を使用するのをおすすめします。

準備

(Windows環境向けのみ記載します)

  1. FFmpeg
    公式サイトからWindowsアイコンを選び、Windows EXE Filesからffmpeg-release-essentials.7zをDLし、解凍・保存したディレクトリにパスを通しておきます。
  2. Whisper.cppモデル
    huggingface ggerganov/whisper.cppなどからWhisper.cppのモデルを一つDLします。CPUのみのPCで試す場合はggml-small.binなどが実用的に動く限界だと思います。VRAMが足りるGPUを積んでいればlargeモデルでも十分動きます。
    DLしたモデルは%UserProfile%\.cache\ffmpeg-whisperなどのフォルダを作りその中に保存します。(試してすぐ消す場合は文字起こし対象ファイルと同じディレクトリでも構いません。)

Whisper.cpp用のモデルであれば動きます。

(参考)Whisper.cppサイトからDLできるモデルは以下でした。
Model Disk
tiny 75 MiB
tiny.en 75 MiB
base 142 MiB
base.en 142 MiB
small 466 MiB
small.en 466 MiB
small.en-tdrz 465 MiB
medium 1.5 GiB
medium.en 1.5 GiB
large-v1 2.9 GiB
large-v2 2.9 GiB
large-v2-q5_0 1.1 GiB
large-v3 2.9 GiB
large-v3-q5_0 1.1 GiB
large-v3-turbo 1.5 GiB
large-v3-turbo-q5_0 547 MiB

モデル名に.enがついているものは英語のみ対応しているモデルのため、日本語の文字起こしをする場合は.enがついていないモデルを選択してください。

使い方

以下の環境例にてFFmpeg内蔵Whisperで動画を文字起こししてみます。

項目 パス
Whisper.cppモデル C:\Users\user\.cache\ffmpeg-whisper\ggml-small.bin
動画ファイル R:\test.mp4
出力字幕ファイル R:\test.srt

(.wav,.mp3など音声ファイルでも可能です)

本記事では例としてGoogleで「動画サンプル」で検索して上位に出てきた総務省の2.放送を視聴するために (約4分)動画を使用させていただきます。

FFmpegでのWhisperは、オーディオトラックを文字に変換するオーディオフィルタとして機能します。以下が動画のオーディオを文字起こししてsrtファイルとして出力する最も簡単なコマンドです。

実行コマンド
set INPUT=R:\\\\test.mp4
set OUTPUT=R\\:\\\\test.srt
set MODEL=C\\:\\\\Users\\\\user\\\\.cache\\\\ffmpeg-whisper\\\\ggml-small.bin

ffmpeg -i %INPUT% -vn -af "whisper=model=%MODEL%:destination=%OUTPUT%:format=srt" -f null -

¥のエスケープが多いのは、ffmpegのパーサに対してもエスケープが必要なためです。すべて同じフォルダ内において直打ちしたり、バッチファイル化すると多少楽になります。

上記を実行して出力されたtest.srtが以下です。

test.srt
0
00:00:00.000 --> 00:00:03.000
[Music]

1
00:00:02.986 --> 00:00:04.986
(音楽)

1
00:00:04.986 --> 00:00:05.986
臨場感

2
00:00:05.972 --> 00:00:08.972
なふれるきめこまやかなBSと

3
00:00:08.959 --> 00:00:11.959
110度CSによる4K 8Kを

4
00:00:11.946 --> 00:00:14.946
放送が2018年12月から

5
00:00:14.932 --> 00:00:16.932
いよいよスタートします
.
.
.
(略)
format=text例
test.txt
[Music](音楽)臨場感なふれるきめこまやかなBSと110度CSによる4K 8Kを放送が2018年12月からいよいよスタートします...(略)
format=json例
test.json
{"start":0,"end":3000,"text":"[Music]"}
{"start":2986,"end":4986,"text":"(音楽)"}
{"start":4986,"end":5986,"text":"臨場感"}
{"start":5972,"end":8972,"text":"なふれるきめこまやかなBSと"}
{"start":8959,"end":11959,"text":"110度CSによる4K 8Kを"}
{"start":11946,"end":14946,"text":"放送が2018年12月から"}
{"start":14932,"end":16932,"text":"いよいよスタートします"}
.
.
.
(略)

各種設定

FFmpegのサイトの説明を下記します。Whisper.cppのオプションがすべて使えるわけではなさそうです。
主な注意点は以下です。

  • languageは話し出しの部分で自動判定されるので基本はautoで使用します。jaにすると日本後に強制設定できます。ただし、日本語設定している状態で英語の音声を処理させると、Whisperは音声→英語文字起こし→日本語翻訳の処理を行ってしまい、英語のまま文字にならず文字起こしとして適さない場合があります。言語設定は確実にその言語以外はいっていないと事前に分かっているとき以外はauto推奨です。
  • queueは処理する区切り秒数です。デフォルトの3だと音声を3秒ごと区切って文字起こしされます。長くすると文書として整合性が高まりやすくなりますが、長すぎたり、区間中に複数の話者がいると精度が悪くなる傾向があります。
  • VADはまた手動でモデルを用意しないといけないのと、有効にしても最初と最後の無音を切る程度で録音環境によってはほとんど効果がないので試す程度の仕様では無効でよいでしょう。
  • destinationをファイルではなくhttpで指定して処理の都度POSTで送ることも可能です。
項目 説明
model The file path of the downloaded whisper.cpp model (mandatory).
language The language to use for transcription (’auto’ for auto-detect). Default value: "auto"
queue The maximum size that will be queued into the filter before processing the audio with whisper. Using a small value the audio stream will be processed more often, but the transcription quality will be lower and the required processing power will be higher. Using a large value (e.g. 10-20s) will produce more accurate results using less CPU (as using the whisper-cli tool), but the transcription latency will be higher, thus not useful to process real-time streams. Consider using the vad_model option associated with a large queue value. Default value: "3"
use_gpu If the GPU support should be enabled. Default value: "true"
gpu_device The GPU device index to use. Default value: "0"
destination If set, the transcription output will be sent to the specified file or URL (use one of the FFmpeg AVIO protocols); otherwise, the output will be logged as info messages. The output will also be set in the "lavfi.whisper.text" frame metadata. If the destination is a file and it already exists, it will be overwritten.
format The destination format string; it could be "text" (only the transcribed text will be sent to the destination), "srt" (subtitle format) or "json". Default value: "text"
vad_model Path to the VAD model file. If set, the filter will load an additional voice activity detection module (https://github.com/snakers4/silero-vad) that will be used to fragment the audio queue; use this option setting a valid path obtained from the whisper.cpp repository (e.g. "../whisper.cpp/models/ggml-silero-v5.1.2.bin") and increase the queue parameter to a higher value (e.g. 20).
vad_threshold The VAD threshold to use. Default value: "0.5"
vad_min_speech_duration The minimum VAD speaking duration. Default value: "0.1"
vad_min_silence_duration The minimum VAD silence duration. Default value: "0.5"

おまけ

FFmpeg便利機能

.srtファイルが有ればVLC等のプレイヤーで字幕を表示することが可能ですが、生成した字幕を動画に埋め込んで動画ファイル単体で取り扱えるようにもできます。
上記コマンドで.srtファイルを出力したあとで、以下を実行します。

mp4の字幕トラックに追加
set SRT=R:\\\\test.srt
set OUTPUT_W_S=R:\\\\test_w_subt.mp4
ffmpeg -i %INPUT% -i %SRT% -c copy -c:s mov_text %OUTPUT_W_S%

{B44FCDA3-896F-4FAC-B681-7B5B526D86AE}.png

もしくは

画像文字として動画に焼付け
set SRT=R\\:\\\\test.srt
set OUTPUT_W_ST=R:\\\\test_w_subt_hard.mp4
ffmpeg -i %INPUT% -vf subtitles=%SRT% %OUTPUT_W_ST%

{8C2DCBAC-E60A-4DBA-B980-F585C6384624}.png

その他FFmpegだけで出来る便利なことは多数あるので興味があれば調べてみてください。

文字起こし機能としての評価

現状のFFmpegのWhisperオーディオフィルタの所感です。

:white_check_mark: PythonもWhisperも入ってない環境で、モデル1ファイル追加だけでWhisperの文字起こしが可能。手軽とギリいえるかもしれない。
:white_check_mark: FFmpegのオーディオフィルタを重畳させ簡易ノイズキャンセルなどもプログラミング無しで実施可能。
:white_check_mark: 文字起こし結果を中継ツールにjsonで投げるなどしてリアルタイム字幕の情報源をプログラミング無しで作成可能。(受け側は作る必要あり)
:x: Whisperを単体で使うのと機能面で優位性があまり無い。
:x: モデルのDLが手動などWhisper.cppを用意するのと大差ない手間が必要。
:x: Temperature等Whisper.cppの細かい設定が現状できない(?)
:x: 話者分離や、Whisperがよくやらかす文字起こしミスの除去など、音声の前処理や文字の後処理をするなら最初からWhisper+Pythonなどのほうが扱いやすい。(Whisperは無音やノイズを拾って「ご視聴ありがとうございました」のような話してない文字を結果に入れてしまう)

そもそも最初からWhisperが部分的にFFmpegを使って動いているので、FFmpegにWhisperを統合しても文字起こしシステム全体としては特に劇的に変化は無いように思います。各自Pythonで前後処理を組みながらWhisperを使っていた人たちにとっては、FFmpeg内に入ってしまうとより不便なことのほうが多い印象です。
Whisper,Pythonをいじる人がいない、精度はこだわらないから、既存の動画をとにかく簡単に字幕付き動画にしたい、みたいなケースではバッチファイルにD&Dだけで動画作成完了でき便利かもしれません。(そのくらいしか用途が思いつきません)

ということで、現状Whisperを一切触ったことがない、FFmpegならわかる、の方がちょっと試してみるニーズくらいになるかと思いますが、その参考になれば幸いです。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?