Is it possible to check for errors/warnings when writing to RTSP server using VideoWriter?

I am using opencv with gstreamer backend to send frames to an RTSP server (mediamtx), which works very well for the most part. Here is a simplified version:

pipeline = ‘appsrc ! video/x-raw, format=BGR ! queue ! videoconvert ! video/x-raw,format=RGBA  ! nvvidconv ! nvv4l2h264enc ! rtspclientsink location=rtsp://192.168.0.100:8554/stream’
out = cv2.VideoWriter(pipeline,cv2.CAP_GSTREAMER, 0, 10, (856,482), True)

while True:
    frame = frameQueue.get() # Frames from another thread
    out.write(frame)

However, I can’t find any way to detect errors / warnings in the code when writing to the server fails. For example, if the RTSP server is closed the code will continue to run, but I will get the following warnings printed to the terminal each time:

[ WARN:2] global /home/ubuntu/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1967) writeFrame OpenCV | GStreamer warning: Error pushing buffer to GStreamer pipeline

Is there any way to catch these warnings? Or any other ways to detect errors / warnings when writing to an RTSP server? I want to handle this in the code so that I can restart the VideoWriter.

I have tried try…except and out.isOpened() will still return True after the RTSP server has closed.

My current workaround is to have another thread with a VideoCapture reading and checking the RTSP stream, but I would prefer not to have to do that.