[FFmpeg-devel] [PATCH] libavcodec/nvenc.c: copy incoming hwaccel frames instead of ref count increase

Roman Arzumanyan rarzumanyan at nvidia.com
Tue Sep 28 19:22:26 EEST 2021


Hello,

This patch makes nvenc copy incoming hwaccel frames instead of ref count increase.
It fixes the bug which may happen when on-GPU transcoding is done and encoder is set to use B frames.

How to reproduce the bug:
./ffmpeg \
  -hwaccel cuda -hwaccel_output_format cuda \
  -i input.mkv \
  -c:v h264_nvenc -preset p4 -tune hq -bf 3 \
  -y output.mkv

Expected output:
[h264 @ 0x55b14da4b4c0] No decoder surfaces left
[h264 @ 0x55b14da682c0] No decoder surfaces left
[h264 @ 0x55b14da850c0] No decoder surfaces left
[h264 @ 0x55b14daa1ec0] No decoder surfaces left
Error while decoding stream #0:0: Invalid data found when processing input
[h264 @ 0x55b14da2e6c0] No decoder surfaces left
Error while decoding stream #0:0: Invalid data found when processing input
    Last message repeated 1 times


Although fix adds extra CUDA DtoD memcopy, our internal testing results didn't show any noticeable difference in transcoding performance.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-nvenc-copy-incoming-HW-frame-instead-of-referencing.patch
Type: text/x-patch
Size: 1567 bytes
Desc: 0001-nvenc-copy-incoming-HW-frame-instead-of-referencing.patch
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210928/4b937d19/attachment.bin>


More information about the ffmpeg-devel mailing list