OBS: A dump button for dropping the last ~10 seconds before it hits the stream
| emacs, videoI want to make it easier to livestream without worrying about leaking private information. Tradeoff: slower conversations with the chat, but more peace of mind.
I think I've sorted out a setup involving two instances of OBS, with the source instance sending the stream with a delay to the restreaming instance that will then send it on to YouTube. This allows me to cut the feed from the source instance to the restreaming instance in case something happens.
The first OBS is the one that has my screen capture, webcam, audio, etc. Here's what I needed to do to change it.
- Create a new profile or rename the profile to "Source".
- Name the collection of streams "Source" as well.
- In Settings - Hotkeys, define a keyboard shortcut for Stop streaming (discard delay). I use
Super + F12. - In Settings - Stream:
- Service: Custom
- Destination - Server:
srt://127.0.0.1:9000?mode=caller
- In Settings - Advanced:
- Check Stream Delay - Enable.
- Set the duration. Let's try 10 seconds.
- Uncheck Preserve cutoff point (increase delay) when reconnecting.
Then I can launch that one with:
obs --profile "Source" --collection "Source" --launch-filter --multi
The second OBS will restream the output of the first OBS to YouTube.
obs --profile "Restream" --collection "Restream" --launch-filter --multi
I used the Profile menu to create a new profile called "Restream" and the Scene Collection menu to create a new collection called "Restream." I set up the scene as follows:
- Create a text source with the backup message.
- Create a media source.
- Uncheck Local File.
- Uncheck Restart playback when source becomes active.
- Input: srt://127.0.0.1:9000?mode=listener
In the first OBS (the source), click on Start streaming. After some delay, the stream will appear, and I can move or resize it.
I was a little thrown off by the fact that my audio bars didn't initially show up in the mixer in the restreamer, but both recording and streaming seem to include the audio.
To stop the stream, I can switch to OBS, click on Stop streaming, and (important!) choose Stop streaming (discard delay). The OBS window might be buried under other things on my second screen, though, and that's too many clicks and mouse movements. The keyboard shortcut Super + F12 we just set up should be handy, but I might not remember that, so let's add some scripts. The OBS websocket protocol doesn't support discarding the delay buffer yet, but I'm on Linux and X11, so I can use xdotool to simulate a keypress. Here I select the window matching the profile name I set up previously.
WID=$(xdotool search --name "OBS .* - Profile: Source")
xdotool key --window $WID super+F12
I can org-capture the timestamp of the panic so that I can doublecheck the recording.
;;;###autoload
(defun sacha-obs-panic ()
"Stop streaming and discard the delay buffer.
This uses a hotkey I defined in OBS."
(interactive)
(shell-command "~/bin/panic")
(org-capture-string "Panicked" "l")
(org-capture-finalize))
I always have Emacs around, and if it's not my main app, I have an autokey shortcut that maps super + 1 to focus on Emacs. Then I can M-x panic and Emacs completion will take care of finding the right function.
Let's add a menu item for even more panic assistance:
(easy-menu-define sacha-stream-menu global-map
"Menu for streaming-related commands."
'("Stream"
["🛑 PANIC" sacha-obs-panic]
["Start streaming" obs-websocket-start-streaming]
["Start recording" obs-websocket-start-recording]
["Stop streaming" obs-websocket-stop-streaming]
["Stop recording" obs-websocket-stop-recording]))
Let's see if I remember to use it!