流媒体服务之基于RTMP的本地Nginx服务器和VLC安装

1、搭建基于RTMP的本地Nginx服务器

第一步:查看brew有没有安装 终端输入

man brew

如下:

如果没有安装,则在终端输入以下命令安装

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

第二步:先clone nginx项目到本地

brew tap homebrew/nginx

如果报错(路径为空)改为输入

brew tap denji/homebrew-nginx

 

 

 等了一会终于动了,长时间处于Updateing ,按control+C 取消 Updating Homebrew 操作。

或者切换到阿里路径尝试,参考homebrew长时间停在Updating Homebrew 这个步骤 (不过本人尝试无用,又换了回来)

再次尝试,多等了一会,成功,其实就是耗时操作。

第三步:克隆成功,安装Nginx 终端输入如下:

brew install nginx-full --with-rtmp-module

本人出现的问题

 

 

 多个镜像地址,brew不知道该怎么办了!

brew untap denji/nginx

依然报错可以尝试

brew unlink nginx

brew cleanup 
brew install nginx
#不行再次尝试
brew install nginx
#等待成功

nginx

在你的浏览器输入 http://192.168.1.105:8080(192.168.1.105为本机IP地址) ,显示如下图则成功,如果不成功请百度搜索:8080端口被占用

第六步:搜索nginx.conf

在终端 按住 Command+F 搜索 nginx.conf

 第七步:打开nginx.conf

 回到桌面按住 Shift+Command+G 前往 nginx.conf (终端不要关闭)

第八步:打开 nginx.conf

1.配置Nginx,支持rtmp协议推流,将如下代码插入,如下图

rtmp {
    server {
        listen 1935;
        application rtmplive {
            live on;
            max_connections 1024;
        }
        application hls{
            live on;
            hls on;
            hls_path /usr/local/var/www/hls;
            hls_fragment 1s;
        }
    }
}

2.配置Nginx,支持http协议拉流,将如下代码插入,如下图

location /hls {
        #Serve HLS config
        types {
                application/vnd.apple.mpegurl    m3u8;
                video/mp2t ts;
        }
        root /usr/local/var/www;
        add_header Cache-Control    no-cache;
 }

第九步:最后一步,重启nginx

nginx -s reload

在此本地推流的工作完成,暂时不支持外网推流

VLC安装测试拉流

百度搜索VCL

自行下载安装

 

 运行 file -openNetwork 

 

 代开拉流地址即可。

至此服务器测试完成。

 

posted @ 2020-04-28 15:29  M·emor·Y  阅读(593)  评论(0编辑  收藏  举报