您的位置:首页 > 运维架构 > Nginx

MAC使用Nginx搭建RTMP服务器

2018-03-27 10:52 399 查看

1、先安装homeView

安装命令
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
移除命令
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

2、安装Nginx服务器

增加对 nginx 的扩展;也就是从github上下载,home-brew对ngixnx的扩展

brew tap homebrew/nginx

3、安装Nginx服务器和rtmp模块,安装过程有点久。稍等。

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

4、查看nginx的信息

brew info nginx-full

nginx的安装位置

/usr/local/Cellar/nginx-full/1.10.1/bin/nginx
nginx配置文件所在位置
/usr/local/etc/nginx/nginx.conf
nginx服务器根目录所在位置
/usr/local/var/www

使用命令开启nginx:

nginx

在浏览器地址栏输入:http://localhost:8080 (直接点击)

图1.jpg

5、配置rtmp

open /usr/local/etc/nginx

打开niginx的文件夹,找到nginx.conf文件,用xcode打开。添加下面配置

#在http节点下面(也就是文件的尾部)加上rtmp配置:
rtmp {#协议名称
server {#说明内部中是服务器相关配置
listen 12345;#监听的端口号, rtmp协议的默认端口号是1935
application zbcs {#访问的应用路径是 zbcs
live on; #开启实时
record off;#不记录数据
}
}
}


图2.jpg

6、 保存文件后,重新加载nginx的配置文件。

重要操作!一定要重启nginx
nginx -s reload

7、 安装ffmepg工具

brew install ffmpeg

8、推流

ffmpeg -re -i /Users/mazaiting/Downloads/台球.mp4 -vcodec copy -f flv rtmp://localhost:12345/zbcs/room

其中abcs是配置文件中的应用名,12345是配置文件中的端口,room可以随便写,"/Users/mazaiting/Downloads/台球.mp4"是推流的视频。

9、观看

使用软件VLC MediaPlayer打开网络串流,Open Media...->Network,输入
rtmp://localhost:12345/zbcs/room
,点击Open进行观看。

图3.jpg
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: