方案一: nginx
- 首先安装brew,参考http://www.jianshu.com/p/0aa5afd32e86
- 执行命令:
brew tap homebrew/nginx
brew install nginx-full --with-rtmp-module
通过以上步骤nginx和rtmp模块就安装好了,下面配置rtmp模块
- 查看nginx安装信息,执行命令
brew info nginx-full
看到信息如下:
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
-Tips -
Run port 80:
$ sudo chown root:wheel /usr/local/Cellar/nginx-full/1.10.1/bin/nginx
$ sudo chmod u+s /usr/local/Cellar/nginx-full/1.10.1/bin/nginx
Reload config:
$ nginx -s reload
Reopen Logfile:
$ nginx -s reopen
Stop process:
$ nginx -s stop
Waiting on exit process
$ nginx -s quit
To have launchd start homebrew/nginx/nginx-full now and restart at login:
brew services start homebrew/nginx/nginx-full
Or, if you don't want/need a background service you can just run:
nginx
对我们有用的信息如下:
- niginx 服务器所在根目录:
/usr/local/var/www
- niginx安装所在文件夹
/usr/local/Cellar/nginx-full/
- nginx配置文件路径
/usr/local/etc/nginx/nginx.conf
- 版本信息:1.10.1
- 启动nginx
niginx
或者
/usr/local/Cellar/nginx-full/1.10.1/bin/nginx
然后在浏览器地址栏输入:http://localhost:8080
如果出现Welcome to nginx!证明nginx安装成功,可以下一步了,否则卸了重来
- 修改nginx.conf,配置rtmp,执行如下命令
cd /usr/local/etc/nginx
open .
用xcode打开nginx.conf文件
在末尾空白处( }之后空白,也就是118行之后)添加如下代码
rtmp {
server {
listen 1935;
application live {
live on;
record off;
}
}
}
live 表示 app名字,1935表示端口,那么推流和播放地址就是:
rtmp://本机ip(局域网地址):1935/live/xxx
- 保存文件,执行代码:
/usr/local/Cellar/nginx-full/1.10.1/bin/nginx -s reload
注意:1.10.1表示版本,自己根据上面的打印信息适当修改
- 停止nginx服务
nginx -s stop
或者
/usr/local/Cellar/nginx-full/1.10.1/bin/nginx -s stop
方案二:SRS
- srs全称simple-rtmp-server
官网http://www.ossrs.net/srs.release/releases/index.html,不过貌似,现在已经停止更新了
github地址:https://github.com/ossrs/srs/tree/2.0release,这个是2.0版本
MAC下编译SRS源代码
先克隆到本地,代码有点大,耐心等待
git clone https://github.com/ossrs/srs.git
cd srs/trunk
# 指定Mac编译,并关闭其他option
./configure --osx --without-ssl --without-hls --without-hds --without-dvr --without-nginx --without-http-callback --without-http-server --without-stream-caster --without-http-api --without-ffmpeg --without-transcode --without-ingest --without-stat --without-librtmp
make
不出意外就成功了
运行SRS服务器
修改srs.conf
由于Mac系统的限制,运行SRS的话需要把./conf/srs.conf中的并发数修改下,我修改成250:
srs.conf中的这一行需要修改下:max_connections 250;
-
cd srs/trunk
-
开始 ./etc/init.d/srs start
-
停止 ./etc/init.d/srs stop
-
重启 ./etc/init.d/srs restart
开启成功效果如下:
Paste_Image.png
- 推流地址和播放地址:
rtmp://本机ip地址(局域网地址)/xxx/xxx
注:(xxx可以随便写)
网友评论
hhbdeMacBook-Air:~ huhuabin$ brew install nginx-full --with-rtmp-module
Updating Homebrew...
==> Installing nginx-full from homebrew/nginx
==> Installing dependencies for homebrew/nginx/nginx-full: pcre, openssl, rtmp-nginx-module
Error: Cannot link pcre
Another version is already linked: /usr/local/Cellar/pcre/8.38
Error: No such keg: /usr/local/Cellar/nginx-full
报错了