在mac本地搭建rtmp服务器用于测试

OSX安装nginx和rtmp模块(rtmp直播服务器搭建)

参考文章:html

https://github.com/Homebrew/homebrew-nginxnginx

1.安装Homebrew,执行命令git

1github

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

2.执行命令:ruby

1服务器

brew tap homebrew/nginxapp

3.执行命令:curl

1工具

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

经过操做以上步骤nginx和rtmp模块就安装好了,下面开始来配置nginx的rtmp模块

首先来看看咱们的nginx安装在哪里了

1

brew info nginx-full

 执行上面的命令后咱们能够看到信息

1

2

3

4

5

6

7

8

9

10

11

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.8.1/bin/nginx

 $ sudo chmod u+s /usr/local/Cellar/nginx-full/1.8.1/bin/nginx

 nginx安装所在位置

1

/usr/local/Cellar/nginx-full/

nginx配置文件所在位置

1

/usr/local/etc/nginx/nginx.conf

 nginx服务器根目录所在位置

1

/usr/local/var/www

执行命令 ,测试下是否能成功启动nginx服务

1

/usr/local/Cellar/nginx-full/1.8.1/bin/nginx

 在浏览器地址栏输入:http://localhost:8080    若是出现

Welcome to nginx!

表明nginx安装成功了

 

如今咱们来修改nginx.conf这个配置文件,配置rtmp

4.用记事本工具打开nginx.conf

1

2

3

4

5

6

7

8

9

10

11

12

13

http {

    ……

}

在http节点后面加上rtmp配置:

rtmp {

    server {

        listen 1935;

        application live1 {

            live on;

            record off;

        }

    }

}

 而后保存文件后,从新加载nginx的配置文件

/usr/local/Cellar/nginx-full/1.8.1/bin/nginx -s reload

 

如今咱们能够来对推流进行测试了 看看咱们的rtmp能不能推流成功

推流咱们能够经过ffmepg来进行

5.安装ffmepg工具

1

brew install ffmpeg

 安装这个须要等一段时间等待吧 而后准备一个视频文件做为来推流,而后咱们在安装一个支持rtmp协议的视频播放器,Mac下能够用VLC

 

ffmepg 安装完成后能够开始推流了

6.经过ffmepg命令进行推流

1

ffmpeg -re -i /Users/Rick/Movies/Demo.mov -vcodec copy -f flv rtmp://localhost:1935/live1/room1

 这个room1是能够随便定义的,只要live1和上面nginx.conf里面配置的同样就行

而后电脑上打开vlc这个播放器软件  点击File---->Open Network 在弹出来的框中选择Network而后输入URL:

1

rtmp://localhost:1935/live1/room1

 

这样就能看到经过ffmpeg推过来的视频了

这就是一个简单的视频直播服务器的搭建

相关文章
相关标签/搜索