Start/stop OBS recording remotely via Python or similar?

Billius44

New Member
Hi there,

We want to set OBS up manually, but then Start/Stop recording remotely via software trigger. We are running a completely different piece of software on the same Windows workstation, and we want to start/stop OBS recording in sync with this software. The software has a Python interface, so that could be an easy route for us.

Start/stop recording could be via Python - I can see OBS has a Python interface, or it could be via a dedicated OBS plugin?

I've been wading through the forums and resources, but nothing is leaping out at me. Can someone point me in the right direction, please?

Thanks in advance,

Bill
 

Billius44

New Member
OK, thanks for putting me on the right track. I had to wade through a lot of docs on the websocket pages, and dive into the Python SDK for what was a fairly simple task. My use case is fairly basic, as we configure OBS manually, and we just use websocket to start and stop recording remotely to sync with external triggers.

So, just in case this is useful for others in future, here is my simple Python code to "Start Recording" or "Stop Recording":

# Python script to connect to OBS websocket and remote start recording. Must be running on the same machine as OBS

# we use the obsws_python library (OBS websocket)
import obsws_python as obs

# pass connection info if not in config.toml (we set these params within OBS in Tools -> obsWebsocket settings)
cl = obs.ReqClient(host='localhost', port=4455, password='XXXXXX', timeout=3)
#
# resp = cl.get_version()

# Access its field as an attribute, useful for testing that Python can talk to OBS correctly
# print(f"OBS Version: {resp.obs_version}")

# start recording in OBS

cl.start_record()

# or STOP recording in OBS

cl.stop_record()
 
Top