是否可以使用curl工具对RTSP流进行简单的健康检查? [英] Is it possible to do a simple health check of RTSP stream with curl tool?

查看:385
本文介绍了是否可以使用curl工具对RTSP流进行简单的健康检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用curl工具对RTSP流进行简单的健康检查.
但是像这样的命令总是会给我404流未找到错误:

I'm trying to do a simple health check of RTSP stream with curl tool.
But command like this always gives me 404 Stream Not Found error:

curl -v --url rtsp://192.168.1.80/h264/ --user admin:1234
*   Trying 192.168.1.80...
* Connected to 192.168.1.80 (192.168.1.80) port 554 (#0)
* Server auth using Basic with user 'admin'
> OPTIONS * RTSP/1.0
> CSeq: 1
> User-Agent: curl/7.47.0
> Authorization: Basic YWRtaW46YWRtaW4=
> 
< RTSP/1.0 404 Stream Not Found
< CSeq: 1
< Date: Tue, Feb 27 2018 01:14:21 GMT
< 
* Connection #0 to host 192.168.1.80 left intact  

看起来应该是 OPTIONS 之后的URL,而不是 * :>选项* RTSP/1.0

It looks like that instead of * it should be an URL after OPTIONS here: > OPTIONS * RTSP/1.0

例如,我使用VLC媒体播放器测试了相同的URI,并使用tcpdump捕获了数据包.使用VLC,它可以正常工作,并且向RTSP服务器发送数据的请求看起来像这样:

For instance, I tested the same URI with VLC media player and captured packets with tcpdump. With VLC it works without any issues and data send in request to RTSP server looks like this:

OPTIONS rtsp://192.168.1.80:554/h264 RTSP/1.0
CSeq: 2
User-Agent: LibVLC/2.2.2 (LIVE555 Streaming Media v2016.02.09)

看来libcurl中有一个选项 CURLOPT_RTSP_STREAM_URI 可在curl工具的作用下工作,但是我找不到命令行选项来设置此参数,因此 * 会根据以下设置用作默认值: https://curl.haxx.se/libcurl/c/CURLOPT_RTSP_STREAM_URI.html 而且它也不会自动使用--url的值.

It looks that there is an option CURLOPT_RTSP_STREAM_URI in libcurl that works under the hood of curl tool, but I can't find command line option to set this parameter so * is used as default value according to this: https://curl.haxx.se/libcurl/c/CURLOPT_RTSP_STREAM_URI.html And it doesn't automatically use value of --url neither.

是否可以使用curl工具测试(对DESCRIBE或OPTIONS的简单确定响应就足够了)RTSP流?

Is there a way to test(a simple OK response to DESCRIBE or OPTIONS would be enough I think) RTSP stream with curl tool?

推荐答案

可能为时已晚,无法对原始问题的作者有所帮助,但可能对其他问题有用.我的Laview门铃摄像头每隔几天就会死机,而rtsp流却遇到问题,而摄像头实际上却停滞不前.一个简单的curl命令返回选项并等待更多提示:

Probably too late to be helpful to the author of the original question, but might be useful to others. I've ran into an issue with an rtsp stream on my Laview Doorbell camera dying every couple of days, whereas camera actually stays up. A simple curl command returns options and waits for more prompt:

> curl -i -X OPTIONS username:userpassword@192.168.1.15:554/Streaming/Channels/101 RTSP/1.0
200 OK Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE

不想再深入研究RTSP协议,我试图简单地获取返回状态

Not wanting to dive more into RTSP protocol, I tried to simply get a return status

> curl --head --connect-timeout 15 -i -X OPTIONS username:userpassword@192.168.1.15:554/Streaming/Channels/101
curl: (8) Weird server reply

这实际上与死"流的状态不同:

This is actually different from the status of a 'dead' stream:

> curl --head --connect-timeout 15 -i -X OPTIONS username:userpassword@192.168.1.15:554/Streaming/Channels/101
curl: (56) Recv failure: Connection reset by peer

这会导致这种天真但实用的脚本,如果状态不是'8',则会重新启动相机:

This leads to this naive but functional script that restarts the camera if the status is not '8':

curl --head --silent --connect-timeout 15 -i -X OPTIONS username:userpassword@192.168.1.15:554/Streaming/Channels/101
if [ $? -ne 8 ]
then

 curl "http://username:userpassword@192.168.1.15/ISAPI/System/reboot" -X PUT -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0" -H "Accept: */*" -H "Accept-Language: en-US,en;q=0.5" -H "Referer: http://192.168.1.15/doc/page/config.asp" --data ""

fi

这篇关于是否可以使用curl工具对RTSP流进行简单的健康检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆