This how-to is for converting a unencrypted RTMP video stream to a encrypted RTMPS video stream for use on Facebook.
Hardware and Software live-streaming encoders have typically used the RTMP streaming protocol. With the Facebook enforcement of the RTMPS encrypted live-streams, some older hardware and software encoders can no longer work. By using the method below we can convert RTMP to RTMPS using a Nginx on Ubuntu server 18.04 via a cheap Raspberry pi.
Install Nginx and RTMP module (On Ubuntu server 18.04)
This configuration assumes that nginx and stunnel is installed on the same machine.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx -y
sudo apt-get install libnginx-mod-rtmp -y
Edit nginx.conf
sudo nano /etc/nginx/nginx.conf
Add to the end of nginx config
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
push rtmp://127.0.0.1:1936/rtmp/<<Facebook persistent stream key>>;
}
}
}
restart nginx
sudo systemctl restart nginx
If any errors occur at this stage recheck your configuration.
Before moving onto the Stunnel configuration its wise to first check Nginx and RTMP module are working correctly
To test setup use OBS to send video and VLC Player to play video.
OBS >> Ngnix >> VLC Player
>> Settings >> Stream
Service: Custom
Server: rtmp://<<ngnix server IP address>>/live
Stream Key: test
>>Open Network Stream>>Network
Please enter a network URL: rtmp://<<ngnix server IP address>>/live/test
sudo apt-get install stunnel4 -y
Edit stunnel auto boot configuration
sudo nano /etc/default/stunnel4
Change ENABLE from 0 to 1
ENABLE=1
Edit stunnel configuration
sudo nano /etc/stunnel/stunnel.conf
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
sudo systemctl enable stunnel4.service
sudo systemctl restart stunnel4.service
Any errors at this stage maybe due to error in the config. Double check Ports. ngnix an stunnel need to be on different ports when used on the same machine.
For those who are having problems make sure you (in this order)
Setup the Facebook live stream page www.facebook.com/live/producer/ (See picture below)
Start the stream via OBS, Hardware encoder or other device
After about 30 seconds or so the Facebook live stream page will acknowledge a video steam. (See picture below)
On the same page click "Go Live"
From my understand unless you are using a "paired encoder" it is not possible to go live without the extra steps with every new stream.