views:

278

answers:

4

Hello,

I am trying to verify that a video service is provided from an URL in python. I am asking does anyone know of any good libraries to use or a way to do this. I have not found much info for this on the web.

Thanks

+1  A: 

If you try to validate the URL itself as a valid RTSP URL, I think that it's only the protocol token that changes from http:// to rtsp:// or rtspu://, and implicitly, the default port is no longer 80, but 554.

See RTSP RFC, section 3.2 ("RTSP URL") for more details regarding URL format.

However, if wish to know if "behind" a given RTSP URL there's a running RTSP server, you should actually open a connection to this server, usually using TCP sockets. You can make the "conversation" simply via code, but I suggest you use some kind of a product/library that provides RTSP stack for Python; I don't know if such product actually exists for Python, but there are a few things for C/C++.

Ron Klein
+2  A: 

Digging around on StackOverflow I came across a previous question asking for an RTSP library in Python or C/C++ .

Linked there is an RTSP library provided by Twisted, and another one called Live555. Have you tried either of these?

I am just reposting the links for convenience.

jathanism
+2  A: 

If you do not want to use a library, as suggested by synack, you can open a socket connection to the given URL and send an RTSP DESCRIEBE request. That is actually quite simple since RTSP is text-based HTTP-like. You would need to parse the response for a meaningful result, e.g look for the presence of media streams.

Bernd
A: 

I don't believe Live555 provides a python library. However, they do provide source code that can be compiled to build openRTSP. This is a simple command-line utility that will perform the entire RTSP handshake to connect to the server and begin streaming to the client. It also can provide statistic measurements (such as jitter, number of packets lost, etc.) that can be used to measure the quality of the streaming connection.

J. Fritz Barnes