Mac下利用nginx搭建rtmp server

1. RTMP

RTMP specification

The Real-Time Messaging Protocol (RTMP) was designed for high-performance transmission of audio, video, and data between Adobe Flash Platform technologies, including Adobe Flash Player and Adobe AIR. RTMP is now available as an open specification to create products and technology that enable delivery of video, audio, and data in the open AMF, SWF, FLV, and F4V formats compatible with Adobe Flash Player.

  • 基本介绍
    RTMP是指Real Time Messaging Protocol(实时消息传输协议).
    该协议是Adobe公司为Flash播放器和服务器之间音频、视频和数据传输开发的协议.
  • 优点
    RTMP流是利用Adobe flash player即可播放,不依赖于插件,而flash player可以说是电脑的标配.

2. 利用nginx搭建rtmp server

2.1 利用brew安装带有rmtp模块的nginx

brew tap homebrew/nginx
brew install nginx-full --with-rtmp-module

2.2 查看安装信息

brew info nginx-full

Mac下利用nginx搭建rtmp server_第1张图片

可看出配置文件的位置: /usr/local/etc/nginx/nginx.conf

2.3 配置文件中添加rtmp节点

vim /usr/local/etc/nginx/nginx.conf
在http节点后添加如下内容:

rtmp {
    server {
        listen 1935;
        application live {
            live on;
        }
    }
}

2.4 遇到的问题及解决

添加完rtmp节点后,启动nginx时出现如下错误:



发现该文件nginx.pid在相关路径下不存在.

  • 解决方法:
    nginx -c指令指定nginx.conf的位置.
    sudo nginx -c /usr/local/etc/nginx/nginx.conf
    运行完之后在/usr/local/var/run下生成了nginx.pid文件.
    再次尝试启动nginx时, 问题解决.

你可能感兴趣的:(Mac下利用nginx搭建rtmp server)