美文网首页
Mac电脑上利用Nginx安装rtmp直播推流服务

Mac电脑上利用Nginx安装rtmp直播推流服务

作者: 放羊娃华振 | 来源:发表于2020-05-06 23:06 被阅读0次

一、安装Homebrew

   这我就不说了,根据自己的电脑情况安装好可用版本就行。

二、安装Nginx+rtmp服务

1、克隆github的项目

brew tap denji/nginx

2、安装nginx+rtmp模块

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

3、修改rtmp的配置

//查看一下nginx的安装信息
brew info nginx-full
//打开配置文件
vi /usr/local/etc/nginx/nginx.conf
//在http节点后面添加rtmp配置
rtmp { 
    server { 
        listen 1935; 
   
        application myapp { 
            live on; 
   
            #record keyframes; 
            #record_path /tmp; 
            #record_max_size 128K; 
            #record_interval 30s; 
            #record_suffix .this.is.flv; 
   
            #on_publish http://localhost:8080/publish; 
            #on_play http://localhost:8080/play; 
            #on_record_done http://localhost:8080/record_done; 
   
       } 
       application hls { 
             live on; 
             hls on; 
             hls_path /tmp/app; 
             hls_fragment 5s; 
   
   
       } 
    } 
}

4、启动nginx

/usr/local/opt/nginx-full/bin/nginx

5、编辑完成之后,执行一下重新加载配置文件命令:

重新加载配置
nginx -s reload
重启nginx:
sudo /usr/local/opt/nginx-full/bin/nginx -s reload

三、安装ffmpeg并且推流

安装ffmpeg
brew install ffmpeg
推流
ffmpeg -re -stream_loop -1 -fflags +genpts -i /Users/tal/Desktop/testmv.mp4  -vcodec copy -acodec copy -strict -2 -f flv -y rtmp://localhost:1935/rtmplive/room

四、安装VLC播放器

下载mac版本的文件,直接安装就行。
用vlc 然后打开 VLC 中 的 file -- Open Network, 直接输入代码中的 url:

rtmp://localhost:1935/rtmplive/room

五、Updating Homebrew... 问题的解决方式。

使用 Alibaba 的 Homebrew 镜像源进行加速
平时我们执行 brew 命令安装软件的时候,跟以下 3 个仓库地址有关:
brew.git
homebrew-core.git
homebrew-bottles

通过以下操作将这 3 个仓库地址全部替换为 Alibaba 提供的地址
 
1. 替换 / 还原 brew.git 仓库地址
# 替换成阿里巴巴的 brew.git 仓库地址:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 还原为官方提供的 brew.git 仓库地址
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
 
#=======================================================

2. 替换 / 还原 homebrew-core.git 仓库地址
# 替换成阿里巴巴的 homebrew-core.git 仓库地址:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# 还原为官方提供的 homebrew-core.git 仓库地址
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

相关文章

网友评论

      本文标题:Mac电脑上利用Nginx安装rtmp直播推流服务

      本文链接:https://www.haomeiwen.com/subject/cgnightx.html