关于macos:MacOS-1015-安装nginxrtmp-推流接流-以及-错误记录

34次阅读

共计 2604 个字符,预计需要花费 7 分钟才能阅读完成。

1. 下载

mkdir nginx_rtmp
wget http://nginx.org/download/nginx-1.15.3.tar.gz
tar -zxvf nginx-1.15.3.tar.gz
git clone https://github.com/arut/nginx-rtmp-module

2. makefile 生成

若没有则装置 openssl。
–prefix 是你的 nginx 的装置目录,留神批改成你本人的用户名。
将 git clone 的模块退出。
并指出 openssl 的地址(无需批改)。这一步仿佛大家都须要,mac 没有本人找到这个库。

brew install openssl
cd nginx-1.15.3
./configure --prefix=/Users/{your username}/nginx --with-http_ssl_module --add-module=../nginx-rtmp-module --with-openssl=/usr/local/opt/openssl@1.1

若生成胜利,则会显示这样的 summary

Configuration summary
  + using system PCRE library
  + using OpenSSL library: /usr/local/opt/openssl@1.1
  + using system zlib library

  nginx path prefix: "/Users/ray/nginx"
  nginx binary file: "/Users/ray/nginx/sbin/nginx"
  nginx modules path: "/Users/ray/nginx/modules"
  nginx configuration prefix: "/Users/ray/nginx/conf"
  nginx configuration file: "/Users/ray/nginx/conf/nginx.conf"
  nginx pid file: "/Users/ray/nginx/logs/nginx.pid"
  nginx error log file: "/Users/ray/nginx/logs/error.log"
  nginx http access log file: "/Users/ray/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

3. make & make install

间接 make 会报错:

make -j8
...
...
...
 /Library/Developer/CommandLineTools/usr/bin/make -f objs/Makefile
cd /usr/local/opt/openssl@1.1 \
&& if [-f Makefile]; then /Library/Developer/CommandLineTools/usr/bin/make clean; fi \
&& ./config --prefix=/usr/local/opt/openssl@1.1/.openssl no-shared no-threads  \
&& /Library/Developer/CommandLineTools/usr/bin/make \
&& /Library/Developer/CommandLineTools/usr/bin/make install_sw LIBDIR=lib
/bin/sh: ./config: No such file or directory
make[1]: *** [/usr/local/opt/openssl@1.1/.openssl/include/openssl/ssl.h] Error 127
make: *** [build] Error 2

须要批改

sudo vim ./auto/lib/openssl/conf

把上面的几行中的.openssl 去掉,而后保留

39             CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
40             CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
41             CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
42             CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"

改成

39             CORE_INCS="$CORE_INCS $OPENSSL/include"
40             CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h"
41             CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libssl.a"
42             CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libcrypto.a"

此时,须要从新执行第二步 configure,再 make 胜利。

最初:

make install

4. 启动服务

cd /Users/{your username}/nginx 
sudo vim conf/nginx.conf

将上面的 rtmp 服务增加在最初(其中 rtmplive 能够自命名)

rtmp {
    server {
        listen 1935;

        application rtmplive {live on;}
    }
}

而后启动服务

./sbin/nginx -c ./conf/nginx.conf

5. 测试

ffmpeg -re -i test.mp4 -vcodec libx264 -acodec aac -f flv rtmp://localhost:1935/rtmplive/home

ffplay -i. rtmp://localhost:1935/rtmplive/home

此时就能看到你推流的视频啦~

6. References

MAC 上编译装置 nginx-rtmp-module 流媒体服务器

正文完
 0