obs example added.

README for obs example added
This commit is contained in:
onyx-and-iris 2022-10-06 20:29:03 +01:00
parent 4ee37f54c5
commit e0f4aab257
2 changed files with 108 additions and 0 deletions

39
examples/obs/README.md Normal file
View File

@ -0,0 +1,39 @@
## Requirements
- [OBS Studio](https://obsproject.com/)
- [OBS Python SDK for Websocket v5](https://github.com/aatikturk/obsws-python)
## About
Perhaps you have a streaming setup but you want to control OBS and Voicemeeter from a remote location with python installed.
With the vban-cmd and obsws-python packages you may sync a distant Voicemeeter with a distant OBS over LAN.
The script assumes you have OBS connection info saved in a config file named `config.toml` placed next to `__main__.py`.
It also assumes you have scenes named `START` `BRB` `END` and `LIVE`.
A valid `config.toml` file might look like this:
```toml
[connection]
host = "gamepc.local"
port = 4455
password = "mystrongpass"
```
## Use
Simply fill in the OBS websocket details into `config.toml` and your VBAN text request settings in the script (`ip`, `streamname` and `port`).
Make sure you have established a working connection to OBS and the remote Voicemeeter.
Change OBS scenes and watch Voicemeeter parameters change.
Pressing `<Enter>` will exit.
## Notes
This script can be run from a Linux host since the vban-cmd interface relies on UDP packets and obsws-python runs over websockets.
You could for exmaple, set this up to run in the background on a home server such as a Raspberry Pi.
It requires Python 3.10+.

69
examples/obs/__main__.py Normal file
View File

@ -0,0 +1,69 @@
import logging
import obsws_python as obs
import vban_cmd
def on_start():
vban.strip[0].mute = True
vban.strip[1].B1 = True
vban.strip[2].B2 = True
def on_brb():
vban.strip[7].fadeto(0, 500)
vban.bus[0].mute = True
def on_end():
vban.apply(
{
"strip-0": {"mute": True},
"strip-1": {"mute": True, "B1": False},
"strip-2": {"mute": True, "B1": False},
}
)
def on_live():
vban.strip[0].mute = False
vban.strip[7].fadeto(-6, 500)
vban.strip[7].A3 = True
def on_current_program_scene_changed(data):
scene = data.scene_name
print(f"Switched to scene {scene}")
match scene:
case "START":
on_start()
case "BRB":
on_brb()
case "END":
on_end()
case "LIVE":
on_live()
case _:
pass
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
kind_id = "potato"
opts = {
"ip": "gamepc.local",
"streamname": "Command1",
"port": 6980,
"subs": {"pdirty": False},
"sync": True,
}
with vban_cmd.api(kind_id, **opts) as vban:
cl = obs.EventClient()
cl.callback.register(on_current_program_scene_changed)
while cmd := input("Press <Enter> to exit\n"):
if not cmd:
break