A while back, Whisper support was added to ffmpeg to enable generation of subtitles from video files. There is a whisper-cpp ebuild in Gentoo’s GURU overlay, but the ffmpeg ebuild in the main Portage overlay doesn’t use it and just sets --disable-whisper all the time at build time. As far as I can tell, the main reason for this is that the whisper-cpp ebuild, as it stands as of this writing, doesn’t drop the necessary pkg-config configuration into /etc/env.d/. This leaves ffmpeg unable to find whisper-cpp at build time…see this Gentoo Forums thread for more info.
I have modified ebuilds for whisper-cpp and ffmpeg in my overlay. If you don’t already have it enabled, it’s easy to add:
sudo eselect repository enable salfter && sudo emaint sync -r salfter
My home workstation has a GeForce GTX 1070 installed…maybe a bit behind the times, but it gets the job done. Before continuing, newer versions of nvidia-drivers and nvidia-cuda-toolkit need to be masked, as they require newer GPUs than mine. (If you have something newer, you can skip this step.) Add the following to /etc/portage/package.mask/nvidia-drivers:
>=x11-drivers/nvidia-drivers-581
and add the following to /etc/portage/package.mask/nvidia-cuda-toolkit:
>=dev-util/nvidia-cuda-toolkit-13
ffmpeg needs to be configured to use Whisper. Make sure this is in /etc/portage/package.use/ffmpeg:
media-video/ffmpeg whisper
whisper-cpp also needs some configuration, in /etc/portage/package.use/whisper-cpp:
app-accessibility/whisper-cpp -opencl cuda ffmpeg AMDGPU_TARGETS: -*
sci-libs/clblast -opencl
(I found that the GPU wouldn’t be detected properly if OpenCL was enabled. Disabling it forces whisper-cpp to use CUDA instead.)
With those preliminaries out of the way, make sure the system is brought up to date with the changed configuration:
sudo emerge -auNDv --with-bdeps=y @world
If you already had ffmpeg installed, whisper-cpp and its dependencies (including nvidia-cuda-toolkit) should have been built and then ffmpeg should’ve been rebuilt. Otherwise, just build it:
sudo emerge -av ffmpeg
Once it’s installed, download some models and follow the examples provided here to get started with subtitling your videos.