3

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
mgutsche
  • 465
  • 1
  • 9
  • 20
  • You need to silence them in a way that affects not only Python, but also the C/C++ libraries that are called (OpenCV/ffmpeg/gstreamer in this case). Find solutions here: https://stackoverflow.com/questions/11130156/suppress-stdout-stderr-print-from-python-functions – w-m Jul 26 '18 at 14:41
  • 1
    I found this answer to solve my Problem: https://stackoverflow.com/a/14797594/1998288 edit: actually the problem still remains, does h.264 something nasty? – mgutsche Jul 26 '18 at 15:11

0 Answers0