I'm streaming a video from a Raspberry Pi over a gstreamer pipeline. I read this stream on a desktop using OpenCV and gstreamer. Everything works great, except that the receiver does not know when the stream is finished.
The receiver code is essentially the same as in convert gstreamer pipeline to opencv in python
My problem is if I don't quit the receiver by typing 'q', cap_receive.read() never seems to return False as its retval when the sender is done.
gst_str_simple = "udpsrc port=5000 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! avdec_h264 ! videoconvert ! appsink"
recv_cap = cv2.VideoCapture(gst_str_simple, cv2.CAP_GSTREAMER)
if not recv_cap.isOpened():
print('VideoCapture not opened')
exit(0)
while True:
ret, frame = recv_cap.read()
if not ret:
print('empty frame')
break
cv2.imshow('receive', frame)
if cv2.waitKey(1)&0xFF == ord('q'):
break
recv_cap.release()
Can I write an empty frame at the sender to make this happen? Or any other way to make the receiver terminate automatically? Maybe a timeout?
Thanks