Nvidia hardware video encoding not working

Hello. I am trying to get Nvidia hardware encoding working, specifically for ALVR but we may use FFmpeg to test if it’s working as that’s a more widely known program. I have an RTX 3060 card on a desktop computer. My Driver version is 525.89.02 and CUDA version 12 (pacman shows cuda 11.8.0-1 but nvidia-smi outputs CUDA version 12). I followed the Arch Wiki and installed nvidia-utils. The modules are loaded:

$ lsmod | grep nvidia
nvidia_drm             73728  7
nvidia_uvm           2908160  0
nvidia_modeset       1515520  9 nvidia_drm
nvidia              61444096  480 nvidia_uvm,nvidia_modeset
video                  65536  1 nvidia_modeset

Trying to render a video with FFmpeg using this command ffmpeg -y -hwaccel cuda -i bigbuckbunny.mp4 bigbuckbunny2.mp4 works, but uses CPU. I compiled FFmpeg myself following these instructions and tried again and got this error:

Device creation failed: -12.
No device available for decoder: device type cuda needed for codec h264.

Also, ffmpeg -help encoder=h264_nvenc returns error Codec 'h264_nvenc' is not recognized by FFmpeg.. I have also installed x265, libde265 and nvenc packages from the AUR but the same issue still occurs. What can I do to get Nvidia H265 Hardware encoding working? Thanks in advance.