A Cheap, Easy, and Simple BRB Server for IRL Livestreamers

Bad news team: after testing this setup it seems it only works…sometimes. Instead of pursuing this version further, I’ve started to develop a more robust solution. For updates on progress sign up for the mailing list.

When I first started livestreaming as BikeCurious I thought it would be easy. I’d download and app on my phone, hop on my bike, and I’d be interacting with viewers anywhere I rode in San Francisco. 2 years and sizable chunk of money later and I’m still struggling to solve some basic livestreaming problems. One of those problems is a “brb” scene.

As an IRL livestream it’s inevitable that your stream is going to have downtime when you want to be live. Connectivity is unpredictable and viewers are constantly pushing the limits of the technology by demanding new experiences. If your local streaming equipment like a LiveU Solo, mobile phone, or portable PC is streaming directly to a Twitch server and your connection goes down, viewers are going to see the fabled NotLikeThis emote instead of your incredible content. Viewers will leave in droves.

A brb scene replaces this dead air with entertaining footage like clips from your channel. Instead of losing viewers, new viewers might see your most entertaining clips and drop a follow or even a sub! The problem is that making a brb scene work isn’t easy.

First of all, you need to insert your own server between your local streaming rig and Twitch’s ingest server. Second, that server needs to be able to detect when your stream disconnects and switch over to your brb scene, a process called a “failover”. Most IRL livestreamers run a full version of OBS in the cloud or on their home computer. This setup is expensive, complex, and prone to errors. This tutorial will walk you though the process of setting up a cheap and simple brb solution that costs only $5 a month hosted on a Vultr Virtual Private Server.

I will not assume you have previous experience with a Unix terminal, but familiarity will make it easier to understand what’s going on. In order to complete this tutorial you will need SSH installed and functional on your computer. If you are running Linux or OS X you already have ssh, you need only open a Terminal Window. If you are on Windows you’ll need to install a third party application like PuTTY.

Create a Vultr Server

  • Create an account with Vultr (you will need to add your credit card information)

  • Deploy new server

  • Choose Cloud Compute

  • Choose the location that is closest to the Twitch Ingest server you are using

  • Ubuntu 20.04 x64

  • 25GB Vultr server for $5/month

  • Give it a hostname like yourname-rtmp

  • Deploy

Install Nginx and Nginx-RTMP

Nginx does not include RTMP by default. In order to get Nginx-RTMP installed we need to build it from the source code. First we start by connecting to your new server over SSH

ssh root@your.server.ip

Install the necessary tools

sudo apt-get update
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev unzip git

Make a working directory and switch to it

mkdir ~/installer
cd ~/installer

Download the Nginx and Nginx-RTMP source.

wget http://nginx.org/download/nginx-1.19.2.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip

Extract the Nginx and Nginx-RTMP source.

tar -zxvf nginx-1.19.2.tar.gz
unzip master.zip

Switch to the Nginx directory.

cd nginx-1.19.2

Add modules that Nginx will be compiled with. Nginx-RTMP is included.

./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master --without-http_gzip_module --with-cc-opt="-Wimplicit-fallthrough=0"

Compile and install Nginx with Nginx-RTMP.

make
sudo make install

Install the Nginx init scripts.

sudo wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo update-rc.d nginx defaults

Generate a log file for nginx to use

mkdir -p /var/log/nginx/
touch /var/log/nginx/error.log

Start and stop Nginx to generate configuration files.

sudo service nginx start
sudo service nginx stop

Install FFmpeg

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get install ffmpeg

Install streamRIP

streamRIP is an open source script written by hakkin that makes a simple brb scene which plays a looping video file when your streaming rig disconnects. It’s a no-frills solution to a problem every IRL streamer has.

Create a directory for streamRIP and change into it.

mkdir -p /usr/share/nginx/
cd /usr/share/nginx/

Clone the streamRIP git repository.

git clone https://github.com/Hakkin/streamRIP.git
cd streamRIP/

Open the config.sh in the command line text editor nano.

nano config.sh

First set the video to file to loop when your steam goes down (we’ll upload this later).

offfi="/usr/share/nginx/streamRIP/brb.mp4"

Create your stream secret (I like to use CodeIgniter Encryption Keys just because they’re a good balance of secure and easy to type in). You will use this as your stream key when you set up your streaming client (like OBS).

secret="some random key that is hard to guess and not too short"

Add your twitch endpoint based on the location that is closest to your Vultr server (view the recommended Twitch ingests near you)

rtmpe="rtmp://live-sjc05.twitch.tv/app/live_yourtwitchstreamkey"

Replace Nginx’s default config file with the one used by streamRIP

cp /usr/share/nginx/streamRIP/streamrip.conf /usr/local/nginx/conf/nginx.conf

Upload your brb video file. Keep in mind that it should be the same resolution and bitrate as your stream to minimize the likelihood of an f. In practice I was able to download my own clips from twitch and hack together a quick video in iMovie. You can also find a number of “be right back” screens on youtube that are open source. Once you have a video to upload, disconnect from SSH and use SCP to upload the video file

scp ~/Downloads/brb.mp4 root@your.server.ip:/usr/share/nginx/streamRIP/brb.mp4

Last you should reboot your vultr server from the web interface. This will ensure that all your configuration changes take hold before we start testing.

Connecting to Your Server

Launch your streaming application of choice. For this tutorial I’ll use OBS since it’s the standard, but the steps should be pretty similar regardless of your streaming software.

Click Settings and then click Stream. Fill in your Server address.

rtmp://your.server.ip/live/

Take the secret you added to the streamRIP config.sh and put it into the Stream Key field.

Save your changes by clicking ok and test your new server by clicking the Start Streaming button. If you’ve done everything correctly you should see OBS go live and your stream should appear on Twitch in 15 seconds or so.

Last, you should test your brb video. Hit the Stop Streaming button in OBS. This should trigger streamRIP to fail over to the brb.mp4 video you uploaded. If you see your brb video on Twitch then you’re good to go!

Starting and Stopping

To start your stream first make sure your Vultr server is booted up. Once it is you can click Start Streaming in OBS and your stream will automatically forward to Twitch.

In order to stop your stream completely you can no longer just click End Stream in OBS. You also have to access the Vultr admin page and shut down your server or restart it. If you don’t the brb video will just keep looping forever.

Some Further Notes

If your server doesn’t seem to be working then a good place to start is by connecting to your server through SSH again and tailing the Nginx logs to see what’s going on when you start your stream .

ssh root@your.server.ip
tail -f /var/log/nginx/error.log

You may want to run your stream in test mode. In order to do this add the bandwidthtest paramater after your stream key in the config.sh

rtmpe="rtmp://live-sjc05.twitch.tv/app/live_yourtwitchstreamkey"?bandwidthtest=true