Comments (6)
You screenshot indicates a classic example of UDP buffer overflow, specifically during an I-frame which normally requires a few dozen UDP packets to arrive in time. Assuming a reasonably fast system I would only expect to see that during startup.
The issue is relatively simple, ring-client-api relies on werift, a WebRTC implementation entirely in Typescript (Javascript). Javascript is fairly fast for an interpreted language, and the werift code path is fairly optimized, but it's still not ideal for real time streaming.
Even worse, when werift opens a UDP socket, it just uses the default socket receive buffer. You say above that are running on Windows, which I believe defaults to a 64K UDP receive buffer by default. That means that if node can't make it through the event loop in time to service the inbound packets, well, it's UDP, so older packets are just thrown away as newer packets arrive.
With such a small receive buffer, it can be quite difficult for werift to read data from the socket without buffer overflows, this is especially true during initial startup, usually it stables out after the first few seconds.
You see this problem on Linux as well, especially slower devices like RPi 3/4, as Linux only has a 100k default buffer (still larger than Windows). The solution on Linux is to use sysctl to increase the size of net.core.rmem_max
and net.core.rmem_default
. For Windows, I think you have to modify the registry and restart:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AFD\Parameters]
"DefaultReceiveWindow"=dword:00200000
"DefaultSendWindow"=dword:00200000
If you set those values you should get a default 2MB buffer which should help quite a bit, although it may not completely get rid of the issue. I've played with values from 2-8MB, but 2MB usually seems to be enough and has the least impact on latency (may not matter if your are just recording, matters more for viewing a live stream).
from ring.
Regarding onMotionDetected, you didn't really provide much to go on so it's not clear if you are receiving motion events or not. This is unrelated to cameraStatusPollingSeconds
since motion events use push notifications and are not updated by polling, and generally you should use a fairly infrequent polling time here (20 seconds is my recommendation as the Ring API does not update quickly anyway so polling more often is mostly wasting resources for no benefit).
At first glance it appears you are attempting to record the video to a file, so you should probably just use recordToFile()
function instead. I'm not really sure what you are using -r for, as I believe that is setting the frame rate, but you can change the frame rate without transcoding which is not done by default.
Overall there are plenty of examples available.
from ring.
OK, I believe I know why onMotionDetected is not working for you. I'm guessing that you simply generated a new token with the CLI, stored this in an env file, and then are using that token each time you run the app, however, if you do this, notifications will work the first time, but will not continue to work on subsequent uses.
The reason why is that, on first use, the token is updated with additional information, such as the system ID and FCM token, which also must be persistent. If you keep connecting to the API with the CLI generated token, you'll get a new FCM token on each startup and notifications will stop working since Ring doesn't allow the FCM token to change after initial registration.
You should make sure you are moinotiring onRefreshTokenUpdated as documented in https://github.com/dgreif/ring/wiki/Refresh-Tokens#refresh-token-expiration.
from ring.
from ring.
What do you mean by "like how ring actually does it"?
The ring-client-api project includes everything that is needed to start a live stream exactly the way Ring does it (it uses the same API used by the Ring apps and Ring web dashbaord) and from there you can pretty much do anything you want with the stream.
The links I provided above include examples showing, for example, how to stream via HLS in a browser, and there are projects like homebridge-ring, which stream to Homekit, and ring-mqtt, which can stream to any RTSP capable client.
from ring.
I know that this closed a while ago but is there a chance you can link me where the HLS example is that you mentioned. I am currently trying to stream via HLS and I'm not sure how so it would be greatly appreciated. I apologize for causing any inconveniences, I know I've asked a lot of questions today.
from ring.
Related Issues (20)
- myQ Integration HOT 1
- Alarm triggered when using Apple Home intercom HOT 2
- Front door Ring doorbell motion pop up notifications no longer show up on Apple TV 4K HOT 5
- Difference in quality between Ring Camera (getSnapshot) and video search HOT 1
- brief delay in HomePods chime when pressing intercom button HOT 3
- Live Streaming of camera fails after HomeKit architecture upgrade HOT 6
- RIng Server Failure with latest Node.JS HOT 1
- Ring Homebridge camera becomes non-responsive at Apple TV after ~ 5 minutes. HOT 4
- Ring Intercom HOT 1
- Trouble recording video to file or live streaming on an M1 Mac Mini HOT 3
- Ring Plugin v 12.1.0 works for everything but Live Video in Homebridge HOT 1
- Ring Door Opener not working anymore HOT 5
- Add Chime Pro Nightlight as Automation Option HOT 3
- Ring Intercom - not possible to choose which HomePods should ring HOT 8
- Strange error when viewing live streaming from "Home" app HOT 1
- Battery Level in Home
- Ring Intercom HOT 5
- Accessories not exposed to HomeKit HOT 1
- onDoorbellPressed not sending updates HOT 1
- Response Code 422 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ring.