# VideoCapture can't open RTSP stream \[FIXED\]

**URL:** <https://forum.opencv.org/t/videocapture-cant-open-rtsp-stream-fixed/10594>\
**Category:** Python\
**Tags:** rtsp, videoio\
**Created:** [October 18, 2022, 12:02pm UTC](https://forum.opencv.org/t/videocapture-cant-open-rtsp-stream-fixed/10594 "2022-10-18T12:02:48Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Tjirk](https://avatars.discourse-cdn.com/v4/letter/t/ecae2f/32.png) [@Tjirk](https://forum.opencv.org/u/Tjirk)\
**Post date:** [October 18, 2022, 1:58pm UTC](https://forum.opencv.org/t/videocapture-cant-open-rtsp-stream-fixed/10594/3 "2022-10-18T13:58:33Z")

</div>

What I have found is the following:  
It can happen because the cap.read fuction returns a false, thus the frame is empty.  
Possible solutions are to cover it by an if statement

if ret false:  
cap.release()  
cap = cv2.VideoCapture(‘IP camera’)  
ret, frame = cap.read()

This solution doesn’t work because ret is always false.  
this keeps me in an endless loop

> <https://stackoverflow.com/questions/71122785/why-do-i-get-the-following-error-after-and-hour-of-operation-cv2-error-215ass>

> [@Why do I get the following error after and hour of operation cv2.error:(-215:Assertion failed) !src.empty() in function 'cvtColor'](https://forum.opencv.org/t/why-do-i-get-the-following-error-after-and-hour-of-operation-cv2-error-215-assertion-failed-src-empty-in-function-cvtcolor/7586):
>
> Things work fine for 30 minutes to an hour, then I get the following error: ``` (-215:Assertion failed) !\_src.empty() in function ‘cvtColor’ import cv2 import sqlite3 from datetime import datetime connection = sqlite3.connect("/home/harry/interface/wildlife.db") cursor = connection.cursor() x = 1 c = 1 streamTarget = '' def activityScan(status,c): sql=cursor.execute("SELECT \* FROM heavenStream WHERE id = ?",(c,)) dbstatus = sql.fetchone()…

---

_[View the full topic](https://forum.opencv.org/t/videocapture-cant-open-rtsp-stream-fixed/10594)._
