笔记Mac下配置nginx+rtmp模块推流服务器碰到的问题整理

安装环境 ,Mac版本 : 10.13.5

在装的nginx版本为1.13.12


安装命令见:https://blog.csdn.net/zjuwwj/article/details/72773704

如果你输入http://localhost:8080后能看到nginx配置的首页那说明OK。

或nginx -v看下版本号。都能确保装上.

下面是在挂装rtmp模块时出现的问题处理。

安装命令见:https://blog.csdn.net/leonpengweicn/article/details/44917943

安装tap时:brew tap homebrew/nginx  报was deprecated.

报下面这个错

Updating Homebrew...

==> Auto-updated Homebrew!

Updated 1 tap (homebrew/core).

==> Updated Formulae

abyss               docker2aci          libhttpseverywhere  subversion

amqp-cpp            emscripten          mypy                tup

chronograf          grpc                packmol             znapzend

dnscrypt-proxy      influxdb            rancher-cli


Error: homebrew/nginx was deprecated. This tap is now empty as all its formulae were migrated.

并不那么顺利,根查原因是因为homebrew/nginx的git路径变了。因此后面找到一个denji/nginx的。

把命令改为 brew tap denji/nginx

fsh-mac--00-24-D6-72-E4-6A:~ fengsh$ brew tap denji/nginx

Updating Homebrew...

==> Tapping denji/nginx

Cloning into '/usr/local/Homebrew/Library/Taps/denji/homebrew-nginx'...

remote: Counting objects: 72, done.

remote: Compressing objects: 100% (72/72), done.

remote: Total 72 (delta 1), reused 28 (delta 0), pack-reused 0

Unpacking objects: 100% (72/72), done.

Tapped 62 formulae (162 files, 130.2KB)

装好这个本以为就可以直接装rtmp模块了。

直接装rtmp命令 : brew install nginx-full --with-rtmp-module

fsh-mac--00-24-D6-72-E4-6A:~ fengsh$ brew install nginx-full --with-rtmp-module

==> Installing nginx-full from denji/nginx

Error: Cannot install denji/nginx/nginx-full because conflicting formulae are installed.

  nginx: because nginx-full symlink with the name for compatibility with nginx


Please `brew unlink nginx` before continuing.


Unlinking removes a formula's symlinks from /usr/local. You can

link the formula again after the install finishes. You can --force this

install, but the build may fail or cause obscure side-effects in the

resulting software.


又出问题了,denji的git下没有nginx-full?详细看错误有一句 please 'brew unlink nginx ' before continuing.

因此在执行装rtmp时先执行 brew unlink nginx 再来安装,最后成功了。

fsh-mac--00-24-D6-72-E4-6A:~ fengsh$ brew unlink nginx

Unlinking /usr/local/Cellar/nginx/1.13.12... 2 symlinks removed

fsh-mac--00-24-D6-72-E4-6A:~ fengsh$ brew install nginx-full --with-rtmp-module

Updating Homebrew...

==> Installing nginx-full from denji/nginx

==> Installing dependencies for denji/nginx/nginx-full: rtmp-nginx-module

==> Installing denji/nginx/nginx-full dependency: rtmp-nginx-module

==> Downloading https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive

==> Downloading from https://codeload.github.com/sergey-dryabzhinsky/nginx-rtmp-

######################################################################## 100.0%

==> Downloading https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/compare

######################################################################## 100.0%

==> Patching

==> Applying v1.1.7.10...d25c56f.diff

patching file .gitignore

patching file README.md

patching file config

patching file dash/ngx_rtmp_dash_module.c

patching file doc/README.md

patching file doc/directives.md

patching file hls/ngx_rtmp_hls_module.c

patching file hls/ngx_rtmp_mpegts.c

patching file hls/ngx_rtmp_mpegts.h

patching file hls/ngx_rtmp_mpegts_crc.c

patching file hls/ngx_rtmp_mpegts_crc.h

patching file ngx_rtmp.c

patching file ngx_rtmp_auto_push_module.c

patching file ngx_rtmp_cmd_module.h

patching file ngx_rtmp_codec_module.c

patching file ngx_rtmp_core_module.c

patching file ngx_rtmp_exec_module.c

patching file ngx_rtmp_handshake.c

patching file ngx_rtmp_live_module.c

patching file ngx_rtmp_live_module.h

patching file ngx_rtmp_netcall_module.c

patching file ngx_rtmp_notify_module.c

patching file ngx_rtmp_record_module.c

patching file ngx_rtmp_record_module.h

patching file ngx_rtmp_shared.c

patching file ngx_rtmp_version.h

 配置文件 open /usr/local/etc/nginx 下的nginx.conf

#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    
    keepalive_timeout  65;
    server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
		
		#配置rtmp stat
        location /stat {
          rtmp_stat all;
          rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            root /usr/local/Cellar/rtmp-nginx-module/1.1.7.11-dev_2/share/rtmp-nginx-module;
        }

        location /control {
          rtmp_control all;
        }

        #HLS配置开始,这个配置为了`客户端`能够以http协议获取HLS的拉流
        location /hls {
            # Serve HLS fragments
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            root html;
            add_header Cache-Control no-cache;
        }
		#HLS配置结束

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }


    
    include servers/*;
}

rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;

        application myapp {
            live on;
            record off;
	    max_connections 1024;
        }

    #增加对HLS支持开始
    application hls {
        live on;
        hls on;
        hls_path /usr/local/var/www/hls;
        hls_fragment 5s;
    }
    #增加对HLS支持结束
    }
}
有关rtmp的配置项看这个: https://www.cnblogs.com/lidabo/p/7099501.html


配置好之后要记得 nginx -s reload 重新加载配置。

之后就可以使用ffmpeg+vlc 进行推流测试了。(经试推流过一段时间会有Broken pipe)还在百度中,希望能找到吧。


你可能感兴趣的:(FFmpeg)