I am reading the drone camera using the opencv Videocapture gstreamer and adding an overlay text to the frame.
The python script can read the frames and add an overlay, and I using nvv4l2decoder to decode the frames. But after minutes, the frame returns None and the gstreamer reader pipeline stops to read the data.
import cv2
cap_send = cv2.VideoCapture('rtspsrc location="rtsp://192.168.0.201:5500/live0" ! queue max-size-bytes=65536 max-size-buffers=0 max-size-time=0 leaky=downstream ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink sync=false ')
scale = 1
font = cv2.FONT_HERSHEY_PLAIN
xMargin = 10
yMarginBottom = 10
yMarginTop = 20
while True:
try:
time.sleep(0.03)
ret,frame = cap_send.read()
if not ret:
print('empty frame')
#break
cv2.imshow('frame', frame)
if cv2.waitKey(1)&0xFF == ord('q'):
break
except Exception as e:
print (e)
cap_send.release()
out_send.release()
I am getting this error If I move the camera continuously for few minutes. My camera is integrated with a drone, so when the vehicle is flying it sends the frame and suddenly gstreamer pipelines stops sending the frames.
After the below error, the pipeline stops to read.