Nginx RTMP 模块安装与使用教程
nginx-rtmp-module 项目地址: https://gitcode.com/gh_mirrors/ngin/nginx-rtmp-module
1. 项目目录结构及介绍
nginx-rtmp-module/
├── conf/
│ ├── nginx.conf
│ └── rtmp.conf
├── src/
│ ├── core/
│ ├── http/
│ ├── mail/
│ ├── misc/
│ ├── os/
│ ├── stream/
│ └── rtmp/
├── test/
│ ├── rtmp/
│ └── http/
├── README.md
├── LICENSE
└── INSTALL
目录结构介绍
- conf/: 存放项目的配置文件,包括
nginx.conf
和rtmp.conf
。 - src/: 项目的源代码目录,包含核心模块、HTTP模块、邮件模块、杂项模块、操作系统相关模块、流媒体模块以及RTMP模块。
- test/: 测试文件目录,包含RTMP和HTTP的测试文件。
- README.md: 项目的基本介绍和使用说明。
- LICENSE: 项目的开源许可证文件。
- INSTALL: 项目的安装说明文件。
2. 项目启动文件介绍
项目的启动文件主要是 nginx.conf
,该文件位于 conf/
目录下。nginx.conf
是 Nginx 的主配置文件,包含了 HTTP 和 RTMP 服务的配置。
nginx.conf 文件结构
# 全局配置
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
# 事件配置
events {
worker_connections 1024;
}
# HTTP 配置
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
# RTMP 配置
rtmp {
server {
listen 1935;
application live {
live on;
record off;
}
}
}
启动命令
nginx -c /path/to/nginx.conf
3. 项目配置文件介绍
rtmp.conf 文件结构
rtmp {
server {
listen 1935;
application live {
live on;
record off;
}
application vod {
play /var/vod;
}
}
}
配置文件介绍
- rtmp: RTMP 模块的顶级配置块。
- server: 定义一个 RTMP 服务器实例。
- listen: 指定 RTMP 服务器的监听端口,通常为 1935。
- application: 定义一个 RTMP 应用,例如
live
和vod
。- live on: 启用直播功能。
- record off: 关闭录制功能。
- play /var/vod: 指定视频点播的文件路径。
通过以上配置,可以实现 RTMP 直播和点播功能。
以上是 Nginx RTMP 模块的安装与使用教程,涵盖了项目的目录结构、启动文件和配置文件的详细介绍。希望对你有所帮助!
nginx-rtmp-module 项目地址: https://gitcode.com/gh_mirrors/ngin/nginx-rtmp-module