Skip to content

Instantly share code, notes, and snippets.

@xiCO2k
Last active May 30, 2024 01:53
Show Gist options
  • Save xiCO2k/e378be37e933b3f5c6c106ba149f34af to your computer and use it in GitHub Desktop.
Save xiCO2k/e378be37e933b3f5c6c106ba149f34af to your computer and use it in GitHub Desktop.
RTMP Server to Stream to Facebook, Youtube, Instagram
apt install nginx
apt install libnginx-mod-rtmp
apt install ffmpeg
apt install stunnel4

vim /etc/nginx/nginx.conf

  • Remove http {} and mail {}
  • Add RTMP
rtmp {
     server {
             listen 1935;
             chunk_size 4096;

             application live {
                        live on;
                        record off;
                        # YouTube
                        push rtmp://a.rtmp.youtube.com/live2/REPLACE_WITH_KEY;

                        # Facebook
                        push rtmp://127.0.0.1:1936/rtmp/REPLACE_WITH_KEY;

                        # Instagram
                        exec ffmpeg -loop 1 -i /var/www/image.png -i rtmp://127.0.0.1:1935/live/$name -filter_complex "[1:v]scale=720:-1[fg];[0:v][fg]overlay=(W-w)/3:(H-h)/3:shortest=1" -c:v libx264 -preset veryfast -c:a aac -b:a 128k -f flv rtmp://127.0.0.1:1935/instagram;
             }
             application instagram {
                    live on;
                    record off;

                    push rtmp://127.0.0.1:1937/rtmp/REPLACE_WITH_KEY;
             }
      }
}

vim /etc/default/stunnel4

  • Change ENABLED from ENABLED=0 to ENABLED=1

vim /etc/stunnel/stunnel.conf and add:

pid = /var/run/stunnel4/stunnel.pid
output = /var/log/stunnel4/stunnel.log

setuid = stunnel4
setgid = stunnel4

# https://www.stunnel.org/faq.html
socket = r:TCP_NODELAY=1
socket = l:TCP_NODELAY=1

debug = 4

[fb-live]
client = yes
accept = 1936
connect = live-api-s.facebook.com:443
verifyChain = no

[ig-live]
client = yes
accept = 1937
connect = live-upload.instagram.com:443
verifyChain = no
systemctl restart stunnel4.service
systemctl restart nginx
@Ayoubatiki199
Copy link

Cv

@hassaan-dev
Copy link

From where, I can get this REPLACE_WITH_KEY of YouTube, Facebook and Instagram

@verticalhost
Copy link

Mine looks like this :

[bolt]
client = yes
accept = 127.0.0.1:19350
connect = 6bb1de725b94.global-contribute.live-video.net:443
verifyChain = no

[kick]
client = yes
accept = 127.0.0.1:19351
connect = fa723fc1b171.global-contribute.live-video.net:443
verifyChain = no

One is for boltplus.tv and other one for kick.com

Looks like only one is going UP ( BOLT )
The other one is completly ignored.

Any reason why it's not working for kick ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment