Python gstreamer h264 desktop gpu for rtsp in BGR format

Hi,

Looking for python code for convert via RTSP using desktop GPU in BGR format. We have tried various combinations and its now been a week that we cannot get our head around. Cannot use deepstream because it is too tightly coupled.
We have been using CPU only method to decode the stream but that is consuming too much cpu. I would request you to kindly help us with stable code for production environment.

Hi,

What model of GPU are you using? I only have experience with T4, but I think this also applies to V100.

There is a GStreamer element called nvv4l2h264enc that supports h246 encoding using the GPU. It only supports I420, NV12 and P010_10LE as source pixel formats. but you can add a converter without too much overhead.

Please provide more information about your platform and application to give you a better answer.

Thanks for replying. We are stuggling to reduce CPU usage with RTSP streams for live object detection.
GPU Mode: T4

The CPU usage is too high for a single stream with OpenCV in order for us to scale for a smart city project.
80% of a single core. I have tried ffmpeg with cuda and it works beautifully but the moment i add code to convert it to BGR the CPU usage spikes from 16% to 90% of a single core. Since we are working with OpenCV we need BGR format and also python is needed.

Can you share your pipeline for nvv4l2h264enc ?

I still don’t fully understand your application. I am assuming you have an RTSP stream encoded in h264 and need to perform an OpenCV algorithm on it. Is this correct?

The pipeline to do that would be something like:
gst-launch-1.0 uridecodebin uri=rtsp:… !

uridecodebin creates a pipeline giving priority to HW accelerated elements like nvv4l2h264dec and nvvidconv

You can also check out out GTC 2020 demo, where we use Python to create modular Gstreamer pipelines: