网站首页 > 技术教程 正文
流媒体服务功能说明:
nginx实现rtmp服务端,可以接受推流,然后将流分发出去。
一般接受rtsp推流,可输出rtmp或flv等多种格式。 在安防领域典型的应用场景:
将摄像机的rtsp推流到流媒体服务器,网页端可使用flash或无插件观看视频。
下载nginx-rtmp-module
git clone https://github.com/arut/nginx-rtmp-module.git
下载安装nginx
wget http://nginx.org/download/nginx-1.8.1.tar.gz
tar -zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure --prefix=/usr/local/nginx --add-module=../nginx-rtmp-module --with-http_ssl_module
make && make install
设置nginx
vi /usr/local/nginx/conf/nginx.conf
内容:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 809;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
rtmp {
out_queue 4096;
out_cork 8;
max_streams 4096;
server {
listen 90;
drop_idle_publisher 30s;
application live {
live on;
}
}
}
启动:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
卸载
# 如果有自启动,则删除 Nginx 的自启动
chkconfig nginx off
服务 nginx 信息读取出错:没有那个文件或目录
# 查找nginx的安装目录
whereis nginx
nginx: /usr/local/nginx
# 停止nginx服务
/usr/local/nginx/sbin/nginx -s stop
# 删除安装目录
rm -rf /usr/local/nginx/
# 查找是否还有残余的
find / -name nginx
/usr/local/lib64/nginx-1.15.7/objs/nginx
rm -rf /usr/local/lib64/nginx-1.15.7/
使用ffmpeg推流测试:
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i "视频资源源地址" -c:v h264_nvenc -an -crf 20 -b:a 96k -b:v 2048k -preset medium -tune animation -vf scale_npp=1024:-1 -f flv rtmp://ip:90/live/test
拉流测试
使用:
rtmp://ip:90/live/test
地址播放即可。
Flv配置
https://github.com/winshining/nginx-http-flv-module
nginx flv是基于nginx-rtmp-module的流媒体服务器
功能对比:
安装
yum install https://extras.getpagespeed.com/release-el$(rpm -E %{rhel})-latest.rpm
yum install nginx-module-flv
1. 通过nginx.conf引用
安装完毕后,HTTP-FLV功能的配置文件http-flv.conf和RTMP功能的配置文件rtmp.conf会被放在/etc/nginx/http-flv目录下,通过include手工将它们添加到/etc/nginx/nginx.conf,以开启HTTP-FLV和RTMP功能:
http {
...
include /etc/nginx/http-flv/http-flv.conf;
}
include /etc/nginx/http-flv/rtmp.conf;
添加以下配置到/etc/nginx/nginx.conf,启动或者重启NGINX来启用本模块:
load_module modules/ngx_http_flv_live_module.so;
注意
上述的配置必须位于events配置项之前,否则NGINX不能启动。
更新可以通过yum update来完成。关于其他NGINX模块的详情见GetPageSpeed。
对于其他操作系统,见下面源码编译安装的说明。
2. 源码编译安装
cd root
git clone https://github.com/winshining/nginx-http-flv-module
wget http://nginx.org/download/nginx-1.8.1.tar.gz
tar -zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure --add-module=/root/nginx-http-flv-module --with-http_ssl_module
make && make install
猜你喜欢
- 2024-10-14 Jenkins+Gitlab+Nginx+SonarQube+Maven编译Java项目自发布与回退
- 2024-10-14 三句话测试你是否懂git(用几句话测试对方喜不喜欢你)
- 2024-10-14 Nginx部署前端代码实现前后端分离
- 2024-10-14 Nginx 反向代理及负载均衡实践(nginx反向代理与负载均衡)
- 2024-10-14 JAVA 项目如何进行 git 多人协作开发
- 2024-10-03 让Jenkins自动部署你的Vue项目「实践」
- 2024-10-03 Nginx + uWSGI 部署Django站点(nginx和uwsgi部署flask项目)
- 2024-10-03 纯 Git 实现前端 CI/CD(git js)
- 2024-10-03 搭建Nginx+rtmp+hls直播推流服务器
你 发表评论:
欢迎- 最近发表
-
- 阿里P8大佬总结的Nacos入门笔记,从安装到进阶小白也能轻松学会
- Linux环境下,Jmeter压力测试的搭建及报错解决方法
- Java 在Word中合并单元格时删除重复值
- 解压缩软件哪个好用?4款大多数人常用的软件~
- Hadoop高可用集群搭建及API调用(hadoop3高可用)
- lombok注解@Data没有toString和getter、setter问题
- Apache Felix介绍(apache fineract)
- Spring Boot官方推荐的Docker镜像编译方式-分层jar包
- Gradle 使用手册(gradle详细教程)
- 字节二面:为什么SpringBoot的 jar可以直接运行?
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)