1. 下载源码 http://hg.nginx.org/nginx nginx-c74904a17021.zip https://github.com/arut/nginx-rtmp-module nginx-rtmp-module-master.zip https://www.openssl.org/source/ https://www.openssl.org/source/openssl-1.0.2r.tar.gz https://ftp.pcre.org/pub/pcre/ https://ftp.pcre.org/pub/pcre/pcre-8.43.zip http://www.zlib.net/ http://www.zlib.net/zlib-1.2.11.tar.gz 2. 源码部署 nginx-rtmp-module-master.zip 解压到 nginx-c74904a17021/nginx-rtmp-module nginx-c74904a17021 目录下创建目录 libs openssl-1.0.2r.tar.gz pcre-8.43.zip zlib-1.2.11.tar.gz 解压到 nginx-c74904a17021/libs 3. 启动 MSYS 进入 nginx-c74904a17021 目录 最新版本 nginx 的 configure 在 auto 目录下 ./auto/configure --prefix=/usr/opt/nginx-1.15.9 --with-pcre=/usr/build/libs/nginx-c74904a17021/libs/pcre-8.43 --with-openssl=/usr/build/libs/nginx-c74904a17021/libs/openssl-1.0.2r --with-zlib=/usr/build/libs/nginx-c74904a17021/libs/zlib-1.2.11 --add-module=/usr/build/libs/nginx-c74904a17021/nginx-rtmp-module --with-http_ssl_module 4. 修改源码 nginx-c74904a17021 ginx-rtmp-module gx_rtmp.h #if (NGX_WIN32) //typedef __int8 int8_t; typedef unsigned __int8 uint8_t; #endif Note: int8_t 已经在 gcc 里定义过 nginx-c74904a17021objs gx_auto_config.h #ifndef NGX_PREFIX //#define NGX_PREFIX "/usr/opt/nginx-1.15.9/" #define NGX_PREFIX "./" #endif Note: NGX_PREFIX 定义成 /usr/opt/nginx-1.15.9/ 时 windows 系统无法正确地找到目录 nginx-c74904a17021objsMakefile //CC = cc CC = gcc Note: MSYS 没有 cc //advapi32.lib ws2_32.lib /usr/build/libs/nginx-c74904a17021/libs/pcre-8.43/.libs/libpcre.a /usr/build/libs/nginx-c74904a17021/libs/openssl-1.0.2r/.openssl/lib/libssl.a /usr/build/libs/nginx-c74904a17021/libs/openssl-1.0.2r/.openssl/lib/libcrypto.a -lgdi32 -lcrypt32 -lws2_32 /usr/build/libs/nginx-c74904a17021/libs/zlib-1.2.11/libz.a -l advapi32 -l ws2_32 /usr/build/libs/nginx-c74904a17021/libs/pcre-8.43/.libs/libpcre.a /usr/build/libs/nginx-c74904a17021/libs/openssl-1.0.2r/.openssl/lib/libssl.a /usr/build/libs/nginx-c74904a17021/libs/openssl-1.0.2r/.openssl/lib/libcrypto.a -lgdi32 -lcrypt32 -lws2_32 /usr/build/libs/nginx-c74904a17021/libs/zlib-1.2.11/libz.a Note: MSYS 不支持 advapi32.lib ws2_32.lib 5. 编译安装 make make install opt ginx-1.15.9sbin ginx.exe 移到 opt ginx-1.15.9 ginx.exe opt ginx-1.15.9 目录下创建 nginx-1.15.9 emphls 修改 nginx.conf 文件 nginx-1.15.9-v2conf ginx.conf worker_processes 1; error_log logs/error.log info; events { worker_connections 1024; } rtmp { server { listen 1935; application live { live on; } application hls { live on; hls on; hls_path temp/hls; hls_fragment 8s; } } } http { server { listen 8080; location / { root html; } location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root html; } location /hls { #server hls fragments types{ application/vnd.apple.mpegurl m3u8; video/mp2t ts; } alias temp/hls; expires -1; } } } 运行 nginx.exe 6. 测试 安装 Screen Capturer Recorder v0.12.10 https://sourceforge.net/projects/screencapturer/files/ 创建 streaming.cmd @echo off set bitrate=1200 set maxrate=2400 set x264=-look_ahead 0 -ac 2 -c:v h264_qsv -profile:v high -level 3.1 -preset:v veryfast set ki=-keyint_min 72 -g 72 -sc_threshold 0 set br=-b:v %bitrate%k -minrate %bitrate%k -maxrate %maxrate%k -bufsize %maxrate%k -b:a 128k set vf=-vf crop=854:480:1920-854:0,fps=fps=24 set deskdev=-f dshow -i video="screen-capture-recorder" -f dshow -i audio="virtual-audio-capturer" ffmpeg -threads 4 -hide_banner -rtbufsize 512M -re %deskdev% %ki% %vf% %x264% %br% -f flv rtmp://localhost:1935/live/ pause 创建 pull.cmd @echo off ffplay.exe rtmp://localhost:1935/live/ 执行 streaming.cmd 后 执行 pull.cmd 如果能正常播放说明成功了 下载编译好的程序包 https://files.cnblogs.com/files/nlsoft/nginx-1.15.9_rtmp-module-1.2.1_bin.7z