I have the following script with which I read RTSP streams from withing Python3 using OpenCV.
cap = cv2.VideoCapture(ID)
ret, frame = cap.read()
The streams are encoded using h264 and I get tons of warnings and error messages.
[h264 @ 0x7f74cc430c80] co located POCs unavailable
[h264 @ 0x7f74b4258160] error while decoding MB 38 2, bytestream -19
I tried to silence them using a context manager for redirecting stdout and stderr but with no success:
class SilenceOutput(object):
def __enter__(self):
self._original_stdout = sys.stdout
self._original_stderr = sys.stderr
sys.stdout = None
sys.stderr = None
def __exit__(self, exc_type, exc_val, exc_tb):
sys.stdout = self._original_stdout
sys.stderr = self._original_stderr