-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting snapshots of specified timestamp #58
Comments
Great suggestion, thanks! Will definitely look into that at some point. If I remember correctly, there is an endpoint somewhere that can return snapshots for specific timestamps – but it's not the A first guess from my side would be that the |
Your theory about the I haven't found anything easier yet. I was thinking it'd be neat to use this to make a retroactive timelapse of a camera (retroactive in the sense that it has already been recorded), instead of using a cron job to actively grab snapshots over time like https://lazyadmin.nl/home-network/unifi-protect-timelapse/. |
I poked around some more through a combination of inspecting network requests on the Moving the time bar slider around in the UI generates requests to a few "proxy" APIs.
For both the Some code to reproduce these observations is here (https://github.com/benjholla/UnifiProtectClient/blob/f9f4b7e6c26d1e3008d7e181330ca917bee112af/UnifiProtectSnapshots/src/snapshots/UnifiProtectClient.java), but since I don't know what to send back after connecting to the server this path isn't looking promising. For my purposes I might just go with the easy way out of grabbing the smallest video clip I can starting at the timestamp I want and then just extracting the first frame. Ideally there would be a better way though.
|
Ok the quick and dirty way of download video and extract first frame works pretty good. If you set start time and end time to be the same the resulting video ends up being a few seconds and around 2mb downloads. If you're local this probably isn't a big deal. Here's some Java code that calls ffmpeg to get the first frame. |
Thanks a lot! 👍 |
The protect API has a snapshot endpoint parameter of
ts
/cameras/{camera_id}/snapshot?ts={timestamp}
but currently the snapshot command hardcodes the current time. It would be great if we could specify a timestamp for which to retrieve the snapshot.Sadly, playing with the API it seems this parameter is actually ignored and I always get a latest camera snapshot (re-requesting the same timestamp returns new updated images from protect). Maybe this is why this project hardcodes the
ts
parameter to now? There are a few other approaches I thought of, but haven't had any success yet.The timelapse API appears to be using web sockets to send specified snapshots.
https://{ip}/proxy/protect/api/ws/timelapse?camera={camera_id}&channel=0&end={timestamp}&format=FMP4&reverse=true&start=0
returns JSON with a URL containing a unique id that resolves to the download URL{"url":"wss://{ip}:7443/ws/timelapse?uniqid={ws_unique_id}"}
Download a very short video using existing framework with timestamp set as start and minimum interval end from start then use ffmpeg or another utility to extract the first frame.
The text was updated successfully, but these errors were encountered: