CLI Stop and Start for timed recording.

burt8810

New Member
I have OBS working for recording by push HotKeys to stop and start on a WINDOWS 10 system.
Wanted to automate for timed recording.

Found this thread: https://obsproject.com/forum/threads/timed-recordings-on-obs.99727/#post-517690.

I have done the following from that thread:
1. firstly install the "obs-websocket plugin": https://obsproject.com/forum/resources/obs-websocket-remote-control-of-obs-studio-made-easy.466/
2. then install this pluggin "Command line tool for obs-websocket plugin" : https://obsproject.com/forum/resources/command-line-tool-for-obs-websocket-plugin.615/
3. Then open up the command line using shift + right click at the OBSCommand directory, then type "OBSCommand.exe /startrecording" (to start record), and "OBSCommand.exe /stoprecording (for stop record) "

This last step has me completely stumped.

Running this batch file from in the CMD window starts the recording but it never gets to the TIMEOUT. Clicking on "StopRecording" in OBS allows TIMEOUT to run.
obs64.exe --startrecording
TIMEOUT 10
obs64.exe --stoprecording

Running this batch file from in the CMD window never starts OBS. Tried changing --startrecording to /startrecording, no difference
C:\OBSCommand\OBSCommand.exe --startrecording
TIMEOUT 10
C:\OBSCommand\OBSCommand.exe --stoprecording

I have no experience with websockets.
I will be very grateful for any help anyone may be able to provide.
Thanks in advance.
Herb
 

burt8810

New Member
Just a follow up to my original post. Perhaps no one is interested as there have been no replies.
I did come up with a workable solution:
Create a batch file:

:: Stop and start OBS recording
c:
cd "C:\Program Files\obs-studio\bin\64bit\obs64.exe"
START " " /D "C:\Program Files\obs-studio\bin\64bit\" "C:\Program Files\obs-studio\bin\64bit\obs64.exe" --startrecording
TIMEOUT 10
taskkill /F /IM obs64.exe /T
ECHO End of Batch
Pause
:: the last 2 lines may be removed

Create a short cut by:
Right click on your batch file -> New -> Send To Desktop
Right click Desktop shortcut -> Properties
Target E:\obsss.bat use the drive and name of your batch file
Start in E:\ use drive where batch file is located in your system
Run Minimized so Command window is not displayed

When Desktop shortcut is selected OBS will start recording for the time specified as TIMEOUT and then OBS will close.
The file is saved in the location you specified in OBS.
Worked for me.
Herb
 

fraegn1999

New Member
Based on the info I found on this post I writed this script to automate the video splitting

name of the file: "obs auto recording.bat", you have to run it as administator, and works only on windows of course.
Code:
::This script automate the video recording of obs

::setting the echo
echo off
cls

::log file
set logfile="C:\Users\franc\Downloads\setup and software\obs\OBSCommand_v1.5.7\OBSCommand\automate.log"
echo log file will be %logfile%

echo script launched
echo script launched > %logfile%

::setting cmd window parameter
title obs auto recording
color 0a

::counter and counter max(number of videos)
set counter=0
set countermax=2

::video duration in seconds, secboot are the seconds required to open the program obs before start the actual recording
set secduration=10
set secboot=5
set /a duration=%secduration%+%secboot%
echo the timer will be %duration% seconds
echo the timer will be %duration% seconds >> %logfile%
:loop

::OBSCommand.exe /startrecording //start recording when obs is already open, it looks like doesn't work after the stop, so i have to restart obs

::targeting the obs executable DIRECTORY
cd "C:\Program Files\obs-studio\bin\64bit"
::killing already running obs process
Taskkill /IM obs64.exe /F
echo task killed
echo task killed >> %logfile%

echo loop execution number: %counter% su %countermax%
echo loop execution number: %counter% su %countermax% >> %logfile%
if %counter% equ %countermax%  goto :quitscript
set /a counter+=1

::run obs in recording mode
start obs64.exe --profile "debug" --collection "debuging" --scene "debug" --startrecording
echo running obs in recording mode
echo running obs in recording mode >> %logfile%
timeout /t %duration% /nobreak

::targeting the OBSCommand executable DIRECTORY
cd "C:\Users\franc\Downloads\setup and software\obs\OBSCommand_v1.5.7\OBSCommand"

::stopping the rocording to save the video
OBSCommand.exe /stoprecording
echo video ended
echo video ended >> %logfile%

goto :loop

::final step
:quitscript
echo script terminated
echo script terminated >> %logfile%
pause
exit
 

Lambrero

New Member
Here is my version without OBS restarting:

Makefile:
:: This script automates video recording using OBS

:: Required:
:: * https://obsproject.com/ru
:: * https://github.com/REALDRAGNET/OBSCommand
:: + Setup websocket server in OBS to use OBSCommand

:: Disable command echoing and clear the screen
echo off
cls

:: Set CMD window parameters
title obs auto recording
color 0a

:: Sleep durations
set secduration=3600
set secboot=5
set secrestart=3

set obsCommandDefaultParams=/server=127.0.0.1:4455 /password=ELyMUPOZgOBbtWWz
set secrestart=3

:: ------------------------------
:: Start OBS
:: ------------------------------

:: Change the working directory to the OBS executable directory
cd "C:\Program Files\obs-studio\bin\64bit"

:: Kill any already running OBS processes
Taskkill /IM obs64.exe /F

:: Run OBS in recording mode
start obs64.exe --profile "Безымянный" --scene "Сцена" --minimize-to-tray

timeout /t %secboot% /nobreak

:: ------------------------------
:: Main Loop
:: ------------------------------

:loop

:: Change the working directory to the OBSCommand executable directory
cd "C:\utils\OBSCommand"

:: Start recording
OBSCommand.exe %obsCommandDefaultParams% /startrecording

:: Wait for the specified duration before stopping the recording
timeout /t %secduration% /nobreak

:: Stop recording
OBSCommand.exe %obsCommandDefaultParams% /stoprecording

:: Wait some time to finish recording properly
timeout /t %secrestart% /nobreak

:: Loop back to start another recording
goto :loop
 
Top