JohnnyCyp
Posts: 75
Joined: Sun Mar 31, 2019 11:05 pm

Problem with IP Camera Streaming with Flask Web and opencv

Tue Jun 04, 2019 9:56 am

I have a problem with my IP camera trying to streaming in Flask Web using opencv. In my html page shows the camera streaming window but it capture a frame every 2-3 minutes...
I got this error:

[h264 @ 0x23a0be0] error while decoding MB 59 42, bytestream -13
[h264 @ 0x23a0be0]error while decoding MB 72 9, bytestream -7
[h264 @ 0x23a0be0] error while decoding MB 38 14, bytestream -9
[h264 @ 0x23a0be0] error while decoding MB 75 36, bytestream -7
[h264 @ 0x23a0be0] error while decoding MB 44 8, bytestream -19
[h264 @ 0x23a0be0] error while decoding MB 44 8, bytestream -27
[h264 @ 0x23a0be0] error while decoding MB 59 44, bytestream -21
[h264 @ 0x23a0be0] error while decoding MB 64 12, bytestream -23
[h264 @ 0x23a0be0] error while decoding MB 26 19, bytestream -10
[h264 @ 0x23a0be0] error while decoding MB 56 27, bytestream -10

Code: Select all

import cv2

camera = cv2.VideoCapture('rtsp://admin:12345@192.168.1.105:554/user=admin_password=12345_channe0_stream=0.sdp')

def gen_frames():  # generate frame by frame from camera
    while True:
        # Capture frame-by-frame
        success, frame = camera.read()  # read the camera frame
        if not success:
            break
        else:
            ret, buffer = cv2.imencode('.jpg', frame)
            frame = buffer.tobytes()
            yield (b'--frame\r\n'
                   b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')  # concat frame one by one and show result

@app.route('/video_feed')
def video_feed():
    """Video streaming route. Put this in the src attribute of an img tag."""
    return Response(gen_frames(),
                    mimetype='multipart/x-mixed-replace; boundary=frame')

Return to “Camera board”