2. Quick Start: Relay OBS to Twitch and YouTube
This guide runs the relay on one Linux machine (the relay host) and points OBS Studio on your streaming PC at it. The relay receives your stream over the Real-Time Messaging Protocol (RTMP) and forwards it to Twitch and YouTube.
Before you start, check the Requirements.
| Placeholder | Meaning |
|---|---|
<RELAY_IP> |
The relay host's LAN address, for example 192.168.1.50. On the relay host, hostname -I prints it. |
2.1 Set Up the Relay Host
-
Clone the repository and change into it:
-
Copy your stream keys:
- Twitch: Creator Dashboard → Settings → Stream → Primary Stream key.
- YouTube: YouTube Studio → Create → Go live → Stream → Stream key.
TODO(verify: current Twitch and YouTube menu paths to the stream key)
-
Create your settings file from the template:
env/relay.envis ignored by git, so your keys cannot be committed. -
In
env/relay.env, set each key, then save the file:Paste each key with no spaces or quotes. Leave a key empty to turn that service off.
-
If your streaming PC's address does not start with
192.168., uncommentPUBLISH_IP_RANGEinenv/relay.envand set it to the default ranges plus its subnet. For a streaming PC at10.0.0.25:The relay refuses streams from any address outside this list.
-
Start the relay:
start.shremoves any existing relay container, rebuilds the image against the latest base image, and runs the relay in the foreground. Press Ctrl+C to stop it. -
In a second terminal on the relay host, confirm each service is enabled:
Expected output:
Twitch Non-Partner configuration complete, and service enabled. YouTube configuration complete, and service enabled.If you see an
ERROR:line, the relay has stopped. See Invalid Environment Value.
Security
The relay has no password or key authentication. It accepts a stream from any address in PUBLISH_IP_RANGE. Keep that list as narrow as your network allows, and never expose port 1935 to the internet.
2.2 Point OBS at the Relay
-
In OBS, open Settings → Stream and set:
- Service: Custom
- Server:
rtmp://<RELAY_IP>:1935/relay - Stream Key: any name, for example
mystream. This is not your Twitch or YouTube key; it names the stream on the relay, in its log and in archive file names. - Use authentication: unchecked
-
Open Settings → Output, set Output Mode to Advanced, and on the Streaming tab set:
- Encoder: a hardware encoder such as NVIDIA NVENC H.264 if you have one, otherwise x264.
- Rate Control: CBR (constant bitrate).
- Keyframe Interval: 2 s.
- Bitrate: the highest your upload sustains. YouTube receives this stream unchanged. For Twitch, the relay re-encodes to 4500 kbps by default; in Twitch partner mode (
TWITCH_PARTNER=TRUE) Twitch also receives it unchanged, so keep it within Twitch's Broadcasting Guidelines. See Bandwidth Requirements for the relay host's total upload.
YouTube, and Twitch in partner mode, get exactly what OBS sends, so these settings are what those viewers see.
-
Click Start Streaming, then confirm the stream is live in Twitch Stream Manager and in YouTube Studio → Go live.
If it is not, start at the Troubleshooting Guide.
2.3 See Also
- Change Relay Settings - Edit, apply and confirm a setting
- Environment Variables Reference - Every variable, its default and valid values
- Troubleshooting - Common issues and solutions