background

Due to the learning needs, the live streaming push and pull servers are built on centos7 server, mainly based on nginx-Rtmp-Module open source service.

1. Download the nginx broadcast server module address

https://github.com/arut/nginx-rtmp-module/releases/tag/v1.2.1
Copy the code

(1) Decompress nginx-rtmp-module-1.2.1.tar.gz

Tar - XVF nginx RTMP - module - 1.2.1. Tar. GzCopy the code

(2) Add the nginx module

./configure --prefix=./bin --add-module=.. / nginx - RTMP - module - 1.2.1 /Copy the code

If the following information is displayed, the compilation is successful

(3) Make installation

make && make install
Copy the code

(4) Check whether the installation is successful

Configure the nginx.config file

Nginx. Conf configuration

#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } rtmp { server { listen 1935; Application myapp {live on; Drop_idle_publisher 5s; }}} # Http {include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' #  '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; Server {listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; # location / { # root /home/dist; # index index.html index.htm; # } location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat. XSL {root /home/nginx-rtmp-module-1.2.1/; } location /control { rtmp_control all; } location rtmp-publisher {root /home/nginx-rtmp-module-1.2.1/test; } location / {root /home/nginx-rtmp-module-1.2.1/test/ WWW; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php${# proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php${# root HTML; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:! aNULL:! MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} #} # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:! aNULL:! MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # #}}}Copy the code

(6) Run the live broadcast server

./bin/sbin/nginx

(7) Access link address

(8) Push flow

Use OBS Studio tool to test the push flow and configure the push flow address.

(9) pull flow

Use THE LC Media Player tool to test whether there is a live screen.

(10) Mobile phone side through FFmpeg tool pull flow display

The last

The next step will be to collect picture data through the camera of the mobile phone and stream the data to the server, which involves knowledge points such as RTMP and X264 related open source libraries.