-
Notifications
You must be signed in to change notification settings - Fork 23
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
More examples please and how do you select a source in a scene correctly? #52
Comments
Hi thanks for your questions!
Not sure I entirely understand. Since we're programmatically interacting with OBS, there's no need to "select" a scene. Instead we specify the scene and how we want to interact with it.
I added another example that creates some sources in a scene and then reverses them at https://github.com/andreykaipov/goobs/blob/master/examples/sceneitems/main.go. It uses the Below is some general advice. The way I usually use this library is by first looking through the obs-websocket protocol docs to see all the available requests and if any involve what I wanna do. This library is generated from those docs so all requests, events, parameters, documentation are practically 1-1. https://github.com/obsproject/obs-websocket/blob/5.1.0/docs/generated/protocol.md Any time I don't know what parameters to use for some request, I listen for the client events and inspect the logs. For example in the above example -
Specifically - |
I don't think so. There's this open feature request https://ideas.obsproject.com/posts/2225/allow-clean-shutdown-via-api which links to the currently open PR obsproject/obs-studio#8889. So the functionality is not even in OBS itself. Depending on what you wanna do, maybe you could kill the program externally and listen for the |
@andreykaipov thanks for your prompt reply. I'm using obs studio as a remote switcher (minimised no need to see UI) I switch scenes and sources in a scenes.
After spending a few hours, I managed to get source switching working using a 'for range' and iterating through the source list matching the source name then enabling the source I wanted to show with disabling the other sources in that scene. I'll post the code here shortly to let others know how to do so for additional help. As far as shutting down obs, I've tried killing its pid however doesn't shut down cleanly since obs spawns children threads which need to kill in a specific sequence. Far to dirty IMHO. The Exit button on obs UI is the best approach to shutdown obs however, seems there is yet to be a WebSocket method to do such. I've request to add the shutdown method in the next release on the obs forums however, I'm not sure if it be a priority for the obs team? Time will tell. Sorry for my incorrect statement?
There is a plugin to shut down obs which interacts with the obs api directly.
Be nice to have the Shutdown properly added to the Websocket and add it to your library. I see there is already a method stub ready to go. |
Ah I see, in the forum thread, that plugin was created as a workaround until obsproject/obs-studio#8889 and obsproject/obs-websocket#1138 are both in. It has an example which uses _, err := client.General.CallVendorRequest(&general.CallVendorRequestParams{
VendorName: "obs-shutdown-plugin",
RequestType: "shutdown",
RequestData: map[string]interface{}{
"reason": "cleaning up",
"support_url": "https://github.com/norihiro/obs-shutdown-plugin/issues",
"force": true,
},
}) You'd have to first install that plugin by copying its release into your OBS directory though. https://github.com/norihiro/obs-shutdown-plugin/releases |
Hello @andreykaipov, Below is my snippet of test code which I've put together to select a specific source within a Scene. Thought it could help others using the library. I do a getSceneList query and map to use for a local copy than having to websockets returning all the Scenes. Same principle can be extended to take a snapshot of all Sources per Scene.
|
Since this issue I've added a few more examples to the repo and added a "dev walkthrough" of sorts to https://github.com/andreykaipov/goobs/tree/main/docs#making-requests that hopefully provides some techniques for figuring out things like this for any folks from the future :) |
I'm having difficulty using the library.
Works fine for scene
How do you properly select a source within a scene?
Below pulls no errors however, the source isn't selected. What is the need for SceneItemIndex: 3, SceneItemId: 3, SceneName: "MyScene"? Any combination breaks.
Is there a method to shut OBS down? Apparently OBS can be closed via websockets?
The text was updated successfully, but these errors were encountered: