Live Streaming Sports to YouTube and Facebook Simultaneously

The Northern Territory Rugby Union Season Kicked off early this year.

With a bit of help from PierToPier.net its being live streamed to both face book and Youtube.

NT Rugby have bought a Camera, laptop and microphones, as per our specs, so far its been a fabulous success.

There’s already a guide on ‘how to stream the rugby‘ here from last year. However there’s a couple of new an innovative features with this years version.

The main one is using nginx to split the stream. Instead of putting the youtube server and stream key into OBS, you:

  • Get  free AWS account.
  • Get a free tier AWS server
  • install nginx with the rtmp module on it
  • put your nginx server into obs
  • put the facebook and youtube keys into nginx.conf.

There’s an excellent guide here:

Of course I didn’t follow that guide, I used an ubuntu instance.  A free tier AWS ubuntu instance can be set up in minutes using:

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

sudo apt-get update
sudo apt-get -y install build-essential libpcre3 libpcre3-dev libssl-dev unzip ffmpeg
mkdir ~/working
cd ~/working
wget http://nginx.org/download/nginx-1.7.5.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
tar -zxvf nginx-1.7.5.tar.gz
unzip master.zip
cd nginx-*
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
make
sudo make install
mkdir ~/init
cd ~/init
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

sudo apt-get install ntp
sudo dpkg-reconfigure tzdata

this will compile nginx with rtmp and set the timezone and network time protocol.

then just edit the nginx.conf

 sudo nano /usr/local/nginx/conf/nginx.conf

redacted version of my nginx.conf changes:

rtmp {
 server {
 listen 1935;
 chunk_size 4096;
 application [redacted] {
 live on;
 record off;
 allow publish 127.0.0.1;
 allow publish [redacted ip];

#event round three other
 push rtmp://a.rtmp.youtube.com/live2/[youtube stream key];
 push rtmp://live-api.facebook.com:80/rtmp/[facebook stream key];

}
 }
 }

Just append this to the bottom of the nginx.conf.

where it says application [redacted] put the PATH to your server. Then enter custom streaming server  the same in OBS e.g. rtmp://[ip of AWS server]/path

Stream key doesn’t seem to matter

Danger Will Robinson

this is obviously a MAHOOSIVE security risk. I got around it by:

allow publish [redacted ip];

This means that only the ip listed above can publish. in this case the IP of rugby parks NBN connection.

I also did the same with the AWS firewall. I also shut the instance down when not in use.

if I were you I would NOT:

  • use recurring stream keys with this setup
  • allow unrestricted access to your server
  • use auto go live

in the situation above should someone find you server, they could stream anything to your channels. Use this with caution!

This is not a particular endorsement of AWS, you could do this with linode, azure, digital ocean or whoever. Only used AWS as it was free and i needed to learn it. Also AWS have an Australian Data Centre, and we’re talking live streaming here. I’m not sure I want it going half way around the globe.

Leave a Reply

Your email address will not be published. Required fields are marked *