通过 URL 验证 RTSP 服务
我正在尝试验证 python 中的 URL 是否提供了视频服务。我问有谁知道有什么好的库可以使用或者有什么方法可以做到这一点。我在网上没有找到太多这方面的信息。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 StackOverflow 上进行挖掘时,我遇到了一个之前的问题,要求使用 Python 或 RTSP 库C/C++。
链接有一个 Twisted 提供的 RTSP 库< /a>,另一个名为 Live555。您尝试过其中任何一个吗?
我只是为了方便而重新发布链接。
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.
如果您不想使用库,按照 synack 的建议,您可以打开到给定 URL 的套接字连接并发送 RTSP DESCRIEBE 请求。这实际上非常简单,因为 RTSP 是基于文本的,类似于 HTTP。您需要解析响应以获得有意义的结果,例如查找是否存在媒体流。
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.
如果您尝试将 URL 本身验证为有效的 RTSP URL,我认为这只是协议令牌从
http://
更改为rtsp://
或 < code>rtspu://,默认端口不再是 80,而是 554。参见 RTSP RFC,第 3.2 节(“RTSP URL”),了解有关 URL 格式的更多详细信息。
然而,如果想知道给定 RTSP URL“后面”是否有一个正在运行的 RTSP 服务器,您实际上应该打开到该服务器的连接,通常使用 TCP 套接字。您可以简单地通过代码进行“对话”,但我建议您使用某种为 Python 提供 RTSP 堆栈的产品/库;我不知道 Python 是否真的存在这样的产品,但 C/C++ 有一些东西。
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://
tortsp://
orrtspu://
, 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++.
我不相信 Live555 提供 python 库。然而,他们确实提供了可以编译以构建 openRTSP 的源代码。这是一个简单的命令行实用程序,它将执行整个 RTSP 握手以连接到服务器并开始流式传输到客户端。它还可以提供统计测量(例如抖动、丢失的数据包数量等),可用于测量流连接的质量。
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.