Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Failing to open rtsp stream in ubuntu 18.04 and python

Hi!

I am trying to receive a rtsp video stream from my drone camera in python. After searching for solutions online, I ended up trying to use open cv's VideoCapture(...) function. The problem is that it does not open the video capture object, but returns false. It gives no error message. VLC manage to open the stream, so I know it is transmitted correctly.

The code i use for reception:


import cv2 as cv
vcap = cv.VideoCapture("rtsp:// ...")
if vcap.isOpened():
    while(1):
        ret, frame = vcap.read()
        print(ret)
        cv.namedWindow('VIDEO', cv.WINDOW_AUTOSIZE)
        cv.imshow('VIDEO', frame)
        cv.waitKey(1)
else:
    print("Camera failed to open. :(")
 

It prints "Camera failed to open. :(" every time.

I have FFMPEG installed, and cv2. getBuildInformation() returns (among other things):


Video I/O:
    DC1394:                      YES (2.2.5)
    FFMPEG:                      YES
      avcodec:                   YES (57.107.100)
      avformat:                  YES (57.83.100)
      avutil:                    YES (55.78.100)
      swscale:                   YES (4.8.100)
      avresample:                YES (3.7.0)
    GStreamer:                   NO
    v4l/v4l2:                    YES (linux/videodev2.h)
 

My system:


OS: Ubuntu 18.04
Python version: 3
OpenCV version: 4.1.0
 

The video stream:


rtps
.h264
 

Any help would be appreciated. :)