Build Nginx-RTMP live server on ubuntu

Preface##

Recently I have been learning Android live broadcast, so there is no doubt that ffmpeg and WebRTC are the two big players in the audio and video industry.

The basic use of ffmpeg: https://blog.csdn.net/huangliniqng/article/details/81842273

I have seen many tutorials explaining how to build a live broadcast environment, most of which are built on a mac environment. It is more cumbersome for windows users. At this time yesterday, I tried to build a Nginx-rtmp live server locally in windows, and it finally worked successfully. . The effect diagram is shown below.

But we will not explain how to build a live server on windows today. If you have any questions, you can discuss it together. Today I will explain how to build a live server on the ubuntu server. (We don’t build wheels here, just to make it easier to build later)

1. Introduction to RTMP##

RTMP stands for Real Time Messaging Protocol (Real Time Messaging Protocol), rmtp is a communication protocol. This protocol is based on TCP and is a protocol family, including RTMP basic protocol and RTMPT/RTMPS/RTMPE and other variants. RTMP is a network protocol designed for real-time data communication. It is mainly used for audio, video and data communication between the Flash/AIR platform and a streaming media/interactive server that supports the RTMP protocol.

2. Environment Construction##

If you are not familiar with linux operation commands, you can move to my linux series articles:

https://mp.csdn.net/postedit/82469566

** First create a directory for source code compilation and enter. **

**   $ mkdir nginx-src****    $ cd nginx-src**

Download the source code** $ git clone https://github.com/nginx/nginx.git**** $ git clone https://github.com/arut/nginx-rtmp-module.git**** $ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz**** $ tar -xzvf pcre-8.39.tar.gz**** $ cd nginx$ git checkout release-1.9.9**

Compile and install

# Encapsulate the configure command into a script **** $ vim cfg.sh

Contents of cfg.sh file

auto/configure --prefix=/usr/local/nginx
      --with-pcre=../pcre-8.39
              --with-http_ssl_module
              --with-http_v2_module
              --with-http_flv_module
              --with-http_mp4_module
              --add-module=../nginx-rtmp-module/

$ chmod a+x cfg.sh
$ ./cfg.sh
$ make 
$ make install

3. Configure service environment###

After the installation is complete, modify the configuration file to perform the following operations:

Enter cd /usr/local/nginx/conf

Edit nginx.conf, if you are prompted that there is no permission, execute sudo chmod 777 nginx.conf to get all permissions

Edit the nginx.conf file, mainly to add rtmp service

After the configuration is complete, save the file.

Execute the following command to restart nginx:
sudo /usr/local/nginx/sbin/nginx -s stop

sudo /usr/local/nginx/sbin/nginx

If there is no error, the rtmp streaming media has been successfully built at this time,

Then we use the tool to test, you can also use the webrtc-android terminal to test, here we use the tool SmarterStreaming, download address: https://github.com/daniulive/SmarterStreaming

Before testing, we must first push a video stream

We use the command ffmpeg -re -i soft/2.mp4 -c copy -f flv rtmp://localhost:1935/live/film

soft/2.mp4 is the video address on the server. If the following figure appears when running, it means that there is no problem with the above environment.

We use the testing tool to test, enter the address rtmp://123.207.55.74:1935/live/film

Results as shown below:

When the push is over, the playback ends (think carefully about pushing like a TV station and then ending and then pushing ads, etc.)

Sharing technical articles, submitting and sharing, unlimited technical types, unlimited technical depth, so that more people can benefit from sharing.

Recommended Posts

Build Nginx-RTMP live server on ubuntu
Build a file server on ubuntu
[Linux] Build Samba server (ubuntu16.04)
Install OpenSSL 1.0.2 on Ubuntu Server 14.04
ubuntu 16.04 build pptpd V** server
Configure tomcat on ubuntu server
Build Ubuntu 12.04 cross compilation server
Ubuntu16.04 build GitLab server tutorial
Install Chef server workstation on Ubuntu 18.04
Ubuntu16.04 build php5.6 Web server environment
Teach you how to build a Git server on Ubuntu
How to build an NFS file sharing server on Ubuntu 16.04
Build Discuz forum based on ubuntu
Install Oracle 11gR2 on Ubuntu Server 12.4.0
Install Gnome and VNC on Ubuntu Server
Build a LAMP development environment on Ubuntu 16.04
How to build nfs service on ubuntu16.04
How to install Bacula Server on Ubuntu 14.04
Steps to build LNMP environment on ubuntu 20.04
Build arm virtual operating environment on Ubuntu
How to use Samba server on Ubuntu 16.04
Configure Nginx Git server on Ubuntu system
Build a Minecraft Bedrock Edition server (Ubuntu)
How to install Zabbix on Ubuntu 16.04 Server
lamp on ubuntu
Ubuntu build etcd
Ubuntu build Seafile
How to install Squid proxy server on Ubuntu 18.04
How to set up Shiny Server on Ubuntu 14.04
How to set static IP on Ubuntu 18.04 Server
How to set static IP on Ubuntu 18.04 Server
How to quickly deploy docker on ubuntu server
Configure Wolfram Engine on Tencent Cloud ubuntu server
How to use Jenkins to build automatically on Ubuntu
Configure automatic updates for Ubuntu Server on Azure
How to run the parsing server on Ubuntu 14.04
Install Leanote on Ubuntu18 to build cloud notes
install vscode on ubuntu18
Install Redis on Ubuntu
Build k8s1.9.9 on centos7
Install R4 on ubuntu20
Install nvtop on Ubuntu 18.04
Install postgresql-10 on Ubuntu 18.04
3 minutes to teach you to build gitea on Centos server
Install docker on Ubuntu
How to set up a DNS server on Ubuntu 18.04
Install Docker on ubuntu18.04
Install nodejs10 on Ubuntu16
Ubuntu 18.04 LTS LAMP build
Install mysql on Ubuntu 14.04
Install Django on ubuntu
Install Pytorch+CUDA on Ubuntu 16.04
Install Python3 on Ubuntu 14.04
Jenkins build on centos
Install rJava on Ubuntu18
Install JDK10+ on Ubuntu
Install Python3 on Ubuntu 16.04
ROS learning---Install ROS on Ubuntu
Install KDE on Ubuntu16.04.2
ubuntu install nginx server
Install Docker on Ubuntu18