Nvdec in Gstreamer pipeline fails

I am trying to utilize the GPU decoder to handle my rtsp stream in OpenCV, this pipeline is currently failing.

cap = cv2.VideoCapture('rtspsrc location=rtsp://localhost:8554/ ! rtph264depay ! h264parse ! nvdec ! videoconvert ! appsink', cv2.CAP_GSTREAMER)

The failing message is listed as follow:

(python3:48928): GStreamer-CRITICAL **: 17:00:08.155:
Trying to dispose element nvdec0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(python3:48928): GStreamer-CRITICAL **: 17:00:08.155:
Trying to dispose element h264parse0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(python3:48928): GStreamer-CRITICAL **: 17:00:08.155:
Trying to dispose element rtph264depay0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(python3:48928): GStreamer-CRITICAL **: 17:00:08.155:
Trying to dispose element rtpstorage0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(python3:48928): GStreamer-CRITICAL **: 17:00:08.155:
Trying to dispose element funnel1, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(python3:48928): GStreamer-CRITICAL **: 17:00:08.155:
Trying to dispose element funnel0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(python3:48928): GStreamer-CRITICAL **: 17:00:08.155:
Trying to dispose element manager, but it is in PLAYING (locked) instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(python3:48928): GStreamer-CRITICAL **: 17:00:08.155:
Trying to dispose element rtspsrc0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

When I set GST_DEBUG=4, I am able to see this error:

0:00:00.275478672 48840 0x7fdbfc003a30 INFO               GST_EVENT gstevent.c:1517:gst_event_new_reconfigure: creating reconfigure event
0:00:00.275507575 48840 0x7fdbfc003a30 WARN                   nvdec gstnvdec.c:61:cuda_OK: CUDA call failed: CUDA_ERROR_INVALID_HANDLE, invalid resource handle
0:00:00.275515327 48840 0x7fdbfc003a30 WARN                   nvdec gstnvdec.c:1000:gst_nvdec_drain:<nvdec0> parser failed
0:00:00.275526125 48840 0x7fdbfc003a30 FIXME               basesink gstbasesink.c:3145:gst_base_sink_default_event:<appsink0> stream-start event without group-id. Consider implementing group-id handling in the upstream elements

Hey I’m facing the same issue, have you found any solution for this?

No I have not. Still waiting for a reply. Will post the solution here once I figure it out.