-
Notifications
You must be signed in to change notification settings - Fork 78
Websockets
It is possible to use the macros system to communicate with remote OBS instances using version 5.0 of the obs-websockets plugin.
Since version 28 of OBS the obs-websocket plugin is shipped with OBS itself so there is no need to install anything for this functionality.
To receive messages the macro condition "Websocket" can be used.
To send messages to other OBS instances the macro action "Websocket" can be used.
The supported message types that can be used with the "Websocket" action and condition are "Requests" and "Events".
- Requests (1) are sent to one specific target via the specified connection.
- Events (2) are sent to all clients that are connected to the obs-websocket server the event is emitted from.
This condition type will allow you to perform actions if certain messages or patterns are received from other OBS instances.
Simply enter the desired message into the text field (1).
If applicable check (2) to interpret the message as pattern to match incoming messages against.
If a matching message was received the condition will return true for the interval the message was received in.
This action type will allow you to send messages to other OBS instances which could then trigger macros on the remote OBS instance.
First select the connection you want to send the message to (1).
For more details on how to configure connections have a look at the upcoming sections.
Next enter the message you want to send in the text field at (2).
A new connection can be added to a websocket request action or websocket event condition by clicking on the "Add new connection" entry in the connection selection menu.
When selecting this entry a dialog will open in which you will have to enter the connection details:
- Unique name for this new connection (1).
- The address to connection to (2).
- The port to connect to on the specified address (3).
- The password required to connect to the websocket server (4).
- If you would like the plugin to automatically attempt to connect on OBS startup check (5).
- If you want the plugin to automatically attempt to reconnect once the connection is lost check (6) and enter the desired time after which reconnecting should be attempted.
- Finally you can check if the entered connection details are valid by clicking on the "Test connection" button (7).
If the status message reports "Connected and authenticated" all is well.
To modify the connection details of an existing connection simply select it in the drop down menu of a websocket action and click the marked gear symbol.
Next click the "Properties" entry and a dialog like described above will open in which you can modify the connection's settings.
The gear icon will also allow you to rename or remove existing connections.
The scene switcher is using the obs-websocket protocol to send and receive messages.
This can also be used by external tools to send messages, which can be processed by the plugin and thus trigger macros.
To send a message with the contents testing
one has to create a CallVendorRequest
type message using a vendorName
of AdvancedSceneSwitcher
and a requestType
of AdvancedSceneSwitcherMessage
and add the "message" field with the desired contents to the requestData
.
{
"d": {
"requestData": {
"requestData": {
"message": "testing"
},
"requestType": "AdvancedSceneSwitcherMessage",
"vendorName": "AdvancedSceneSwitcher"
},
"requestId": "someUniqueIdHere",
"requestType": "CallVendorRequest"
},
"op": 6
}
Below is an example configuration that can be used to send message Requests from "Bitfocus Companion" to the Advanced Scene Switcher plugin.
Field | Value |
---|---|
Request Type | CallVendorRequest |
Request Data | {"requestData":{"message":"testing"},"requestType":"AdvancedSceneSwitcherMessage","vendorName":"AdvancedSceneSwitcher"} |
An example event emitted by the Advanced Scene Switcher containing the message "testing" would be the following:
{
"d": {
"eventData": {
"eventData": {
"message": "testing"
},
"eventType": "AdvancedSceneSwitcherEvent",
"vendorName": "AdvancedSceneSwitcher"
},
"eventIntent": 512,
"eventType": "VendorEvent"
},
"op": 5
}
You will have to construct the message body in accordance with the OBS websocket protocol.
So you your message must at least include an op
and d
field and in most cases also the requestId
.
Here is an example who to send the websocket message to start a recording:
- Show webcam only when speaking
- Twitch Category Changer
- Show text source with latest Twitch follower
- Detect elements on screen and hide them automatically
- Motion detection
- Start other programs when starting OBS
- Crossfading audio during scene changes
- Switch scenes randomly
- Re-shuffle VLC source
- Automatically switch scene if a game capture's target window no longer exists
- Audio based scene switching in podcast setting
- Switching scenes based on portrait or landscape mode resolution of a window capture source
- Set up a hotkey to start and stop recording with a fade from and to black
- Automatically cycle through a list of scenes
- Toggle visibility of scene items on a timer
- Advance through a list of scenes by hotkey
- Performing actions only when transitioning from A to B
- Media playlist with commercial interruptions
- Split recording of stream into chunks
- Switching scenes for Aitum Vertical plugin
- Using MIDI devices
- Change capture window of Window Capture source
- Show URLs in clipboard in browser source
- General tab overview
- Starting and stopping the plugin
- Macros explained
- Creating a macro
- Pausing macros
- Macro duration modifiers
- Exporting and importing individual macros
- Audio condition
- Cursor condition
- Date condition
- Hotkey condition
- Media condition
- Process condition
- Scene item transform condition
- Slide Show condition
- Video condition
- Audio action
- Http action
- Hotkey action
- Random action
- Scene item visibility
- Sequence action
- Action Queue example
- Variables
- Websockets
- Scripting
- Scene groups
- Troubleshooting
- Saving and loading settings