A websocket client for OBS Studio in Python.
Project description
OBS WebSocket Client
A Python library for interacting with OBS Studio through its WebSocket protocol (v5.x.x). This client provides a simple async interface to control OBS Studio programmatically.
Features
- Support for OBS WebSocket 5.x.x protocol
- Asynchronous interface using asyncio
Requirements
- Python 3.9 or higher
- OBS Studio 28.0.0 or higher with WebSocket server enabled
Installation
This package uses Poetry for dependency management. Make sure you have installed Poetry (v1.8.3). Then simply run:
poetry install
Setting up OBS WebSocket Server
- Open OBS Studio
- Go to Tools -> WebSocket Server Settings
- Enable WebSocket server
- Set the Server Port (default is 4455)
- Optionally set the password for authentication
Quickstart
Below is a simple code snippet that demonstrates the usage of ObsWsClient to start and stop recording in OBS Studio. For more examples, checkout the example folder.
from obswsc.client import ObsWsClient
from obswsc.data import Request
import asyncio
async def main():
client = ObsWsClient(url='ws://localhost:4455')
async with client:
await client.request(Request('StartRecord'))
await asyncio.sleep(10.0)
res = await client.request(Request('StopRecord'))
print(f'recorded video: {res.res_data["outputPath"]}')
asyncio.run(main())
License
This project is licensed under the MIT License.
Acknowledgments
- Thanks to the OBS Studio team for creating the WebSocket protocol.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file obs_ws_client-0.1.0.tar.gz.
File metadata
- Download URL: obs_ws_client-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.7 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3d0e5c2ba81e54458e0650575dce4db66e2e76b9c0befb3e0e80194eb048cf7
|
|
| MD5 |
a037bc6a7057744ab611a3213209edd4
|
|
| BLAKE2b-256 |
a9f4b218564e082f2dd396c212064b20c587dd867341bd7ccb08f909806b6980
|
File details
Details for the file obs_ws_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: obs_ws_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.7 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab0bda953c20b73a54c2bfd3b1a60372face3b2d145cf13121df6bb6e0876fb3
|
|
| MD5 |
5747fc79fa62aeefd52b4c72d9efed3d
|
|
| BLAKE2b-256 |
e7de624f268d48051f6ff614772f1fb9ee37ddcfae718f8235bf493c57d4759e
|