• Nginx 搭建rtmp直播服务器


    1.到nginx源码目录新建个rtmp目录 ,进入  git clone https://github.com/arut/nginx-rtmp-module.git  
    2.重编译nginx 代码如下

    [Shell] 纯文本查看 复制代码
    1
    2
    3
    ./configure  --prefix=/usr/local/nginx-1.2.9/ --add-module=./rtmp/nginx-rtmp-module --with-http_ssl_module --with-pcre=/lamp_source/pcre-8.38;
     make;make install;
    #重新安装nginx


    3.完成安装后。

    打开nginx.conf 在http{server...} 之后加上以下代码

    [AppleScript] 纯文本查看 复制代码
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    rtmp{
            server{
                    listen 1935;
                    chunk_size 4000;
                    application hls {
                            live on;
                            hls on;
                            hls_path /你的服务器路径这个用于存放缓存文件的。必须可写;
                            hls_fragment 5s;
                    }
            }
    }


    然后新建个主机配置

    [AppleScript] 纯文本查看 复制代码
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    server {
     
            listen  8851;
            location /index.html {
            root /网站存放目录;
    }
            location / {# return 403;
                # Serve HLS fragments
               types {
                   application/vnd.apple.mpegurl m3u8;
                   video/mp2t ts;
               }
               root /同上,缓存用;
                expires -1;
            }
        }



    完成以上配置后。 下载一个软件叫做 open broadcaster software 的软件推流即可(注意,也可以使用ffmpeg 进行推流)。 软件使用如截图

    然后点开始串流就可以了。

    下载打开vlc播放器(拉流)。输入 rtmp://你的网址:1935/hls/上图中的密码    然后就ok了。 成功在线直播

  • 相关阅读:
    sqlzoo练习系列(一)——SELECT 基础
    域名重定向
    自动识别PC端、移动端,并跳转
    Laravel传递多个参数到页面
    Laravel提示The GET method is not supported for this route. Supported methods: POST.错误的解决办法
    Laravel8和之前Laravel版本的区别
    Laravel使用Ajax提交表单报419 unknown status错误的解决方法
    PHP 函数调用之引用地址
    软件开发流程以及开发原则
    php 函数基础
  • 原文地址:https://www.cnblogs.com/ghjbk/p/7792019.html
Copyright © 2020-2023  润新知