Question / Help Command Line and scripting controls

ThadeuMelo

New Member
Hello guys.

I would like to use OBS to stream my Archviz projects automatically to a midia server in the Cloud.

It seems to be working fine if I type the commands on the terminal. But this has to be automated.

However I can´t get make it work using a Python or a .bat file.

@Echo Off
call "C:\\Program Files (x86)\\obs-studio\\bin\\64bit\\OBS64.exe"

Returns only a error windows with "Failed to find locale/en-US.ini"

Any help on why this happens?
 
It seems I have to be inside the folder.

@Echo Off
cd "C:\\Program Files (x86)\\obs-studio\\bin\\64bit\\"
call "OBS64.exe"

Would work.

However, now I have problems with the double quotes.

call "OBS64.exe --collection ""Twitch"" --profile ""Twitch"" --scene ""Stream Start"" --startstreaming"

Won´t work.
 
In python you can try:
Code:
import os
import subprocess
class Pwd:
    dir_stack = []
    def __init__(self, dirname):
        self.dirname = dirname
        self.dirname = os.path.realpath(os.path.expanduser(self.dirname))
    def __enter__(self):
        Pwd.dir_stack.append(self.dirname)
        return self
    def __exit__(self,  type, value, traceback):
        Pwd.dir_stack.pop()
    def run(self, cmdline, **kwargs):
        return subprocess.Popen(cmdline, cwd=Pwd.dir_stack[-1], shell=True, **kwargs)

Then call obs with..

Code:
with Pwd(r"C:\\Program Files (x86)\\obs-studio\\bin\\64bit\\") as shell:
    shell.run(r
'obs64.exe --collection "Twitch" --profile "Twitch" --scene "Stream Start" --startstreaming'
)

I had a similar issue opening other programs and found out about this through https://stackoverflow.com/questions...ess-check-call-not-recognising-pushd-and-popd
However mileage may vary depending on the the version of Python installed.

You can also keep track of your current directory, change directories, call the program and return to your starting point.

Code:
import os
start_dir = os.getcwd()
os.chdir(r"C:\\Program Files (x86)\\obs-studio\\bin\\64bit\\")
os.system('obs64.exe --collection "Twitch" --profile "Twitch" --scene "Stream Start" --startstreaming')
os.chdir(start_dir)
*note on this code segment, there is the possibility it won't return to the python script until OBS is closed

Another possible option would be:
Code:
import os
import subprocess
OBS_DIR = os.path.realpath(os.path.expanduser(r"C:\\Program Files (x86)\\obs-studio\\bin\\64bit\\"))
OBS_CMD = r'obs64.exe --collection "Twitch" --profile "Twitch" --scene "Stream Start" --startstreaming'
OBS_RUN = subprocess.Popen(OBS_CMD, cwd=OBS_DIR)

Sorry for the wall of text. I just wanted to cover as many possible options as I could. Though, the last 2 examples should be wrapped into a function to make using the code easier and potentially used for other programs.

**edit** I realized that I didn't have the first one written properly
 
Last edited:
Back
Top