How to build a multi-streaming server for Microsoft Live Events with a Raspberry Pi
By: John Moore
Tags: Raspberry Pi, Live Streaming, Nginx, Microsoft Stream, Rtmp

Set up the Raspberry Pi

Assemble the Pi into the case Flash the OS to the MicroSD Card using the Raspberry Pi Imager. I chose to install Raspbery Pi OS (other) > Raspberry Pi OS Lite (32-bit) Insert the MicroSD card, plug in the monitor, keyboard, and power on the Pi Log in using the default username pi and password raspberry

Initial Setup

In the command line, enter:

sudo raspi-config

2. Select the first option and set a new password for the pi user.

3. Select Network Options and then Hostname. Set a hostname. I chose to name mine “multi-streamer”.

4. Select Interfacing Options and enable SSH so you can remotely log into the pi from another computer.

5. Select Finish to exit raspi-config.

5. Set a static ip address.

sudo nano /etc/dhcpcd.conf

add the following to the bottom of the dhcpcd.conf file:

interface eth0

static ip_address=[whatever IP address you pick]/24

static routers=[your router's IP address]

static domain_name_servers=[your router's IP address]

Press CTRL+X and then Y and press Enter

6. Get updates, install updates, and Reboot the Pi.

sudo apt-get update

sudo apt-get upgrade

reboot

7. After the Pi reboots, you can now SSH to the Pi from another computer using Putty on Windows or Terminal on macOS.

ssh pi@[hostname of your pi].local

Install NGINX and the RTMP module

Install NGINX.

sudo apt install nginx

2. Install the RTMP module for NGINX.

sudo apt-get install libnginx-mod-rtmp

Configure the RTMP server

Open the NGINX.conf file.

sudo nano /etc/nginx/nginx.conf

2. Scroll to the very bottom of the text file and enter rtmp config info below. This is where Microsoft Stream is a bit special. For ingest URL’s that are provided by Microsoft Stream, there are two unique codes in the URL. This very long URL must be split into two parts. You will find that the middle of the URL contains ‘channel.media.azure.net:1935/live/[uniquecode]’. What you’ll need to do is paste this URL into the conf file and then split the URL just after the ‘1935’ and enter a space and then ‘app=live/[uniquecode]’. Be careful to look at the example in the code block to understand the format.

rtmp { server { listen 1935; chunk_size 4096; notify_method get; application live { live on; record off; push rtmp://localhost/microsoftstream; push rtmp://localhost/youtube; } application microsoftstream { live on; record off; allow publish 127.0.0.1; deny publish all; push [First half of Stream URL Here] app=[Second Half of Stream URL Here]; } application youtube { live on; record off; allow publish 127.0.0.1; deny publish all; push rtmp://a.rtmp.youtube.com/live2/[YouTube Stream Key Here]; } } }

3. Press CRTL+X then enter Y then hit Enter to save conf file.

4. Restart NGINX.

sudo systemctl restart nginx

Configure your encoder

Enter “rtmp://[Hostname of the Pi]:1935/live/“ for the server and anything you want for the key. You must enter a key for Microsoft Stream to work. Be sure to set your encoder’s output to 30fps and Keyframe=2 for it to work properly with Microsoft Stream.

Test it out