GithubHelp home page GithubHelp logo

rtsp's People

Contributors

dactylroot avatar oh-noodles avatar rafale77 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rtsp's Issues

Bad URI Parsing

RTSP resource URIs are not parsed properly per urllib and currently fed directly to OpenCV. Can add some input cleansing around to help make this parameter more robust.

Timeout and try catch

Hello, great library!
I am trying to do two things by using it. The first one, is to set a max-timeout of rtsp.Client read() function. I mean I am trying to make it try until X seconds and assume the stream is down after those X seconds.

The second one, is to detect a wrong stream url. The following snippet is running with a wrong URL and port but still gives "FOUND" output. Shouldn't it return "NOT FOUND"?

import rtsp
try:
    client = rtsp.Client(rtsp_server_uri = 'rtsp://DNA:[email protected]:12345', verbose=True)
    client.read()
    client.close()
    print("FOUND")
except:
    print("NOT FOUND")

Can't Read Stream Properties

The async thread locks stream access, so this packages users can't access informative properties e.g.

  • stream.get(cv2.CAP_PROP_FPS)
  • stream.get(cv2.CAP_PROP_FRAME_WIDTH)
  • stream.get(cv2.CAP_PROP_FRAME_HEIGHT)
  • stream.get(cv2.CAP_PROP_FRAME_COUNT)

Keep RTSP connection alive

Can you tell me how to keep the rtsp connection alive,my connection keep dropping after 10-15 seconds consistently

module "rtsp" has no attribute "Client"

I'm trying to use this module to read RTSP stream, I tried with the exemple in your readme (One-off Retrieval)
and I got this error :
AttributeError: module 'rtsp' has no attribute 'Client'.

Environment:

  • - Jetson TX2
    
  • - Ubuntu 18.04 LTS
    
  • - Python 3.6.9 
    

Authentication

Hi
I did a bit of googling to discover that authenticated RTSP streams can be accessed with a modified url of form

RTSP_URL = f"rtsp://{USERNAME}:{PASSWORD}@192.168.1.221:554/11"

This could be included in your readme or just left here as an issue :-)

Can't Set CV_CAP_PROP_BUFFERSIZE

Problem

Given an unknown source framerate and unknown frame processing time for each frame, we want to be able to always grab the most recent frame at the time of a read() call. In contrast to traditional process-every-frame stream workflows, which opencv-python seems to have been designed around.

Ideally we could follow cap.set(CV_CAP_PROP_BUFFERSIZE,1) and then always have the most recent frame available. Unfortunately, contrary to this suggestion, we don't appear to be able to set this property in Python:

In : cap.set(cv2.CAP_PROP_BUFFERSIZE,1)                                                                                  
Out: False

It appears everyone tries to manually flush the buffer themselves e.g. 1 2a 2b

Current Workaround

As a workaround, I parameterized the buffer skipping rate. So users of this package still have to be conscious of their source framerate and set a flush rate accordingly.

Possible Solutions

Some options to consider to fix this:

  • Find out how to set the CAP_PROP_BUFFERSIZE property for OpenCV.
  • Use another thread to spool frames as quickly as possible. This is no ideal as we don't want to force every user into multithreading situations, especially when OpenCV supposedly has this capability already.

None frames are not caught

Hi
I have an RTSP camera which is secured with a username and password. This causes the connection to fail with the error

Failed to connect to source rtsp://192.168.1.221:554/11.
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-10-8bc6cd52214b> in <module>
----> 1 client.read().show()

~/anaconda3/lib/python3.6/site-packages/rtsp/__init__.py in read(self)
     55     def read(self):
     56         """ Return most recent frame as Pillow image. Returns None if none have been retrieved. """
---> 57         return self._capture.read()
     58 
     59     def preview(self):

~/anaconda3/lib/python3.6/site-packages/rtsp/cvstream.py in read(self)
    149         self._latest = frame
    150         self._stream.release()
--> 151         return Image.fromarray(cv2.cvtColor(self._latest, cv2.COLOR_BGR2RGB))
    152 
    153     def preview(self):

error: OpenCV(3.4.2) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.hpp:253: error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper'

This issue indicates there is no frame data, which could be caught, and an appropriate exception raised.

Lack of Logging Support

Should support log object dependency-injection style. Allow users to pass in a log file in lieu of the verbose parameter.

AttributeError: 'NoneType' object has no attribute 'shape' during write video output using ffmpegcv

objective
write video output using ffmpegcv

steps
pip install -U rtsp ffmpegcv

code

import rtsp
import ffmpegcv
url = 'http://clausenrc5.viewnetcam.com:50003/nphMotionJpeg?Resolution=320x240' # aspect ratio = 4:3
client = rtsp.Client(rtsp_server_uri = url, verbose = False)
output_file = 'rtsp_ffmpegcv_time.mp4'
vidout = ffmpegcv.VideoWriter(output_file, None, pix_fmt = 'bgr24')
i = 0
while i <= 9:
    frame = client.read(raw = True)
    vidout.write(frame)
    i += 1
client.close()
vidout.release()

result

AttributeError                            Traceback (most recent call last)
[<ipython-input-29-fc5430a80232>](https://localhost:8080/#) in <cell line: 11>()
     12     frame = client.read(raw = True)
     13 
---> 14     vidout.write(frame)
     15 
     16     i += 1

[/usr/local/lib/python3.10/dist-packages/ffmpegcv/ffmpeg_writer.py](https://localhost:8080/#) in write(self, img)
     65                 height = int(height_15 / 1.5)
     66             else:
---> 67                 height, width = img.shape[:2]
     68             self.width, self.height = width, height
     69             self.in_numpy_shape = img.shape

AttributeError: 'NoneType' object has no attribute 'shape'

best regards

Get the byteArray

Hello, first thanks for your project and effort put on this.

I'm currently developing a script for FacialRecognition and the APIs that I'm using receive the ByteArray of the image capture using RTSP. I'm wonder if you can guide me how can I achieve this. Actually I have noticed that the read() method return the image in Pillow format, maybe I should touch your code to change this, but can't find where.

Thank you so much.

Timeout Exception

Make an optional timeout argument that throws an exception if the connection takes too long to complete.

object has no attribute 'save'

I've just found this package and was running the sample code.

I'm getting "object has no attribute 'save'" although the camera show as connected:

Connected to video source rtsp://xxxx:[email protected]/.
Traceback (most recent call last):
File "d:\Dev\Python\Rtsp2email\rtsp2mail.py", line 9, in
rclient.read().save("./"+ str(datetime.datetime.now()) +".jpg")
^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'save'

[Question] Would an asyncio rtsp stream reader make sense?

In the docs, you say: "v2.0.0 - lightweight native-Python implementation rtsp client functions"

Are you thinking of using asyncio/concurrency to handle concurrent RTSP streams?

I'm experimenting with different ways of listening to dozens of cameras concurrently and was curious what a native Python solution might look like :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.