opencvencodinggstreamerhardware-accelerationnvenc

OpenCV VideoWriter (Gstreamer + NVENC) freezes for more than 3 streams


I am trying to setup a multi-stream hardware accelerated (Nvidia's NVENC) encoding system using Opencv compiled with Gstreamer backend as well as nvenc and nvdec plugins baked into Gstreamer.

The setup works fine for <= 3 streams but as soon as I create a 4th VideoWriter object the program freezes.

Freezed Output

Note that when I remove the 4th videoWriter object or change the encoding element from "nvh264enc" to "x264enc" for 4th stream, the program works just fine. The issue does not reproduce with all 4 streams switched to "x264enc". So my guess is that it has something to do with Nvidias NVENC API or underlying hardware? Testing on a laptop with RTX-3070.

Non-Freezed Output


Solution

  • I'm pretty sure that consumer grade NVIDIA GPUs are limited to 3 concurrent NVENC sessions.

    See https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new