ffmpeg hwaccel no decoder surfaces left

Viewed 4171

Recently I compiled natively the latest version of ffmpeg 4.3 on Windows 10 amd64. Evironment:CUDA11.0, NASM, VS2019, MYSY2 with mingw64.

I also used the patch https://trac.ffmpeg.org/attachment/ticket/9019/0001-Patch-for-ticket-9019-CUDA-Compile-Broken-Using-MSVC.patch

Compile featrues were:

--enable-nonfree --enable-cuda-nvcc --enable-libnpp --enable-gpl --enable-libx264 --enable-cuda-llvm --enable-nvenc
--toolchain=msvc --extra-cflags=-I../nv_sdk --extra-ldflags=-libpath:../nv_sdk

I tested ffmpeg for cuda acceleration. the CPU is an AMD 3500x. the GPU is an RTX 2060Ultra.

Issuing this command:

.\ffmpeg -hwaccel cuvid -i .\a.wmv -c:v hevc_nvenc -bf 4 -preset slow -c:a aac -b:a 256k myvideo.mp4

But recieved this error:

[wmv3 @ 000002632DFC5180] No decoder surfaces left
Error while decoding stream #0:0: Cannot allocate memory
[hevc_nvenc @ 00000263300B1740] Failed locking bitstream buffer: out of memory (10):
video encoding failed: Cannot allocate memory

I'm not sure where I've gone wrong here.

2 Answers

Try adding -extra_hw_frames N to your input and increase N until the error ceases. I just needed 8 myself.

I encountered this same problem on version 4.4 as well. This was reported against 4.1 but only on some cases. Someone suggested the -extra_hw_frames N workaround on https://trac.ffmpeg.org/ticket/7562 and it worked for me.

I also had the same problem as OP and followed the user's "Moby Disk" advice to use "-extra_hw_frames N"

Here is what I used which worked for me:

ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -extra_hw_frames 8 -i video_sample.mp4 -c:a copy -c:v h264_nvenc -b:v 5M output.mp4

The GPU I have is: MSI Nvidia GeForce GT 710 2GB 2GD3

Related