Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cv2.videoCapture only return "Port missing in uri"

First of all, thank you for your attention. I'm trying to stream with opencv and ip camera, but it only returns "[tcp @ 000001d5fce13580] Port missing in uri". I have already tested on VLC and also tested with JavaCV and it works on both. I already checked the MPEG and it's OK. Has anyone been through this and can help?

I am with:

  • WIN10
  • OpenCV 4.5.1

CODE:

import numpy as np
import cv2


def runCam():
    print(cv2.getBuildInformation())
    video_src = "rtsp://admin:[email protected]:554/Streaming/channels/1/"
    cap = cv2.VideoCapture(video_src, cv2.CAP_FFMPEG)

    while True:
        ret, frame = cap.read()
        try:
            cv2.resizeWindow('Stream IP Camera OpenCV', 120300, 800)
            cv2.imshow('Stream IP Camera OpenCV', frame)
        except Exception as ex:
            template = "An exception of type {0} occurred. Arguments:\n{1!r}"
            message = template.format(type(ex).__name__, ex.args)
            print(message)
            break

        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    cap.release()
    cv2.destroyAllWindows()


runCam()

OPENCV BUILD INFO: https://gist.github.com/nathancn/745f543e3a6cd13d012855759bd0940d

I USE HIKVISION IP CAM MODEL DS-2CD2621G0-IS

ERROR RETURNED: enter image description here

like image 265
Nathan Nacimento Avatar asked Dec 01 '25 06:12

Nathan Nacimento


1 Answers

RESOLVED

The problem was with my password, for some reason opencv's VideoCapture gets confused when the password contains "#". As I tested it in javacv and VLC and it worked, I had not tested it with another password and wasted a lot of time with it :( But now that I found out I changed the password and it already worked. I hope it helps those who have the same problem to be aware of special password characters .

like image 106
Nathan Nacimento Avatar answered Dec 03 '25 19:12

Nathan Nacimento



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!