How do I enable NVDEC in MPV/Celluloid on Silverblue?

I’m running Fedora Silverblue 41. Here are my packages:

rpm-ostree status
State: idle
Deployments:
● fedora:fedora/41/x86_64/silverblue
                  Version: 41.20241203.0 (2024-12-03T02:08:54Z)
               BaseCommit: 041c69aa9a95a4590dc5c9a72da480dc92f45a8639604e2ba389368a58c4b9fe
             GPGSignature: Valid signature by 466CF2D8B60BC3057AA9453ED0622462E99D6AD1
          LayeredPackages: akmod-nvidia libva-nvidia-driver steam xorg-x11-drv-nvidia-cuda-libs
            LocalPackages: rpmfusion-free-release-41-1.noarch rpmfusion-nonfree-release-41-1.noarch

I have a NVIDIA RTX card along with an Intel CPU/iGPU on my laptop. I would like to use the NVIDIA card for hardware decoding.

I am using Resources to watch GPU usage, and no matter what settings I set in Celluloid’s mpv.conf, I never see any usage on the NVIDIA card.

I have tried:

hwdec=auto
hwdec=nvdec
hwdec=cuda

In combination with:

vo=gpu

Desperate, I also tried:

flatpak run --command=sh io.github.celluloid_player.Celluloid

mpv --no-config --hwdec=nvdec video.webm

Which gave me this error:

[vo/gpu/cuda] cu->cuGLGetDevices(&device_count, &display_dev, 1, CU_GL_DEVICE_LIST_ALL) failed -> CUDA_ERROR_INVALID_GRAPHICS_CONTEXT: invalid OpenGL or DirectX context
[vo/gpu/cuda] CUDA hwdec only works with OpenGL or Vulkan backends

Which makes it seem like CUDA is failing to probe devices or something?

I’m on the verge of giving up and going back to NVK. Am I missing a package?

Wayland, by the way.

The only way I could get this to work was following the advice in this issue tracker: hwdec=nvdec fails: invalid OpenGL context · Issue #10839 · mpv-player/mpv · GitHub

I’ve never seen this before. That call relies on implicit OpenGL and cuda state, and if it doesn’t work, there’s not much we can do. Your logs appear to show nvidia’s OpenGL initialising correctly, but this kind of failure might indicate incorrectly installed GL or nvidia libraries.

You can also try with --gpu-api=vulkan

When using this option together with --hwdec=nvdec, my CPU’s iGPU is no longer maxed out, the video doesn’t drop any frames, and I can navigate my desktop without slowness. Mpv says it’s using hardware video decoding with nvdec. So, mission accomplished I guess.

Though, I can’t manage to get Celluloid to do the same thing.

I can only get mpv in the Celluloid flatpak to use NVDEC hardware decoding. Celluloid will only use VAAPI if I set hwdec=auto in mpv.conf. If I set hwdec=nvdec, it refuses to work. When mpv uses the same config file, it correctly selects hwdec.

For some reason, Celluloid refuses to use NVDEC for a VP9 video.