How to set up multistreaming to RTMP and RTMPS (Kick, Twitch, Facebook and others)

How to set-up multistreaming to save on bandwidth?  Useful in cases where upload might be limited.

Install NPM

sudo apt install npm

Install Node media server

npm install node-media-server

Configure Node media server

mkdir -p /home/ubuntu/nms

Use a text editor to create/edit the following file: app.js


Example configuration file:

const NodeMediaServer = require('node-media-server');

const config = {
  logType: 3,
  rtmp: {
    port: 1935,
    chunk_size: 60000,
    gop_cache: true,
    ping: 30,
    ping_timeout: 60
  },
  http: {
    port: 8000,
    allow_origin: '*'
  },
  relay: {
    ffmpeg: '/usr/bin/ffmpeg',
    tasks: [
      {
          app: 'live',
          mode: 'push',
          edge: 'rtmp://sea02.contribute.live-video.net/app/live_<TWITCH-TOKEN>',
          name: 'twitch',
          appendName : false

      },
      {
          app: 'live',
          mode: 'push',
          edge: 'rtmps://fa723fc1b171.global-contribute.live-video.net/app/sk_us-west-<KICK-TOKEN>',
          name: 'kick',
          appendName : false
      },
      {
          app: 'live',
          mode: 'push',
          edge: 'rtmp://a.rtmp.youtube.com/live2/<YOUTUBE-TOKEN>',
          name: 'youtube',
          appendName : false
      }
    ]
  }
};

var nms = new NodeMediaServer(config)
nms.run();

 

Configure the firewall

sudo ufw allow proto tcp from <YOUR-IP> to any port 1935

 

Installing Node Media Server as a service:

Use a text editor to create/edit the following file: /lib/systemd/system/nms.service

[Unit]
Description=start NMS
Documentation=
After=network.target

[Service]
Environment=
Type=simple
User=ubuntu
ExecStart=/usr/bin/node /home/ubuntu/nms/app.js
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable the service
sudo systemctl enable nms
sudo systemctl start nms

To later restart the service after config changes, use:

sudo systemctl restart nms

 

Start streaming
After completing these steps, configure OBS to point to <SERVER-IP>:1935  and within a few seconds it should start streaming to all configured platforms.



Profile picture
Gideon Bakx
Updated on: Tuesday, November 19, 2024 2:58:07 PM
C# certified software engineer living in Calgary, Canada.
multistreaming kick twich facebook youtube