Hello guys,
I have an issue with trying reconnect stream.
def open_cam_rtsp(uri, width, height, latency):
"""Open an RTSP URI (IP CAM)."""
gst_str = ('rtspsrc location={} latency={} ! '
'rtph264depay ! h264parse ! omxh264dec ! '
'nvvidconv ! '
'video/x-raw, width=(int){}, height=(int){}, '
'format=(string)BGRx ! videoconvert ! '
'appsink').format(uri, latency, width, height)
return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
This is my format rtsp stream , i’m using HKVion camera. Everything work fine. I try to control the case when camera dont have internet connection (network not stable, camera turn off, …), so i want to call reconnect function after 5 second to make sure when the camera is activated, i can get the stream from it.
def show_camera():
while(isOpened):
cap = cv2.VideoCapture(open_cam_rtsp(url), cv2.CAP_GSTREAMER)
if cap.isOpened():
print('Connected to camera')
isOpened = True
else:
print('Unable to open camera')
isOpened = False
It run fine after hours bebore this error show , this code will stuck and dont run anymore.
(python:2946615): GStreamer-CRITICAL **: 19:24:31.287:
Trying to dispose element rtph264depay, 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.
(python:2946615): GStreamer-CRITICAL **: 19:24:31.287:
Trying to dispose element h264parse, 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.
(python:2946615): GStreamer-CRITICAL **: 19:24:31.287:
Trying to dispose element udpsrc0, 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.
(python:2946615): GStreamer-CRITICAL **: 19:24:31.287: gst_mini_object_unref: assertion '(g_atomic_int_get (&mini_object->lockstate) & LOCK_MASK) < 4' failed
(python:2946615): GStreamer-CRITICAL **: 19:24:31.287:
Trying to dispose element omxh264dec, but it is in PAUSED 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.
[ WARN:0] global /home/Users/dqy/myLibs/opencv/modules/videoio/src/cap_gstreamer.cpp (914) open OpenCV | GStreamer warning: unable to start pipeline
(python:2946615): GStreamer-CRITICAL **: 19:24:31.287:
Trying to dispose element videoconvert, 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.
[ WARN:0] global /home/Users/dqy/myLibs/opencv/modules/videoio/src/cap_gstreamer.cpp (501) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
(python:2946615): GStreamer-CRITICAL **: 19:24:31.287:
Trying to dispose element appsink0, but it is in READY 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.