1. Install the Nginx server

Brew Tap Homebrew/Nginx has the following problem:It is possible that the previous git address is invalid. brew tap denji/nginx

2. Install the Nginx server and RTMP module

brew install nginx-full –with-rtmp-module Brew info nginx-fullThe red box is the location of the root directory of the Nginx server.

Nginx commands:

  • Nginx -s reload: modified configuration file to reload;
  • Nginx-s reopen: Reopen the log file;
  • Nginx -s stop: stops the server
  • Nginx -s quit: exits the server

On the command line, type nginx;The nginx service has been successfully started.

3. Modify the nginx conf configuration

The nginx.conf file in /usr/local/etc/nginx is where the nginx service is configured. Configure RTMP in the file under the HTTP configuration node.

rtmp { server { listen 1935; application test { live on; record off; }}}Copy the code
  • RTMP indicates the protocol name.
  • Server is a server configuration node.
  • Port number of listen (default: 1935).
  • Live on: enables live streaming.
  • Record off means not to record;

Run the nginx -s reload command to restart the configuration.

4. Live streaming

We use ffmpeg to push flow RTMP message: ffmpeg – re – I test3. Mp4 – vcodec copy -f FLV RTMP: / / localhost: 1935 / test/live after after the command is:We found that the wrapper and encoding formats we defined are displayed above, we need to play them out, using VLC or ffplay can play, the following uses VLC play;Of course, you can also directly use the IP address of your computer as a push stream address, look up their OWN IP address: 192.168.0.103 ffmpeg – re – I test3. Mp4 – vcodec copy -f FLV RTMP: / / 192.168.0.103:1935 / test/live A player on his mobile phone and then enter the RTMP: / / 192.168.0.103:1935 / test/live;

Very great; The local use of Nginx to build live streaming server can be; Stay tuned for the next issue;