Automating OBS from PowerShell Script

Open Broadcaster Software (OBS) is a great, open source, product that can be used to capture, record and stream a mixture of sources. With support for Decklink cards, it is easy to include the output of an ATEM vision mixer.

Using Windows PowerShell would let you automate OBS using XKeys or a Midi device and even coordinate switching ATEM inputs or playing out graphics from CasparCG at the same time (see my other PowerShell add-ons in https://ianmorrish.wordpress.com/v-ise/)

What you need:

Web Socket add-in for OBS https://obsproject.com/forum/resources/obs-websocket-remote-control-of-obs-studio-made-easy.466/download?version=1124

The following files in your Documents\WindowsPowerShell directory (remember to un-block them after downloading)

WebSocket-Sharp.dll https://1drv.ms/u/s!ApGpqMMpRLhijrNWU5eDhO1PzJZkAg

NewtonSoft.Json.dll https://1drv.ms/u/s!ApGpqMMpRLhijrNYgWt2nKGOqx2XGQ

OBS-WebSocket-Net.dll https://1drv.ms/u/s!ApGpqMMpRLhijrNXDV9u52u6CWbdbQ

Sample script

Add-Type -path ‘documents\WindowsPowerShell\obs-websocket-dotnet.dll’
$obs = new-object OBSWebsocketDotNet.OBSWebsocket
$obs.Connect(“ws://127.0.0.1:4444”, “password”)
$scenes = $obs.ListScenes()
$scenes
$obs.SetCurrentScene(“Intro”)
#Loop through each scene
$loop = $true; $i =1
Do{
$obs.SetCurrentScene($scenes[$i].Name)

if($i -eq $scenes.Count){$i=1}
   else{$i++}
Start-Sleep 5
}While($loop)
#Other commands
$obs.ToggleStreaming()
$obs.ToggleRecording()

All methods and properties for OBS Websocket:
OBSCommands

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s