Configure the rtmp Server in NGINX to implement rtmp and hls live broadcast

Source: Internet
Author: User
: This article mainly introduces how to configure the rtmp Server for NGINX to implement rtmp and hls live broadcast. if you are interested in PHP Tutorial, refer to it. Introduction to NGINX

First configure:

work_processes4;events{    work_connections1024;}http{    include mime.types;    default_type application/octet-stream;    sendfileon;    keepalive_timeout65;    server{        listen80;        server_name localhost;        location /{            root html;            insex index.html index.htm;            }        location /hls{            alias /tmp/app;            }        error_page500502503504 /50x.html;        location = /50x.html{            root html;            }        }    }rtmp{    server{        listen1935;        chunk_size4000;        application liaortmp{            liveon;            }        application hls{            liveon;            hlson;            hls_path /tmp/app;            hls_frament15s;            }        }    }

Explanation of configuration


  • Workprocesses and work_connections

Work_processes: starts a process, which is usually set to an equal number of CPUs.
Work_connections: maximum number of concurrent connections of a single backend worker process

  • Http server configuration

    • Sendndfile: Specifies whether nginx calls the sendfile function (zero copy mode) to output files. for common applications, this function must be set to on. if this function is used for downloading application disk I/O heavy load applications, it can be set to off to balance the disk and network I/O processing speed and reduce the system uptime.
    • Keepalive_timeout: connection timeout
    • Server
      • Listen: port used to configure the listener
      • Server_name: the domain name corresponding to the IP address.
      • Loaction/: default request
      • Error_page and the following location: defines the error prompt page
      • Location/hls: define the request hls. my declaration here is that if the request hls stream needs to be added to the stream playback address with m3u8, hls slice from/tmp/appCome on, the app is defined for itself
  • Configuration of rtmp streaming server
    • Listen: listening port
    • Application liaortmp: Configure rtmp normal streaming requests here
    • Application liaohls: configure the rtmp streaming request here, play the video in hls mode, and place the slice in/tmp/app, Which corresponds to the http configuration above. what is written by the app here and what is written in http?
      • Live on: switch the live broadcast mode, that is, one-to-multiple broadcast.
      • Hls on: switch HLS in application
      • Hls_path: slice storage address
      • Hls_fragment: Slice size. set the length of HLS segments. the default value is 5 seconds.

  • So far, the simple configuration of nginx has been completed, and the above configuration is stored in/usr/local/conf/nginx. conf.

    • Give a column (aboutapp)
    • Rtmp streaming and rtmp playback
      • Streaming address: rtmp: // x. x: 1935/liaortmp/liao
      • Playback address: rtmp: // x. x: 1935/liaortmp/liao
    • Rtmp streaming and hls live broadcasting
      • Streaming address: rtmp: // x. x. x: 1935/liaohls/liao
      • Playback address: rtmp: // x. x: 80/hls/liao

      liaoCan be replaced by any.

    Reference
    1. Nginx configuration file description
    2. Nginx RTMP module nginx-rtmp-module instructions

    The above describes how to configure the rtmp Server for NGINX to implement rtmp and hls live broadcast, including some content, and hope to help friends who are interested in PHP tutorials.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.