-
-
Notifications
You must be signed in to change notification settings - Fork 404
Add JSON-API support for requesting image snapshots #1839
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
Conversation
… the current image via JSON-API
@xIronic Thank you for your PR and contribution! After having an initial review, let me share some feedback/considerations. a) having the ApI responding with image data is perfectly fine, as it fits the request for that data. b) It would be great, if you could add an optional „instance“ element (see other Schemas for reference). The users with multiple instances can choose where to pick a snapshot from c) You might want to allow passing the output „format“ of the returned image. d) I am still thinking, if it might make sense to change the command to „instance-data“ Besides storing the image on disk, all other comments are to support scenarios that other user might benefit from on top of your provided code. |
@Lord-Grey a) Not doing any additional I/O on the server filesystem seems like a good approach to me. I will remove the path attribute. In fact, my script already uses requests and responses to avoid sd card wear. b) Right, I forgot that the user can choose the capture source based on the instance. I will change it accordingly. c) I've had this idea before and I like it. For example, the user could choose a format that is not compressed further. d) This makes sense and the command would be more in line with the API. When I have some spare time, I will try to rewrite my API extension to be more comprehensive and extensible. |
… getImageSnapshot and getLedSnapshot.
@Lord-Grey The last commit fixed some formatting issues in JsonApi.cpp that my vscode introduced. I am still working out how to adapt it to an existing formatting standard a given file has. |
Thank you for your time incorporating the proposed changes. |
@xIronic I just did the two outstanding code changes that we can put the PR to bed. |
Summary
This PR adds support for requesting a snapshot of the current screen via the JSON-API. By sending the "getImageSnapshot" command, the API responds with a base64-encoded JPEG image.
Alternatively, one can a request a snapshot of the current LED data for a given instance.
For example, this could be a message sent to the JSON-API:
Request: getImageSnapshot
Response:
Request: getLedSnapshot
Response:
The main purpose of this feature is to support an external script that analyses time-shifted snapshots to detect whether my USB grabber has crashed. If a crash is detected, the grabber is reset, and Hyperion is restarted.
This approach eliminates the need for V4L2 loopbacks, as only one process can access my /dev/video* device at a time.
What kind of change does this PR introduce? (check at least one)
If changing the UI of web configuration, please provide the before/after screenshot:
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing setups:
The PR fulfills these requirements:
Fixes: #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
PLEASE DON'T FORGET TO ADD YOUR CHANGES TO CHANGELOG.MD
To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.
Other information:
If this feature is of interest to others and is likely to be merged, I will update the documentation accordingly.