Nonmatching transport in server reply” when cv2.VideoCapture rtsp onvif camera, how to fix?

asked 2018-04-10 21:48:08 -0500

mozillaa gravatar image

updated 2018-04-10 21:49:44 -0500

I'm on windows 10 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://")
    ret, frame =
    if cv2.waitKey(1) & 0xFF == ord('q'):

[rtsp @ 0000016f6d5995a0] Nonmatching transport in server reply warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:834) warning: rtsp:// (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:835)

But when I'm using ffmpeg code:

ffplay rtsp:// --> Capture oke
ffplay -rtsp_transport udp rtsp:// --> Capture oke
ffplay -rtsp_transport tcp rtsp:// --> Nonmatching transport in server reply

I tried the following steps but don't work:

1 - change cap_ffmpeg_impl.hpp:
replace the line (798->801)
        av_dict_set(&dict, "rtsp_transport", "tcp", 0);
         int err = avformat_open_input(&ic, _filename, NULL, &dict);
        int err = avformat_open_input(&ic, _filename, NULL, NULL);
2 - recompile opencv (

Can you help me, please?

edit retag flag offensive close merge delete


Somebody help me, please ?

mozillaa gravatar imagemozillaa ( 2018-04-18 03:00:08 -0500 )edit

@mozillaa , please do not post answers here, if you have a question or comment, thank you.

berak gravatar imageberak ( 2018-04-18 03:07:34 -0500 )edit