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
Cv