ring-mqtt: RTSP steams always failing, but snapshots and other entities working in HA
Describe the problem
I am able to get ring-mqtt 5.4.1 running via Docker. But everytime I try to run the RTSP stream, it fails in VLC. I am using the url 'rtsp://192.168.1.184:8558/90486c0ef167_live '. It is also not working when adding a generic camera in HA. Although, the snapshot does work, as well as all of the other entities added to HA via MQTT. When the stream fails, it looks like in the logs that it attempts to open the stream several times.
Describe your environment
Running via Docker on Unraid. Using a Ring Video Doorbell (2nd Gen) wired. Video feed is working in the app.
Describe any steps you’ve taken to attempt to resolve the problem
Tried adding username / password, with the same result.
Config:
{
"mqtt_url": "mqtt://192.168.1.3:1883",
"mqtt_options": "",
"livestream_user": "",
"livestream_pass": "",
"disarm_code": "",
"enable_cameras": true,
"enable_modes": false,
"enable_panic": false,
"hass_topic": "homeassistant/status",
"ring_topic": "ring",
"location_ids": []
}
Debug Logs
2023-06-28T17:55:10.601Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/status online
2023-06-28T17:55:12.602Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/motion/attributes {"lastMotion":1687972897,"lastMotionTime":"2023-06-28T17:21:37Z","personDetected":false,"motionDetectionEnabled":true}
2023-06-28T17:55:12.603Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/motion_detection/state ON
2023-06-28T17:55:12.841Z ring-rtsp [go2rtc] DBG [rtsp] new consumer stream=90486c0ef167_live
2023-06-28T17:55:12.841Z ring-rtsp [go2rtc] DBG [exec] run url="exec:/app/ring-mqtt/scripts/start-stream.sh 90486c0ef167 live ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167 {output}"
2023-06-28T17:55:12.853Z ring-rtsp [Front Door] Sending command to activate live stream ON-DEMAND
2023-06-28T17:55:12.855Z ring-mqtt [Front Door] Received set live stream state ON-DEMAND rtsp://127.0.0.1:8554/fb3e5ae3254b0ac6f8f6fd8d6383e39d
2023-06-28T17:55:12.855Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/state ON
2023-06-28T17:55:12.855Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/attributes {"status":"activating"}
2023-06-28T17:55:12.856Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/event_stream/attributes {"status":"inactive"}
2023-06-28T17:55:12.856Z ring-mqtt [Front Door] Initializing a live stream session for Ring cloud
2023-06-28T17:55:12.881Z ring-mqtt [Front Door] TypeError: Cannot read properties of undefined (reading 'url')
2023-06-28T17:55:12.881Z ring-mqtt [Front Door] Failed to retrieve recording URL for Motion 1 event
2023-06-28T17:55:12.881Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/state ON
2023-06-28T17:55:12.881Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/attributes {"status":"activating"}
2023-06-28T17:55:12.881Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/event_stream/state OFF
2023-06-28T17:55:12.881Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/event_stream/attributes {"status":"inactive"}
2023-06-28T17:55:12.881Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/event_select/state Motion 1
2023-06-28T17:55:12.882Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/event_select/attributes <recording_url_masked>
2023-06-28T17:55:12.882Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/motion/state OFF
2023-06-28T17:55:12.882Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/motion/attributes {"lastMotion":1687972897,"lastMotionTime":"2023-06-28T17:21:37Z","personDetected":false,"motionDetectionEnabled":true}
2023-06-28T17:55:12.882Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/ding/state OFF
2023-06-28T17:55:12.882Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/ding/attributes {"lastDing":0,"lastDingTime":"none"}
2023-06-28T17:55:12.882Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/ding_duration/state 180
2023-06-28T17:55:12.882Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/motion_duration/state 180
2023-06-28T17:55:12.883Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/snapshot_mode/state Auto
2023-06-28T17:55:12.883Z ring-mqtt [Front Door] Requesting an updated interval snapshot
2023-06-28T17:55:12.883Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/snapshot_interval/state 600
2023-06-28T17:55:12.933Z ring-rtsp [Front Door] State indicates live stream is activating
2023-06-28T17:55:12.958Z ring-rtsp [Front Door] State indicates live stream is activating
2023-06-28T17:55:13.038Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/info/state {"batteryLevel":100,"batteryLife":100,"firmwareStatus":"Up to Date","lastUpdate":"2023-06-28T17:26:02Z","wirelessNetwork":"Computer_Guest1","wirelessSignal":-63}
2023-06-28T17:55:13.039Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/wireless/attributes {"wirelessNetwork":"Computer_Guest1","wirelessSignal":-63}
2023-06-28T17:55:13.039Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/battery/attributes {"batteryLevel":100,"batteryLife":100}
2023-06-28T17:55:13.163Z ring-mqtt [Front Door] Live stream session successfully initialized, starting worker
2023-06-28T17:55:13.165Z ring-wrtc [Front Door] Live stream WebRTC worker received start command
2023-06-28T17:55:13.198Z ring-wrtc [Front Door] Live stream transcoding process is starting
2023-06-28T17:55:13.573Z ring-wrtc [Front Door] Websocket signaling for Ring cloud connected successfully
2023-06-28T17:55:13.582Z ring-mqtt [Front Door] Successfully retrieved updated snapshot
2023-06-28T17:55:13.582Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/snapshot/image <binary_image_data>
2023-06-28T17:55:13.583Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/snapshot/attributes {"timestamp":1687974914}
2023-06-28T17:55:14.329Z ring-wrtc [Front Door] Live stream transcoding process has started
2023-06-28T17:55:34.381Z ring-wrtc [Front Door] Live stream WebRTC session has disconnected
2023-06-28T17:55:34.381Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/state OFF
2023-06-28T17:55:34.382Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/attributes {"status":"inactive"}
2023-06-28T17:55:34.419Z ring-rtsp [Front Door] State indicates live stream has gone inactive
2023-06-28T17:55:34.420Z ring-rtsp [go2rtc] DBG [exec] run url="exec:/app/ring-mqtt/scripts/start-stream.sh 90486c0ef167 live ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167 {output}"
2023-06-28T17:55:34.429Z ring-rtsp [Front Door] Sending command to activate live stream ON-DEMAND
2023-06-28T17:55:34.431Z ring-mqtt [Front Door] Received set live stream state ON-DEMAND rtsp://127.0.0.1:8554/fb3e5ae3254b0ac6f8f6fd8d6383e39d
2023-06-28T17:55:34.431Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/state ON
2023-06-28T17:55:34.432Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/attributes {"status":"activating"}
2023-06-28T17:55:34.432Z ring-mqtt [Front Door] Initializing a live stream session for Ring cloud
2023-06-28T17:55:34.509Z ring-rtsp [Front Door] State indicates live stream is activating
2023-06-28T17:55:34.690Z ring-mqtt [Front Door] Live stream session successfully initialized, starting worker
2023-06-28T17:55:34.690Z ring-wrtc [Front Door] Live stream WebRTC worker received start command
2023-06-28T17:55:34.696Z ring-wrtc [Front Door] Live stream transcoding process is starting
2023-06-28T17:55:35.043Z ring-wrtc [Front Door] Websocket signaling for Ring cloud connected successfully
2023-06-28T17:55:35.497Z ring-wrtc [Front Door] Live stream transcoding process has started
2023-06-28T17:55:36.255Z ring-wrtc [Front Door] Live stream WebRTC session has disconnected
2023-06-28T17:55:36.256Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/state OFF
2023-06-28T17:55:36.256Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/attributes {"status":"inactive"}
2023-06-28T17:55:36.294Z ring-rtsp [Front Door] State indicates live stream has gone inactive
2023-06-28T17:55:36.295Z ring-rtsp [go2rtc] DBG [exec] run url="exec:/app/ring-mqtt/scripts/start-stream.sh 90486c0ef167 live ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167 {output}"
2023-06-28T17:55:36.302Z ring-rtsp [Front Door] Sending command to activate live stream ON-DEMAND
2023-06-28T17:55:36.304Z ring-mqtt [Front Door] Received set live stream state ON-DEMAND rtsp://127.0.0.1:8554/fb3e5ae3254b0ac6f8f6fd8d6383e39d
2023-06-28T17:55:36.304Z ring-mqtt [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/state ON
2023-06-28T17:55:36.304Z ring-attr [Front Door] ring/cf988c80-4c29-472c-8b29-ae5424d5c633/camera/90486c0ef167/stream/attributes {"status":"activating"}
2023-06-28T17:55:36.304Z ring-mqtt [Front Door] Initializing a live stream session for Ring cloud
2023-06-28T17:55:36.376Z ring-rtsp [Front Door] State indicates live stream is activating
2023-06-28T17:55:36.598Z ring-mqtt [Front Door] Live stream session successfully initialized, starting worker
2023-06-28T17:55:36.599Z ring-wrtc [Front Door] Live stream WebRTC worker received start command
2023-06-28T17:55:36.606Z ring-wrtc [Front Door] Live stream transcoding process is starting
2023-06-28T17:55:36.952Z ring-wrtc [Front Door] Websocket signaling for Ring cloud connected successfully
2023-06-28T17:55:37.112Z ring-wrtc [Front Door] Live stream transcoding process has started
2023-06-28T17:55:38.601Z ring-disc Republishing existing device id: 90486c0ef167
2023-06-28T17:55:38.602Z ring-disc HASS config topic: homeassistant/binary_sensor/cf988c80-4c29-472c-8b29-ae5424d5c633/90486c0ef167_motion/config
2023-06-28T17:55:38.602Z ring-disc {
name: 'Front Door Motion',
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 41 (20 by maintainers)
Well, transcoded events are pretty horrible. It’s effectively the same as selecting to “download” a video in the Ring app. Ring transcodes the video to include timestamps from the event and their watermark, but the actual resulting file is pretty crappy (it’s like the hard stich the pre-buffer together) and the video is not optimized for streaming at all and thus streams very poorly in most cases, likely because it’s optimized for local playback since it’s a “download” and it does work fine for this use case.
Unfortunately, it’s so bad that I have to use ffmpeg to re-transcode with the ultrafast preset (because that’s the only one that has a prayer of working on lower end hardware like RPis) to try to get it back into something marginally stream-able. But the tradeoff made by the ultrafast preset to get decent quality with fairly low CPU is to create a much larger file, which in turn produces a much higher bitrate than would normally be required for similar quality H.264 video.
I played around with a different approach, using Ring’s API for “sharing” the file vs “downloading” the file. In this case the transcoded video seems far more optimized for streaming, which makes sense as that is the intended use case of that feature, and of course the file can still be downloaded in this case. In many ways this is even easier than the “download” method because the shared link is permanent while the download link expires every 180 seconds, but this also had the side effect that every single video ends up with a permanent link that can play it without any other authorization (basically, a magic link) and then the video stored on Ring servers, apparently, forever. Well, I don’t actually know how long, but longer than the normal 60 days or whatever as I have a handful a videos of some deer roaming my front yard that I shared back in 2021 that are still there to this day. Ring might not like this if I did this for every video and, on top of that, having all user videos with a non-expiring link seems not exactly super-safe, so I stuck with the current approach for now.
I have considered the possibility of downloading the file locally, to /tmp or something, which should make it less of an issue since the local streamer (ffmpeg) would be able to analyze the entirety of the file vs try to stream it on-demand from AWS S3. Streaming the file from local storage seems to work just fine, but then you have to manage files, etc. Might happen one day.
@Scope666 Interesting findings and good sleuthing! I wonder if it’s just due to overrunning the queue in the switch. During initial startup of the stream there’s a period of time where Ring is sending data, but werift isn’t forwarding the packets yet. This data builds in the UDP receiver buffer and, once the full stream gets going, those initial packets are sent in a very fast burst through the pipeline. The stream then settles down to a more typical rate. I wonder if the TP-link is just dropping a lot of those initial packets because its queue is too small (it must have some queue since it appears to have QoS). That could potentially explain why the single camera, which for some reason negotiates a slightly lower bitrate, somehow works, it could be just right on the edge.
Anyway, interesting, but at this point it seems not related to the issue @guythnick is having, so I’m going to copy your response with the resolution to your original issue and then hide the other comments about your issue from this thread as “resolved” to hopefully avoid confusion. I really appreciate your efforts and willingness to dig so deep into the issue and I’m glad you found a resolution for your specific case. It does remind us that networking gear can still be a source of unexpected issues!