Skip to content
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

Expose images through proxy for specific UNIX timestamps #321

Open
2 of 5 tasks
EliSchleifer opened this issue Dec 10, 2024 · 5 comments
Open
2 of 5 tasks

Expose images through proxy for specific UNIX timestamps #321

EliSchleifer opened this issue Dec 10, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@EliSchleifer
Copy link

Is your feature request related to a problem? Please describe.

I am looking to integrate Protect images with a LLM to scan for packages. I want to see images from 30 seconds after and 30 seconds before an event.

I don't think that the current proxy allows that since it is limited to video. Would be great to provide direct access something like

/unifiprotect/thumbnail/{nvrid}/{cameraId}/timestamp/{UNIX_TS}

Describe alternatives you've considered

Alternative is to use the IP address directly for anonymous snapshotting which is less secure and more annoying.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Are you willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time, and I know how to start.
  • Yes, I have the time, but I don't know how to start. I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
@EliSchleifer EliSchleifer added the enhancement New feature or request label Dec 10, 2024
@RaHehl
Copy link
Collaborator

RaHehl commented Dec 12, 2024

There is already a way to retrieve snapshots at a specific timestamp:
https://github.com/uilibs/uiprotect/blob/main/src/uiprotect/data/devices.py#L2006

For your use case, I’d personally recommend downloading the video clips and then extracting snapshots using ffmpeg. Since this method offloads the snapshot generation from the UniFi hardware to a separate machine, it’s likely to generate less load on the UniFi system.

Example using ffmpeg to extract one frame per second:

ffmpeg -i input_video.mp4 -vf fps=1 snapshot_%03d.jpg

This command will produce snapshot_001.jpg, snapshot_002.jpg, and so forth, for each second of the video. You can adjust the fps value as needed.

@RaHehl
Copy link
Collaborator

RaHehl commented Dec 12, 2024

Ah, I think I misunderstood you. You don’t want multiple screenshots from 30 seconds; you just need two in total. In that case, I would simply use the existing method in the camera object.

@EliSchleifer
Copy link
Author

EliSchleifer commented Dec 13, 2024 via email

@RaHehl
Copy link
Collaborator

RaHehl commented Dec 13, 2024

I think I understand what you are aiming for, but I don’t fully grasp the reasoning behind it yet. From what I see, the context here is a standalone Python library, not something specifically tailored for Home Assistant. This library doesn’t include a web server, which makes the idea less clear to me. The proxy implementations you’re referring to appear to be in Home Assistant, as shown in the link: https://github.com/home-assistant/core/blob/dev/homeassistant/components/unifiprotect/views.py#L67.

Are you aiming to connect this to an LLM within Home Assistant? That would make more sense to me, and in that case, I believe a feature request would be better placed there for the unifiprotect component, within the Home Assistant project.

As for alternative approaches, you might consider solutions like the AI Port on UniFi Protect https://techspecs.ui.com/unifi/cameras-nvrs/up-ai-port or using Frigate https://frigate.video/ with a Google Coral

@EliSchleifer
Copy link
Author

EliSchleifer commented Dec 13, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants