Is it possible to do a simple health check of RTSP stream with curl tool?

烈酒焚心 提交于 2020-12-30 09:02:00

问题


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  

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

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)

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.

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


回答1:


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

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

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



回答2:


I managed to use

curl -v -X DESCRIBE "USERNAME:PASSWORD@192.168.1.11:554/Streaming/Channels/101" RTSP/1.0

But it can't find the info

*   Trying 192.168.1.11...
* TCP_NODELAY set
* Connected to 192.168.1.11 (192.168.1.11) port 554 (#0)
* Server auth using Basic with user 'USERNAME'
> DESCRIBE /Streaming/Channels/101 HTTP/1.1
> Host: 192.168.1.11:554
> Authorization: Basic YWRtaW46MTIzNDU=
> User-Agent: curl/7.58.0
> Accept: */*
> 
RTSP/1.0 404 Not Found

Seems like it's not using the right protocol ! I couldn't find how to make it use RTSP

PS : I can confirm it works with ffmpeg ! The path is right.




回答3:


Append rtsp:// to the request as given below:

curl -v -X DESCRIBE "rtsp://USERNAME:PASSWORD@192.168.1.11:554/Streaming/Channels/101" RTSP/1.0


来源:https://stackoverflow.com/questions/49002614/is-it-possible-to-do-a-simple-health-check-of-rtsp-stream-with-curl-tool

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!