4

Hello im learning opencv and im reading a ip camera through rtsp://

videoStream = "rtsp://admin:123456@10.0.0.1:554/Streaming/Channels/1"
capture = cv2.VideoCapture(videoStream)

im reading this stream and im making a facial detection in opencv but after 1 or 2 minutes my script crashes whit a h264 message and my opencv code gives me a error:

[h264 @ 0x27e49570] error while decoding MB 55 12, bytestream -12
no video

and if i use a webcan it not happening

some one can help me whit how is the best way to get a ip camera streaming for facial detection?

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
Jasar Orion
  • 626
  • 7
  • 26
  • i runned again whit lesser resolution and it keeps working for 4 min and the same error. `[h264 @ 0xb4a5510] error while decoding MB 19 4, bytestream -7` `no video` – Jasar Orion Feb 18 '19 at 20:32
  • Note that OpenCV itself does not handle this. H264 decoding happens with whatever backend you are using, e.g. FFMPEG. Try with whichever backend you are using first without OpenCV and see if the issue persists. Note that this type of bug is not likely to be diagnosed on Stack Overflow, especially with this little of information--it's not a simple typo on your part or anything :). See for e.g.: https://github.com/opencv/opencv/issues/13302 – alkasm Feb 19 '19 at 00:44

1 Answers1

2

Before you process any frames, you can ensure that the camera is open and that obtained frames are valid.

videoStream = "rtsp://admin:123456@10.0.0.1:554/Streaming/Channels/1"
capture = cv2.VideoCapture(videoStream)

while True:
    if capture.isOpened():
        status, frame = capture.read()
        if status:
            # Process frames here
            ...

If you are unable to access the camera or get corrupted frames, you can catch this with cv2.error.

try:
   ...
except cv2.error as e:
   ...
nathancy
  • 42,661
  • 14
  • 115
  • 137