Question / Help Is there any way to automate scene switching to create a slideshow of sources?

MrResistance

New Member
I need OBS to switch between multiple cameras over time, say every 30 seconds it switches to a different IP camera. I need an automated solution as I cannot be there to monitor it.
 

Montclair

New Member
Yes, download a program called Authotkey, and install it. Create a script to do the job, then run it. Here's a sample script that will cycle between 4 different scenes every 10 seconds. It assumes that you have 4 different scenes named "SceneSlide1" through "SceneSlide4". If you want to use it as is, copy all of below and save it to a file named "slideshow.ahk". When you run that file, it will launch Authotkey and begin the scene slideshow. Turn it off by exiting the program from the system tray. You can change the amount of time each scene runs by changing the milliseconds.

#Persistent
SetTimer, Slide1, 10000
SetTimer, Slide2, 20000
SetTimer, Slide3, 30000
SetTimer, Slide4, 40000
Return

Slide1:
Control, ChooseString, SceneSlide1, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide1, Off
Return

Slide2:
Control, ChooseString, SceneSlide1, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide2, Off
Return

Slide3:
Control, ChooseString, SceneSlide2 ListBox1, ahk_class OBSWindowClass
SetTimer, Slide3, Off
Return

Slide4:
Control, ChooseString, SceneSlide4, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide1, On
SetTimer, Slide2, On
SetTimer, Slide3, On
Return
 

Ohm Audio

New Member
Hi there, is there any way I can edit this .ahk to make it work with the new OBS studio version? Or any other suggestions if not? Regards, Jack.
 

Ohm Audio

New Member
Oh, so I found an example of some .ahk code for the studio version on youtube -
https://www.youtube.com/watch?v=kGTagaDMtWk
but can't work out what to edit for it to work with setup. My old code (I modified yours which worked for classic) is in the comments, any help with this would be much appreciated. Here's his code to save you clicking the link -

;
; AutoHotKey scene switcher / scheduler for OBS Studio
; Adam Powers - theCichlidShow.net
;
#InstallKeybdHook
#Persistent
#SingleInstance force
#NoEnv
#UseHook On

Menu, Tray, Icon, shell32.dll, 110

SetTitleMatchMode, 2
DetectHiddenWindows, On

scenes_by_name := Object()
scenes_by_name.4 := "SIDE CAMS"
scenes_by_name.3 := "FRONT CAM"
scenes_by_name.2 := "LEFT SIDE CAM"
scenes_by_name.1 := "RIGHT SIDE CAM"

; SCHEDULE ############################

; scene hotkey mappings, set these in OBS Studio
SIDES := 4
FRONT := 3
LEFT := 2
RIGHT := 1

; Add table entries here for each rotation event
table := [ [FRONT,25] ; scene, duration (seconds)
, [LEFT,15]
, [RIGHT,15]
, [FRONT,15]
, [SIDES,18] ]

; MAINLOOP ############################

Loop {
For key, value in table
{ scene := value.1 duration := value.2 Rotate(scene, duration)
}
}

; FUNCS ##############################

Rotate(scene,duration) {
; I couldn't get ControlSend to work with OBS Studio ; so I had to settle on WinActivate and Send.
WinActivate OBS
Send "!%scene%"
global scenes_by_name
while duration
{ WriteSceneAuto(duration,scenes_by_name[scene]) Sleep, 1000 duration := duration - 1
}
Return
}

WriteSceneAuto(duration,scene) {
; write to a file which is read in by OBS Studio
file := FileOpen("c:\rotation\scene_state.txt", "w")
file.WriteLine(scene . " (next cam in " . duration . ")")
file.Close()
Return
}

; shift-space pauses the switcher
+Space::
Suspend
file := FileOpen("c:\rotation\scene_state.txt", "w")
file.WriteLine("CAMERA PAUSED")
file.Close()
Pause ,, 1
Return
 

Ohm Audio

New Member
my old code -

#Persistent
SetTimer, Slide1, 10000
SetTimer, Slide2, 60000
SetTimer, Slide3, 120000
SetTimer, Slide4, 180000
SetTimer, Slide5, 240000
SetTimer, Slide6, 300000
SetTimer, Slide7, 360000
SetTimer, Slide8, 420000
SetTimer, Slide9, 450000
SetTimer, Slide10, 540000
SetTimer, Slide11, 600000
SetTimer, Slide12, 660000
Return

Slide1:
Control, ChooseString, Scene 02, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide1, Off
Return

Slide2:
Control, ChooseString, Scene 03, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide2, Off
Return

Slide3:
Control, ChooseString, Scene 04, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide3, Off
Return

Slide4:
Control, ChooseString, Scene 05, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide4, Off
Return

Slide5:
Control, ChooseString, Scene 06, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide5, Off
Return,

Slide6:
Control, ChooseString, Scene 07, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide6, Off
Return,

Slide7:
Control, ChooseString, Scene 08, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide7, Off
Return,


Slide8:
Control, ChooseString, Scene 09, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide8, Off
Return,


Slide9:
Control, ChooseString, Scene 10, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide9, Off
Return,


Slide10:
Control, ChooseString, Scene 11, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide10, Off
Return,


Slide11:
Control, ChooseString, Scene 12, ListBox1, ahk_class OBSWindowClass
SetTimer, Slide1, On
SetTimer, Slide2, On
SetTimer, Slide3, On
SetTimer, Slide4, On
SetTimer, Slide5, On
SetTimer, Slide6, On
SetTimer, Slide7, On
SetTimer, Slide8, On
SetTimer, Slide9, On
SetTimer, Slide10, On
SetTimer, Slide11, On
Return
 
Top