Live Steaming with Nginx and FFMPEG
Live Steaming with Nginx and FFMPEG
Live Steaming with Nginx and FFMPEG
We are going to setup a complete live stream website with nginx and ffmpeg.
Linux Server - the distribution
I have set up on both Ubuntu and Debian and in this doc I use Debian as will can see with bellow information
root[1]nginx:english-pod# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root[1]nginx:english-pod# Install Nginx
On Debian (and may be others, I did not test it) we have different complied version of Nginx. You can search it using
then you will see a line link this
which simply says we have three versions for installing
nginx-light
nginx-full
nginx-extras
and the deference between them is with the number of modules have been complied to have the binary file. For having less headache you can install nginx-extras so most required modules already complied into it.
We can install Nginx using default Debian packages or using separate Nginx repository. After installing Nginx make sure it is up and running and load the IP or domain name you have to see the Welcome to nginx! page.

Check list of Nginx modules
Now we should check if we have rtmp shared library or not. First check the location
Then check the modules, here you can see I have it ngx_rtmp_module.so at the bottom
if you did not have, check the next step
Install rtmp modules on Debian
If you did not have the modules, search for it :)
Here is the module libnginx-mod-rtmp so install it
and then check the Nginx's modules location to see if we have ngx_rtmp_module.so or not. WE SHOULD HAVE IT.
Here is the RTMP source code if wanted to see.
Here is a screenshot of mine

Config nginx.conf file
nginx.conf fileGo to /etc/nginx/ directory and open up nginx.conf file. We should add RTMP configuration to nginx.conf file
Here is the configuration
and the RTMP server
As last step for this section, reload Nignx and make sure everything is fine.
Also here is the complete nginx.conf file if you want to check everything with mine.
Setting up a domain name (optional)
We can have our own domain to load the website or just using an IP address. I already have tested with IP address and preferred to have a domain name so I used live.shakiba.net
Setting up SSL/TLS and HTTPS for domain (optional)
We do not have to do so, but again I preferred to have it. You can use any CDN provider and most of them support Free SSL using Lets Encrypt to issue 90 days certificate. So mine endpoint will be https://live.shakiba.net
Configure live.shakiba.net file in sites-available/
live.shakiba.net file in sites-available/Since my chosen domain is live.shakiba.net I will use this name, you have your own. You can see bellow I have the file
basic configuration to check the load of the domain
root directory we have set up is /var/www/live so make sure you have it and add a sample index.html to the location which means we will have /var/www/live/index.html
reload or restart Ningx the load your own domain name or IP address ir you did not have domain name and have set it up on your localhost
Here is a screenshot of mine which I made it fancy, of course you do not have to make it fancy.

the reset will be added soon
Last updated
Was this helpful?