I am trying to edit the text of an obs source, as well as an image.
I don't get any errors and I am able to switch scenes using
ws.call(requests.SetCurrentProgramScene(sceneName=scene_name))
,
so my WebSocket connection works.
I am using OBS 30 with the integrated WebSocket and the obs-websocket-py
package.
This is my full code:
from obswebsocket import obsws, requests
new_image_file_path = "image.png"
source_name_text = "text"
source_name_image = "image"
def connect():
host = "localhost"
port = 4455
password = "myPassword"
ws = obsws(host, port, password)
ws.connect()
run(ws)
def run(ws):
request = requests.SetSourceSettings(
sourceName=source_name_image,
sourceSettings={"file": new_image_file_path}
)
ws.call(request)
ws.call(requests.SetTextGDIPlusProperties(
source_name=source_name_text,
text="text"
))
if __name__ == '__main__':
connect()
I checked, if the connection to the WebSocket works and it does.
I tried using different variations I could find, but non of them were any help.
Those requests are for WebSocket plugin version 4.
OBS 28 and newer, comes with builtin WebSocket plugin version 5, where SetSourceSettings
and SetTextGDIPlusProperties
requests don't exist anymore.
They were replaced with SetInputSettings
.
This is the new way of doing it:
ws.call(requests.SetInputSettings(
inputName=source_name_image,
inputSettings={
"file": new_image_file_path,
}
))
ws.call(requests.SetInputSettings(
inputName=source_name_text,
inputSettings={
"text": "text",
}
))