github 地址:https://github.com/arut/nginx-rtmp-module 本站下载: nginx-rtmp直播源码点我下载 我下载的是nginx-rtmp-module1.2.2
一、整体设计架构nginx-rtmp-module 是 Nginx 的一个扩展模块,专门为 Nginx 添加了对 RTMP 协议的支持。 nginx-rtmp-module 正是以这种思路开发的: 复用Nginx的网络和事件处理机制,管理连接(Connection)和事件(Event)。 三、nginx-rtmp-module 核心代码结构与逻辑说明该项目的核心源码位于以下几个关键目录和文件:1. 事件驱动 (ngx_event_t): nginx-rtmp-module使用Nginx的事件驱动架构,事件分为读、写、超时事件。 通过以上说明,相信你能够更快地熟悉和理解nginx-rtmp-module源码及其背后的Nginx核心思想,帮助你进一步提高代码阅读效率并更快上手实践。
nginx-rtmp-module搭建流媒体服务器实现直播介绍在现代互联网时代,直播已经成为一种非常受欢迎的媒体传播形式。 为了实现高质量的直播流媒体传输,我们可以使用nginx-rtmp-module来搭建一个流媒体服务器。 在本篇文章中,我们将介绍如何使用nginx-rtmp-module来搭建一个简单的流媒体服务器,并实现直播功能。步骤1. 安装nginx和nginx-rtmp-module首先,我们需要安装nginx和nginx-rtmp-module。 结论通过nginx-rtmp-module,我们搭建了一个流媒体服务器,并实现了推流和播放的功能。
下载地址:https://github.com/johnf/m3u8-segmenter.git
— 上下文配置段: main 说明:版本必须>=1.9.11 实例:load_module modules/ngx_mail_module.so; 编译动态模块 这里安装基于Nginx的流媒体服务器:nginx-rtmp-module 模块 项目地址:https://github.com/arut/nginx-rtmp-module 下载 OpenResty OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web git clone https://github.com/arut/nginx-rtmp-module.git 下载模块路径地址为:/home/www/build/nginx-rtmp-module with-stream \ --with-stream_ssl_preread_module \ --with-compat --add-dynamic-module=/home/www/build/nginx-rtmp-module /configure [“你的nignx -V 得到的配置参数”] --add-dynamic-module=/home/www/build/nginx-rtmp-module 注意事项: 动态模块只能在
一、准备Nginx和nginx-rtmp-module的源码Nginx的官网地址是https://nginx.org/,下载页面为https://nginx.org/en/download.html,最新版本为 nginx-rtmp-module的源码托管地址是https://github.com/arut/nginx-rtmp-module,各版本的下载页面为https://github.com/arut/nginx-rtmp-module /tags,最新版本为2024年4月发布的nginx-rtmp-module-1.2.2,该版本的源码包下载链接为https://github.com/arut/nginx-rtmp-module/archive 二、编译与安装Nginx(包含集成rtmp模块)登录Linux服务器,依次执行下列的解压命令,分别解压nginx-rtmp-module、nginx等等的源码包。
openssl 下载地址:https://github.com/openssl/openssl/archive/OpenSSL_1_1_0f.tar.gz 3.rtmp -- 推流使用的协议,好在有现成的模块:nginx-rtmp-module 下载地址:https://github.com/arut/nginx-rtmp-module/archive/v1.2.0.tar.gz 下载完毕后分别解压 [1240] 二.先编译openssl,进入 /test/下的nginx.conf 复制到 nginx/bin/conf下面 [1240] 该配置文件可以修改最大连接数和nginx的端口号,我们还需要将配置文件中的nginx-rtmp-module } location /rtmp-publisher { # 改成本地的路径 # root /path/to/nginx-rtmp-module test; } location / { # 改成本地的路径 # root /path/to/nginx-rtmp-module
SRS采用多线程方式,性能优秀,经受住了众多场景的考验,但是SRS3已经闭源(更正:是有一段时间闭源了,现在又开源了);nginx-rtmp-module是采用多进程方式,Nginx的性能优秀,但是据网友测试 ,nginx-rtmp-module的性能不如SRS,并且nginx-rtmp-module的作者已经很久没有更新版本了,支持的功能也有限,例如不支持HTTP方式的FLV直播,而这是国内直播行业普遍采用的方式 我在nginx-rtmp-module的基础上实现了基于HTTP方式的FLV直播功能,支持GOP缓存,减少播放响应延迟时间;支持流式和Transfer-Encoding: chunked两种HTTP响应格式 ;修复nginx-rtmp-module没有listen配置项时,推流失败的问题;解决nginx-rtmp-module已知的bug,见nginx-http-flv-module,欢迎下载测试和修复bug 其他的见nginx-rtmp-module的wiki(https://github.com/arut/nginx-rtmp-module/wiki/Directives)说明。
添加模块--add-module=/www/server/nginx_plus/nginx-rtmp-module 下载nginx-rtmp 接下来,下载nginx-rtmp模块到宝塔的模块目录。 git clone https://github.com/arut/nginx-rtmp-module /www/server/nginx_plus/nginx-rtmp-module/ 重新安装nginx rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /root/nginx-rtmp-module
下载 nginx rtmp 服务器应用 : arut/nginx-rtmp-module , 不要直接下载测试或者不稳定版本 , 下载其发布版本 , 点击 Releases 查看 发布版本 , 这里选择 编译环境准备 : 下载完毕后 , 在 Ubuntu 的 root 用户目录下 , 创建 rtmp 目录 , 将两个包拷贝到 rtmp 目录中 , nginx 服务器与 nginx-rtmp-module 解压源码 : ① 解压 nginx 源码 : tar xvf nginx-1.15.3.tar.gz ; ② 解压 nginx-rtmp-module 源码 : tar xvf nginx-rtmp-module /test; } location / { root /path/to/nginx-rtmp-module/test/www; HTTP 模块配置 : 需要修改 3 个位置 , /path/to/nginx-rtmp-module/ 替换为真实的 nginx-rtmp-module 目录 , 即 /root/rtmp/nginx-rtmp-module
安装RTMP 服务器 自己动手搭建一个rtmp, 本文在 Linux环境中搭建 去git上clone 一个下来https://github.com/arut/nginx-rtmp-module 解压后安装即可 /nginx-rtmp-module/test下配置文件nginx.conf, GitHub上就是这个结构, 我们这里不做改动. ? 作用是指定端口号和文件目录 ? 作用是使浏览器可以访问,便于我们调试视频 以上配置基本可以访问了, 如有其它需求可以参见详细配置: https://github.com/sergey-dryabzhinsky/nginx-rtmp-module /blob/dev/test/nginx.conf 配置完成后检查是否正确: [nginx-rtmp-module]# nginx -t nginx: the configuration file /etc
下面以rtmp模块为例 https://github.com/arut/nginx-rtmp-module 普通方式 静态模块 . /configure --add-module=/path/to/nginx-rtmp-module make //make编译,编译好的程序在objs文件夹下面,这时候不要执行make install /configure --add-dynamic-module=/path/to/nginx-rtmp-module make make install 加载 vi /etc/nginx/nginx.conf
nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm yum -y install ffmpeg 2) nginx-rtmp安装和配置 nginx默认不带nginx-rtmp-module 安装必须的组件 yum -y install openssl openssl-devel 下载nginx-rtmp-module源码 git clone https://github.com/arut/ /nginx-rtmp-module --with-http_ssl_module make make install 4.对接测试配置 1)开通腾讯云直播 开通服务 进入控制台,选择接入码接入方式 ** 5.参考 ffmpeg安装:https://rpmfusion.org/Configuration nginx安装:http://www.nginx.cn/install nginx-rtmp-module 配置:https://github.com/arut/nginx-rtmp-module 腾讯云直播:https://cloud.tencent.com/document/product/267
4.png 使用nginx配置rtmp服务器 下载安装nginx和nginx-rtmp-module nginx 直接到官网下载 nginx-rtmp-module 在github上下载 ? /configure --add-module=/root/nginx-rtmp-module make make install 编译安装完后nginx目录在/usr/local/nginx下 而nginx rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /usr/local/nginx/nginx-rtmp-module
下载 nginx-rtmp-module模块 源码包(RTMP模块源码包)并解压 wget https://github.com/arut/nginx-rtmp-module/archive/master.zip live on; } } } 注意:①直接配置文件增加 与http协议同级 ②修改前先将原文件.bak备份 至此,nginx 及nginx-rtmp-module
/configure --add-module=/nginx/nginx-rtmp-module make make install cd /usr/local/nginx/sbin/ . all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /nginx/nginx-rtmp-module all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /nginx/nginx-rtmp-module
本次分享的组件是流媒体服务器组件nginx-http-flv-module 这款组件主要是在Nginx中使用,使其Nginx可以具备接收rtmp流转换为http地址,提供给前端flv.js一类插件调用使用,其内部采用了nginx-rtmp-module 官方对比如下: 功能 nginx-http-flv-module nginx-rtmp-module 备注 HTTP-FLV (播放) √ x 支持 HTTPS-FLV 和 chunked 回复 GOP
内容 第一部份:Nginx的安装、配置和使用 [1-1]nginx-rtmp-module模块 为了增加对rtmp的支持,下载nginx-rtmp-module解压到/root/download /nginx-rtmp-module 配置和编译nginx的时候要用到。 /configure –prefix=/usr/local/nginx –add-module=/root/download/nginx-rtmp-module –with-http_ssl_module
/configure --prefix=/usr/local/zlib-1.2.11 make make 5.下载nginx-rtmp-module nginx-rtmp-module的官方github 地址:https://github.com/arut/nginx-rtmp-module 使用命令: git clone https://github.com/arut/nginx-rtmp-module.git with-pcre=/usr/local/src/pcre-8.43 --with-zlib=/usr/local/src/zlib-1.2.11 --add-module=/usr/local/src/nginx-rtmp-module
准备工作 购买腾讯轻量服务器: https://curl.qcloud.com/I8Z5glUD 如果您已经安装好 Nginx 和 nginx-rtmp-module 可以跳过此部分 使用包管理安装的 参考文章 Debian / Ubuntu 环境下 LEMP 建站解析 arut/nginx-rtmp-module illuspas/nginx-rtmp-win32 借助 Nginx 搭建带简单认证的直播推流服务器 ,实现多平台同步直播 Nginx学习之配置RTMP模块搭建推流服务 直播推流nginx-rtmp-module集成(