Automatically stop and restart video inputs periodically (every X minutes) to synchronize audio & video streams using AutoHotKey running under MS Windows
When you start streaming from a live video camera, the video and audio are wonderfully synchronized, but they can get out of sync. Typically, the video data takes longer for OBS to process than the audio. After a while, the video lags behind the audio because of the backlog of video data.; ------------ Stop & Restart OBS input streams ------------- Gosub, RestartInputs ; ------------------------------------------------------------ #Persistent ; Runs forever. To stop it, right-click "H" icon ; in system tray and choose Exit ; Set time interval between input restarts SetTimer, RestartInputs, 900000 ; 900000 msec = 15 minutes ; 1200000 msec = 20 minutes ; 1800000 msec = 30 minutes Return ; ----------------------------------------------------------------- RestartInputs: SoundBeep 650, 400 ; warning beeps that restart is about to happen SoundBeep 750, 500 Sleep 4000 ; 4 seconds delay -- pause your mouse usage CoordMode, Mouse, Screen ; Use screen (not window) coordinates Click, 1600 50 ; Click OBS window at upper-right of screen: ; 1600 pixels from left side of screen ; 50 pixels down from top of screen ; (coordinates for OBS window location) Sleep 1000 ; Brief wait before stopping first input stream ; Beforehand, configure keystrokes in OBS: ; Settings > Hotkeys > subwindow name > Stop > keystroke ; Settings > Hotkeys > subwindow name > Restart > keystroke Send, ^+{F4} ; Control-Shift-F4 key, stop input stream Sleep 2000 ; Delay 2 seconds Send, ^+{F5} ; Control-Shift-F5 key, restart input stream Sleep 5000 ; Pause to wait for first subwindow to reappear Send, ^+{F6} ; repeat for second OBS subwindow input stream Sleep 2000 ; (can delete these 3 lines if you have only Send, ^+{F7} ; one input stream, no harm in leaving them in) Return ; End of RestartInputs subroutine