我有一个运行在rtsp链接上的摄像头。我想写python代码来检查相机是活动的还是死的。类似于使用curl检查http是否正常工作。可以用来检查rtsp url状态的类似命令是什么?
我试过在终端上使用openRTSP,我想把它用作python脚本
测试rtsp:// openRTSP _url_here
发布于 2019-06-08 13:27:48
您可以调用FFMPEG来提取快照。如果成功,则可以访问流。
在https://broadcastlivevideo.com/publish-ip-camera-stream-to-website/的教程中使用https://videonow.live/broadcast-ip-camera-or-stream/测试此功能(从rtsp中提取快照)。
提取的命令应该类似于:
/usr/bin/ffmpeg -y -frames 1 snapshot.png -rtsp_transport tcp -i rtsp://test_url_here然后检查快照文件是否已创建且不为空。
你可以在这个免费的开源可湿性粉剂插件https://wordpress.org/plugins/videowhisper-live-streaming-integration/中找到确切的功能代码。
发布于 2019-06-08 19:47:15
您可以使用opencv_python模块播放rtsp流。
示例代码:
import cv2
cap=cv2.VideoCapture("rtsp://admin:admin123@test_url_here")
ret,frame = cap.read()
while ret:
ret,frame = cap.read()
cv2.imshow("frame",frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
cap.release()https://stackoverflow.com/questions/56439798
复制相似问题