obs-websocket - Remote-control OBS Studio using WebSockets

obs-websocket - Remote-control OBS Studio using WebSockets 5.0.1

pietropavan77

New Member
I installed websockets but I cannot see it from within OBS 27.0.1.
I installed the last release of websocket 5.0.0.alpha2 from the windows installer... I read all instruction pages, but I cannot seem to identify where I can activate in OBS...
What did I do wrong ?
 

tt2468

New Member
I installed websockets but I cannot see it from within OBS 27.0.1.
I installed the last release of websocket 5.0.0.alpha2 from the windows installer... I read all instruction pages, but I cannot seem to identify where I can activate in OBS...
What did I do wrong ?
5.0.0-alpha2 is only meant to be used by developers and requires OBS >= 27.1.0. You should probably download 4.9.1
 

tt2468

New Member
(Duplicate of post at https://obsproject.com/forum/thread...al-analysis-web-sockets-also-involved.145612/)
I'm not quite sure of the best way to report this crash. I have done a certain amount of source code analysis, and it seems to lie in a grey area between OBS itself and the OBS web sockets plug-in, but I'm leaning more towards it being a core OBS issue. The crash has shown itself in the final OBS 26.x and in 27.0 on Mac (M1, Big Sur). It happens during change of Scene Collection. This is what seems to be happening in one particular crash.

- Nothing is written to the OBS log from this point
- The Scene Collection change starts
- All current sources are destroyed. Notifications are sent (from OBS events to OBS web sockets events) showing this has happened.
- About 0.2 seconds pass. The scene collection has not yet loaded and the UI is locked.
- An external app sends a request via OBS web sockets "GetSceneList". It does this every second, so it's likely to hit a lot of scene item collection changes.
- This results in a call to obs_frontend_get_scenes, and this function crashes. Details SYSSEGV, offset + 120 (version 27.0).

I speculate that the data structures in the UI are not in a good state at this point in the scene collection change. It would be better to lock out requests if they are going to cause crashes. Perhaps an event OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING could also be sent; this could also clue in monitor processes to just not bother themselves until OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED is sent, because even if all the requests are ok, there is likely to be a lot of redundant work.

I am working with a customised OBS websockets plug-in and would happily add tests to avoid this problem, but I can't really see what to look for. (The only other plug-in loaded is OBS Audio Monitor).
This is a known issue in the 4.x versions. 4.x's development has ceased. 5.x fixes this, but uses a whole new protocol.
 

tt2468

New Member
Hello everyone,

TLDR;
Cant call SetFilenameFormatting and SetRecordingFolder whlile advnced output mode is set.

I have been using this plugin for a while now and it's pretty amazing.
Though I have recently arrived at an "unsurpassable wall" of some sort.
Up until today my setup was using the "Simple" setting at the Settings->Output->Output Mode and I was able to set the recording location and name of my files remotely with ease.
Today, I have decided to update my output to DnxHd, which requires an "Advanced" output mode setting.
Activating this setting prevents me from setting the recording folder and file name remotely.

Am I missing something or should I settle with the "Simple" output mode?

Thanks :)
Known issue. Will be redesigned in 5.0.0 to work properly.
 

tt2468

New Member
Hello there,

I have a question about connecting to obs websocket and status information. I'm making a web page that can control scenes from my phone but after a while if the page isn't focussed/active it will disconnect. So as a prevention i have added some code that reconnects every time the page is refocussed just in case. This isn't the most elegant solution as I would rather just check to see if the connection is still active but I'm having trouble with that as well. Now this could be something I have missed but I cant seem to see any method or what have you to check the connection status while using the JavaScript library. I'm looking to basically check the connection is active and if it is then skip trying to connect to it again. Is that possible? If not is it ok to keep making connections to the obs websocket? Like it wont get to the point it will stop working becuase it thinks too many connections are being made? Is there a better way or reconnecting than just using obs.connect again?

Hope that makes sense!

Thanks a lot in advance :)

All the best,
Will :)
That's a question to ask the developers of the client library you are using. However you could also try to call `GetVersion` as a way of seeing if the connection is responding.
 

tt2468

New Member
Is there any way to interact with scene items (sources) that are [inside a group] using obs websocket?
Not in 4.x versions. Groups are very finnicky and are not officially supported in 4.x In 5.x versions we plan on documenting what can and cannot be done with groups.
 

kevmuller

New Member
I installed websockets but I cannot see it from within OBS 27.0.1.
I installed the last release of websocket 5.0.0.alpha2 from the windows installer... I read all instruction pages, but I cannot seem to identify where I can activate in OBS...
What did I do wrong ?
im having an issue where its crashing my obs immediately after install,
the source icons and the view/hide / Lock buttons glitch out and then it all freezes and crashes
anyone experiencing this?

OBSv 27.1.1
 

jcsam6289

New Member
Im having issue that the websocket was installed and i can't seems to save the password and causing me to can't connect my OBS to my Lioran Board, anyone knows how to solve this?
 

djdam

New Member
Hi,

I am trying to add a webcam source via obs websocket (js) but OBS does not initialize the webcam. I think it's because the webcam needs to be "detected" by OBS first: when I open / close the webcam I created via websockets in OBS, then it shows. But ofcourse I don't want to manually open/close the webcam all the time. Abybody having experience with this? Which websocket calls do I need?
 

roman.dusek

New Member
Hi, we use OBS for youtube streaming, using VLC Video Source containing several videos playing in the loop. I would like to use obs-websocket to monitor it and, in case of failure, start streaming again from the last known position.

I know how to get:
- list of videos inside VLC Video Source (using GetSourceSettings)
- total length and position inside the video that is currently streaming (using GetMediaDuration and GetMediaTime)
... but I did'n find a way to find out, which video (file) is currently streaming. Is there a way to get this information?

Thank you in advance for any help
Roman
 

BarrySDCA

New Member
I have a new issue after installing OBS 27.1.3 on Ubuntu 20.04. This seems to come bundled with OBS Web Sockets, which I have used for quite a while through obs-tablet-remote.

My issue is that once I connect, OBS crashes - it just closes. No errors, no nothing. Just closes.

I am prompted for the password, which I enter. And for a fraction of a second I can see the scenes and such loaded in obs-tablet-remote, but then it says the server is unavailable. And when I return to the machine, OBS is closed.

logs don't show anything. just closed.

ideas?

Thank you much
 

Treylav

New Member
I'm trying to connect to obs-websockets using the Python websockets library. I'm using the following basic code:
Python:
import asyncio
import websockets
import logging
import json
logging.basicConfig(level=logging.DEBUG)


async def obs():
    async with websockets.connect(uri='ws://localhost:4444') as websocket:
        await websocket.send(json.dumps({'op':1, 'd':{'rpcVersion':1}}))
        await websocket.recv()
        
asyncio.run(obs())
Despite the fact that my connection is successful, I cannot send any message:
Code:
DEBUG:asyncio:Using proactor: IocpProactor
DEBUG:websockets.client:= connection is CONNECTING
DEBUG:websockets.client:> GET / HTTP/1.1
DEBUG:websockets.client:> Host: localhost:4444
DEBUG:websockets.client:> Upgrade: websocket
DEBUG:websockets.client:> Connection: Upgrade
DEBUG:websockets.client:> Sec-WebSocket-Key: 0Wit8pQW5fvqvCLaS9gX2Q==
DEBUG:websockets.client:> Sec-WebSocket-Version: 13
DEBUG:websockets.client:> Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
DEBUG:websockets.client:> User-Agent: Python/3.10 websockets/10.1
DEBUG:websockets.client:< HTTP/1.1 101 Switching Protocols
DEBUG:websockets.client:< Connection: Upgrade
DEBUG:websockets.client:< Sec-WebSocket-Accept: qwAVo86irvt4WBvkUUSTgeTlWV4=
DEBUG:websockets.client:< Server: WebSocket++/0.8.1
DEBUG:websockets.client:< Upgrade: websocket
DEBUG:websockets.client:= connection is OPEN
DEBUG:websockets.client:> TEXT '{"op": 1, "d": {"rpcVersion": 1}}' [33 bytes]
DEBUG:websockets.client:< TEXT '{"error":"missing request parameters","status":"error"}' [55 bytes]
DEBUG:websockets.client:= connection is CLOSING
DEBUG:websockets.client:> CLOSE 1000 (OK) [2 bytes]
DEBUG:websockets.client:< CLOSE 1000 (OK) [2 bytes]
DEBUG:websockets.client:= connection is CLOSED
What am I doing wrong?
Thanks in advance.
 

bcoyle

Member
ok, confused. This syntax is version 5. Use of op is now v5 and not released , not currently how v4 works. v5 sends you a hello message (op = 0) with a key. You answer this with op = 1.

v5 sends this hello message on startup:

received from obs with web-socket type v5

{"d":{"authentication":{"challenge":"A6xVgZ4vq+xomYOK0mcWOWT2yl0LwCluUilYUmMgPrA=","salt":"PkWi7lTSowNpbYl7GYT9uF+gMMqBugQ5b5XqBWjxn50="},"obsWebSocketVersion":"5.0.0-622e1c9-git","rpcVersion":1},"op":0}

notice the op = 0

This is my answer back to v5:

{"op":1,"d":{"rpcVersion":1,"authentication":"bbc/RqKhXyz7f3s5h6QmyuesMBEV21/ajCAH5u7W7Wg=","ignoreInvalidMessages":true,"eventSubscriptions":255}}

You see there are more fields. I'm answering the password challenge. Are you really talking to v5 or did you get the wrong library and you should be talking v4.


if obs websocket is happy, it answers with something like this saying it's happy (op=2)

{"d":{"negotiatedRpcVersion":1},"op":2}

Ask yourself this:
1. Are you trying to talk to obs with the new versions of obs-websocket installed
2. Are you using v4 web socket
3. Is your library correct for v4 or v5
4. web sockets v4 does not use OP codes

did that help?
 
Last edited:

Treylav

New Member
ok, confused. This syntax is version 5. Use of op is now v5 and not released , not currently how v4 works.
Yes, you are right, this is the root of the problem. Apparently, at some point I switched to documentation for version 5.x, although I use 4.x.

Thanks for the constructive answer (and very useful plugin)!
 

dorian111

New Member
Has anyone seen an issue with using scene item visibility?

If I send the following JSON Payload:
{"request-type":"SetSceneItemProperties","message-id":"3025","scene-name":"Scene2","item":"1","visible":"false"}

the scene item visibility is correctly set to "false". However, if I send:
{"request-type":"SetSceneItemProperties","message-id":"3025","scene-name":"Scene2","item":"1","visible":"true"}

the visibility is not set to true; further, if the item is visible and I send the message with visible set to true, the item visibility is actually set to false.

Has anyone seen this, or does anyone have a potential workaround?
 

bcoyle

Member
Has anyone seen an issue with using scene item visibility?

If I send the following JSON Payload:
{"request-type":"SetSceneItemProperties","message-id":"3025","scene-name":"Scene2","item":"1","visible":"false"}

the scene item visibility is correctly set to "false". However, if I send:
{"request-type":"SetSceneItemProperties","message-id":"3025","scene-name":"Scene2","item":"1","visible":"true"}

the visibility is not set to true; further, if the item is visible and I send the message with visible set to true, the item visibility is actually set to false.

Has anyone seen this, or does anyone have a potential workaround?
I think your answer is that true and false are not strings and therefore not quoted. Numbers are not quoted, along with boolean.Very subtle at times .
this is what I send and it works fine, notice the false is not quoted.:
{"request-type":"SetSceneItemProperties","message-id":"69,OVERLAY_LOGO,False","scene-name":"OVERLAY_DESIGNER","item":"OVERLAY_LOGO","visible":false}
 
Top