How to fix opencv python cv2.VideoCapture rtsp onvif “nonmatching transport in server reply” error?

前端 未结 2 815
面向向阳花
面向向阳花 2021-02-10 00:23

I\'m on windows using python 3.6.4, installed opencv (3.4) through pip. Here\'s the code I\'m using:

import numpy as np
import cv2

cap = cv2.VideoCapture(\'rtsp         


        
2条回答
  •  被撕碎了的回忆
    2021-02-10 00:24

    I've just encountered this problem and after digging it looks like OPENCV 3.1+ defaults to TCP for the RTSP transport (my ESCAM QF600 only supports RTSP over UDP). You can prevent this from happening via setting the environment variable OPENCV_FFMPEG_CAPTURE_OPTIONS to something (e.g. dummy).

    For completeness; see https://ffmpeg.org/ffmpeg-protocols.html for all options that can be set. Keys and values are separated with ';' and pairs are separated via '|'.

    The offending code begins at line 809 in cap_ffmpeg_impl.hpp (https://github.com/opencv/opencv/blob/master/modules/videoio/src/cap_ffmpeg_impl.hpp)

    Props to the following posts for sending me in the right direction:

    ffmpeg rtsp error: Nonmatching transport in server reply

    Cant get RTSP stream - nonmatching

提交回复
热议问题