Setting Up

Currently OBS Studio can only stream to a single service, such as Facebook or YouTube, but we are going to set up a way to stream to another service at the same time. Assuming that you are already comfortable streaming to Facebook, YouTube will be our second service.

You'll need to install FFmpeg and Python 3.

The following Python code can be run from a Jupyter notebook, or saved as something like and run from there.

Replace xxxx-xxxx-xxxx-xxxx with your stream key from YouTube Studio, and /home/username/Videos with the path to the folder where OBS records your videos. You may also need to include the ffmpeg_path.

This code finds the most recent file in your OBS recordings folder and streams that file to YouTube. You may want to enable the setting "Automatically record when streaming" in OBS, otherwise you'll need to click "Start Streaming" and "Start Recording" each time.

Start recording in OBS then run the code, and it should start streaming the recording to YouTube without interfering with your primary stream. You will, of course, need enough upload bandwidth for both streams.

Potentially you could have another copy of this Python script running to streams the recording to a third service, such as Twitch.

#! /usr/bin/env python3

stream_key = 'xxxx-xxxx-xxxx-xxxx'
recording_path = '/home/username/Videos'
ffmpeg_path = ''

print("If you haven't started the recording already, press Ctrl-c to cancel this...")
from datetime import datetime
from pathlib import Path
import os

# find the newest file in the folder
p = Path(recording_path)
time, newest_file = max((f.stat().st_mtime, f) for f in p.iterdir())

youtube_server = 'rtmp://'
command = ffmpeg_path+'ffmpeg -re -i '+str(newest_file)+' -acodec copy -vcodec copy -f flv '+youtube_server+stream_key

Hopefully that helps get you started with secondary streams from OBS Studio. Let me know if any of this doesn't work for you.