• [微信小程序直播平台开发]___(二)Nginx+rtmp在Windows中的搭建


    1.一个可以忽略的前言

    Nginx (engine x) 是一个高性能的HTTP反向代理服务,也是一个IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日。

    接下来我将讲到怎么在win系统中搭建Nginx-rtmp。之前我查找到了一个教程,跟着博主的流程走,过程是安装一堆环境一堆依赖包来把Nginx源码编译成win系统使用的,结果后来出现了丢失文件的错误,看得头皮发麻后来才知道不需要自己编译这么麻烦又容易出错的。

    2.下载解压与配置

    下载地址 nginx-rtmp-module

     解压后在根目录下的conf文件夹中打开nginx.conf文件

    这个是跟rtmp服务有关的配置

    rtmp {
        server {
            listen 1935;
    
            application live {
                live on;
            }
    		
            application hls {
                live on;
                hls on;  
                hls_path temp/hls;  
                hls_fragment 8s;  
            }
        }
    }

    这个是跟网站有关的

    http {
        server {
            listen      8080;
            
            location / {
                root html;
            }
            
            location /stat {
                rtmp_stat all;
                rtmp_stat_stylesheet stat.xsl;
            }
    
            location /stat.xsl {
                root html;
            }
            
            location /hls {  
                #server hls fragments  
                types{  
                    application/vnd.apple.mpegurl m3u8;  
                    video/mp2t ts;  
                }  
                alias temp/hls;  
                expires -1;  
            }  
        }
    }

    server.listen是监听的端口,根据实际需求修改

    其他配置参数自行百度此处不做详细介绍

    3.使用测试

    打开cmd,cd到解压的根目录下,输入start nginx

    其他命令:

    nginx.exe -s quit
    退出
    nginx.exe -s stop
    快速退出
    
    nginx.exe -s reload
    当配置信息修改,需要重新载入这些配置时使用此命令。

    在浏览器中输入http://localhost:8080/

    可以访问到这个页面说明已经正常打开了

    4.推流测试

    下载OBS 

    打开后在 来源下方点击加号选择“显示器捕获” 点确认,来实时捕捉显示器的画面

    点击右下角的设置按钮,来配置串流

    其中的流秘钥起到识别作用,此处我填写test来做测试

    完毕后点击右下角的开始串流。

    访问之前的那个8080的页面,点击RTMP 点播测试器 跳转到如下页面

    在下方的链接输入框中输入 http://xxx:1935/hls/test.m3u8  再点击旁边的按钮,一切正常的话 就可以看到我们通过OBS录制的画面了

    到此,服务器的配置与基础使用已经介绍完毕了,剩下的就是在小程序中进行推拉流了,此处给几个教程的机票

    https://blog.csdn.net/u012536034/article/details/80524748

    https://www.cnblogs.com/pass245939319/p/9001137.html

     https://developers.weixin.qq.com/miniprogram/dev/api/api-live-pusher.html

    参考来源:

    https://blog.csdn.net/chen782079048/article/details/70917471

  • 相关阅读:
    【SpringMVC】SpringMVC系列15之SpringMVC最佳实践
    【SpringMVC】SpringMVC系列14之SpringMVC国际化
    could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of(maven报错)
    ubuntu14安装tensorflow并测试
    HTMLajax跨域向服务器写入数据
    eclipse的最新版本luna的中建立svn和maven
    关于equals与hashcode的重写
    会计中的冲销和红票
    dubbo在项目中的应用
    dubbo介绍以及创建
  • 原文地址:https://www.cnblogs.com/ysls/p/9662990.html
Copyright © 2020-2023  润新知