#11505 closed defect (fixed)
Cuvid decoders do not work with CUDA hwaccel anymore
| Reported by: | bermond | Owned by: | Timo Rothenpieler <timo@rothenpieler.org> |
|---|---|---|---|
| Priority: | normal | Component: | avcodec |
| Version: | git-master | Keywords: | cuvid cuda Nvidia hw_decode hwaccel |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
Cuvid decoders do not work with CUDA hwaccel anymore in FFmpeg git master. An error message says that Codec h264_cuvid is not supported with this chroma format.
How to reproduce:
$ ffmpeg -init_hw_device cuda=gpu:0 -hwaccel cuda -hwaccel_output_format cuda -hwaccel_device gpu -c:v h264_cuvid -i input.mp4 -y test-out.mp4
ffmpeg version N-118749-g0f7d77fc42 Copyright (c) 2000-2025 the FFmpeg developers
built with gcc 14.2.1 (GCC) 20250207
configuration: --prefix=/usr --enable-lto --disable-rpath --enable-gpl --enable-version3 --enable-nonfree --enable-shared --disable-static --disable-stripping --disable-htmlpages --enable-gray --enable-alsa --enable-avisynth --enable-bzlib --enable-chromaprint --enable-frei0r --enable-gcrypt --enable-gmp --enable-gnutls --enable-iconv --enable-ladspa --enable-lcms2 --enable-libaom --enable-libaribb24 --enable-libaribcaption --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcelt --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdavs2 --enable-libdc1394 --enable-libdvdnav --enable-libdvdread --enable-libfdk-aac --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libglslang --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libilbc --enable-libjack --enable-libjxl --enable-libklvanc --enable-libkvazaar --enable-liblc3 --enable-liblcevc-dec --enable-liblensfun --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopencv --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopenvino --enable-libopus --enable-libplacebo --enable-libpulse --enable-libqrencode --enable-libquirc --enable-librabbitmq --enable-librav1e --enable-librist --enable-librsvg --enable-librubberband --enable-librtmp --disable-libshaderc --enable-libshine --enable-libsmbclient --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libsvthevc --enable-libsvtvp9 --disable-libtensorflow --enable-libtesseract --enable-libtheora --disable-libtls --disable-libtorch --enable-libtwolame --enable-libuavs3d --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libvvenc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxevd --enable-libxeve --enable-libxavs --enable-libxavs2 --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxcb-shape --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-lzma --enable-decklink --disable-mbedtls --enable-libmysofa --enable-openal --enable-opencl --enable-opengl --disable-openssl --disable-pocketsphinx --enable-sndio --enable-sdl2 --enable-vapoursynth --enable-vulkan --enable-xlib --enable-zlib --enable-amf --enable-cuda-nvcc --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-libdrm --enable-libvpl --enable-libnpp --enable-nvdec --enable-nvenc --enable-omx --enable-rkmpp --enable-v4l2-m2m --enable-vaapi --enable-vdpau
libavutil 59. 59.100 / 59. 59.100
libavcodec 61. 33.102 / 61. 33.102
libavformat 61. 9.107 / 61. 9.107
libavdevice 61. 4.100 / 61. 4.100
libavfilter 10. 9.100 / 10. 9.100
libswscale 8. 13.101 / 8. 13.101
libswresample 5. 4.100 / 5. 4.100
libpostproc 58. 4.100 / 58. 4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2023-02-17T22:54:31.000000Z
Duration: 00:00:40.75, start: 0.000000, bitrate: 817 kb/s
Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 576x1024 [SAR 1:1 DAR 9:16], 684 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
Metadata:
creation_time : 2023-02-17T22:54:31.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 02/17/2023.
vendor_id : [0][0][0][0]
Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2023-02-17T22:54:31.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 02/17/2023.
vendor_id : [0][0][0][0]
[h264_cuvid @ 0x5ea53363e140] Codec h264_cuvid is not supported with this chroma format.
[vist#0:0/h264 @ 0x5ea5335a5f40] [dec:h264_cuvid @ 0x5ea533683d00] Error while opening decoder: Invalid argument
Error opening output file test-out.mp4.
Error opening output files: Invalid argument
The command bellow, without hwaccel, works:
$ ffmpeg -c:v h264_cuvid -i input.mp4 -y test-out.mp4
A git bisect shows the offending commit as being: 7e9655800da385f8dc9d31f6ac831910f98c8c9e.
Operating System: Arch Linux
FFmpeg: git master
Change History (10)
comment:2 by , 18 months ago
They may but my quick check also triangulated to that commit:
https://github.com/GyanD/codexffmpeg/issues/173
comment:3 by , 18 months ago
Hm, so I can see the input file is just normal h264 8 bit file, hm. Then it should be a bug.
comment:4 by , 18 months ago
Thank you for the replies.
We need an input file.
This can be used as an input file (download command, needs yt-dlp):
$ yt-dlp --format best https://www.youtube.com/shorts/n5jf9PpZzGY
It's an 8-bit YUV 4:2:0 video, which should work with h264_cuvid when using CUDA hwaccel. It was working right before the mentioned commit.
They may but my quick check also triangulated to that commit:
https://github.com/GyanD/codexffmpeg/issues/173
This seems to be exactly the same issue. Thanks for sharing.
Note: using RTX 3060 with proprietary NVIDIA drivers 570.124.04.
comment:5 by , 18 months ago
I still do not get it why are using it like this, that is kinda wrong... h264_nvenc should be used.
ffmpeg -init_hw_device cuda=gpu:0 -hwaccel cuda -hwaccel_output_format cuda -hwaccel_device gpu -hwaccel cuda -i input.mp4 -c:v h264_nvenc -y test-out.mp4
follow-up: 7 comment:6 by , 18 months ago
I still do not get it why are using it like this, that is kinda wrong... h264_nvenc should be used.
h264_nvenc is an encoder, and I guess you are confusing things here. This issue is not about the encoder.
But the issue is about the decoder. And more specifically, about Cuvid decoders (h264_cuvid, hevc_cuvid and so on).
ffmpeg -init_hw_device cuda=gpu:0 -hwaccel cuda -hwaccel_output_format cuda -hwaccel_device gpu -hwaccel cuda -i input.mp4 -c:v h264_nvenc -y test-out.mp4
Your example does not use Cuvid decoders, which are the subject of this issue.
comment:7 by , 18 months ago
Replying to bermond:
ffmpeg -init_hw_device cuda=gpu:0 -hwaccel cuda -hwaccel_output_format cuda -hwaccel_device gpu -hwaccel cuda -i input.mp4 -c:v h264_nvenc -y test-out.mp4
Your example does not use Cuvid decoders, which are the subject of this issue.
It's use NVDEC decoder, better use it then CUDA.
comment:8 by , 18 months ago
| Owner: | set to |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |
In fed66124/ffmpeg:
comment:9 by , 18 months ago
I can confirm this is now fixed by commit fed6612415c98fc1b0193bb5a92442fab550fd49.
Thank you for fixing this!
comment:10 by , 18 months ago
I still do not get it BTW, you either use -hwaccel and its format or cuvid as decoder, before -i.



We need an input file. But that is not an offending commit, because 50 series Nvidia cards NVDEC silicon supports those formats in HW.
h264_cuvid is deprecated as decoder and encoder, use new h264_nvenc.