Like qhobbes said, you need to switch BOTH the profile AND and scene collection for each instance.
obs --help
to see how to do that.
That section of my bash script is:
Bash:
#
# Start OBS Master with options
#
echo
if [[ "$LOCAL_AUDIENCE" = "0" ]] # 0 for "success" or "yes"
then
echo "Start OBS Master (feed to meeting)"
else
echo "Start OBS"
fi
obs --verbose --unfiltered_log --disable-updater --multi --studio-mode --profile "$OBS_PROFILE" --collection "$OBS_PROFILE" --startvirtualcam > /dev/null &
PID_MASTER=$!
sleep 10
#
# Local Audience?
#
PID_SLAVE=""
if [[ "$LOCAL_AUDIENCE" = "0" ]] # 0 for "success" or "yes"
then
#
# Start OBS Slave
#
echo
echo "Start OBS Slave (local display and recording)"
obs --verbose --unfiltered_log --disable-updater --multi --studio-mode --profile "Meeting_Slave" --collection "Meeting_Slave" > /dev/null &
PID_SLAVE=$!
sleep 10
fi
And you can see how some of the logic and status-reporting works as well.
The
PID_x
variables are used later to clean up automatically:
Bash:
else
#
# Wait for User OK
#
echo
echo
echo "Wait for Done..."
echo
zenity \
--info \
--width=350 \
--title="DO NOT CLOSE THIS ! ! !" \
--text="When done:\n1. Click OK here\n\nEverything will clean up automatically."
echo
echo "Done, cleaning up:"
fi
#
# OBS Slave?
#
if [[ "$PID_SLAVE" != "" ]]
then
#
# Close OBS Slave
#
echo
echo "Close OBS Slave"
kill -TERM "$PID_SLAVE"
sleep 5
fi
#
# Close OBS Master
#
echo
echo "Close OBS Master"
kill -TERM "$PID_MASTER"
sleep 5
zenity
is a dialog box, that waits there until the user clicks OK. Lots of other options too, that are used in other parts of the script, but that's what it does here.
- A backslash
\
allows a newline in the middle of a single command, without breaking that command.
kill
is kind of a misnomer. It simply sends a signal out of a universally predefined list, to the Process ID (PID). The process then decides how to handle that signal. There are standard ones to save and exit, just exit without saving, print something to the terminal, and one that the operating system intercepts to force-kill it. What I'm using here is not the force-kill signal, but the close-gracefully one.
The 3-line comments:
#
# Comment
#
correspond to a flowchart that makes it easier to see the entire startup and shutdown sequence, and understand all of what it's doing. That's attached here too. The sections of script above are the top and bottom of the center section of the flowchart.