NGINX configures rtmp server to implement rtmp and hls live broadcast

WBOY
Release: 2016-08-08 09:29:44
Original
1847 people have browsed it

Introduction to my use of NGINX

First, the configuration:

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; } } } 
Copy after login

Interpretation of the configuration


  • workprocesses and work_connections

work_processes: Start the process, usually set to an equal number of CPUs.
work_connections: The maximum number of concurrent connections for a single background worker process

  • http server configuration

    • sendndfile: Specify whether nginx calls the sendfile function (zero copy mode) to output files. For ordinary applications, it must be set to on. If it is used for disk IO heavy load applications such as downloading, it can be set to off to balance disk and network I/O processing speeds and reduce system uptime.
    • keepalive_timeout: connection timeout
    • server
      • listen: configuration Which port to listen to
      • server_name: Define access using xxx, that is, the domain name corresponding to the IP
      • loaction /: Default request
      • error_page and the following location: Define the error prompt page
      • location /hls: Define the request hls, I am here The statement here is that if you request an hls stream, you need to add m3u8 after the playback address. The slice of hls is obtained from /tmp/app. The app defines the
  • rtmp streaming server configuration
    • listen: Listening port
    • application liaortmp: Configure rtmp normal push request here
    • application liaohls: Configure rtmp push request here, play through hls mode, slices are placed in /tmp/app, This corresponds to the http configuration above. Whatever the app writes here, it will also be written at http. Live on: Switch the live broadcast mode, that is, one-to-many broadcast. hls on: Switch HLS in the application.
      • hls_path: Slice storage address
      • hls_fragment: Slice size, set HLS segment length, the default is 5 seconds

      Now the simple configuration of nginx has been completed, /usr/local/conf/nginx The above configuration is stored in .conf.
    An example (about
  • app

    )


    • rtmp streaming and rtmp playback
    Push streaming address: rtmp://x.x.x.x:1935/liaortmp/liao
    • Playing address: rtmp ://x.x.x.x:1935/liaortmp/liao

      • rtmp push streaming and hls live streaming

      • Push streaming address: rtmp://x.x.x.x:1935/liaohls/liao
    • Playing address: rtmp://x.x.x.x :80/hls/liao

      • liao
      • can be replaced by anything.

      Reference1. Detailed description of Nginx configuration file2. Nginx RTMP module nginx-rtmp-module command detailed explanation
    The above introduces the configuration of NGINX rtmp server to implement rtmp and hls live broadcast, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.



    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!