Nginx集成HTTP-FLV实现直播推流

win11下nginx编译并集成nginx-http-flv-module模块

一、win11环境搭建

1、安装Microsoft Visual Studio(安装C++桌面开发组件) 官网: https://visualstudio.microsoft.com/zh-hans/

2、安装 Strawberry Perl 官网:https://strawberryperl.com/

3、安装MSYS2 官网: https://www.msys2.org/

二、三方依赖库、源码准备

1、下载nginx源码 官网:https://nginx.org/ || Github:https://github.com/nginx/nginx/releases

2、下载PCRE 官网: http://www.pcre.org/ || Github:https://github.com/PCRE2Project/pcre2/releases

3、下载zlib 官网:http://zlib.net || Github:https://github.com/madler/zlib/releases

4、下载nginx-http-flv-module Github:https://github.com/winshining/nginx-http-flv-module/releases

5、下载OpenSSL 官网:http://www.openssl.org || Github:https://github.com/openssl/openssl/releases

​ 三方库与源码包示例:

在这里插入图片描述

三、构建MakeFile文件

1、解压下载的三方库与源码并移动到nginx根目录(新建)\objs\lib下

在这里插入图片描述

2、打开MSYS2切换到nginx源码根目录

在这里插入图片描述

3、执行以下命令构建MakeFile(如有版本、路径有差异修改源码与三方库的版本)

auto/configure --with-cc=cl --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs/lib/pcre-8.32 --with-zlib=objs/lib/zlib-1.2.13 --with-openssl=objs/lib/openssl-3.0.9 --with-openssl-opt=no-asm --with-http_ssl_module --with-http_sub_module --with-http_auth_request_module --add-module=objs/lib/nginx-http-flv-module-master

执行成功

在这里插入图片描述

四、执行编译

1、打开x64 Native Tools Command Prompt for VS xxxx(xxxx为Microsoft Visual Studio版本)

2、切换到nginx源码根目录

cd D:\Downloads\nginx

3、执行编译:nmake

nmake

4、编译成功后如下(本人未出现异常的情况):将nginx.exe拷贝到上层目录(源码路径下)或者重新下载一个nginx.zip覆盖其中的nginx.exe并配置nginx.conf就可以使用了

在这里插入图片描述

五、测试推流

1、安装FFmpeg配置环境变量

2、简单配置一下nginx.config
在这里插入图片描述

在这里插入图片描述

3、启动nginx并打开CMD执行FFmpeg推流命令

ffmpeg -i mv.mp4 -vcodec libx264 -acodec aac -f flv "rtmp://127.0.0.1:1935/live/100"

4、VLC进行测试(HTTP-FLV、RTMP均可用)

HTTP-FLV: http://127.0.0.1:80/live?app=live&port=1935&stream=100
RTMP: rtmp://127.0.0.1:1935/live/100
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值