ffmpeg+nginx 实现rtsp转rtmp并通过nginx转发
2024-08-29 20:50:52
Windows安装
ffmpeg
ffmpeg
- windows版下载地址https://ffmpeg.zeranoe.com/builds/ static版本就行
- 配置环境变量:下载的压缩包解压后的路径加入path
- 测试运行:cmd 输入ffmpeg -version 显示如下:
- 安装完毕。
- Rtsp转Rtmp 并推送到Nginx命令:
ffmpeg -rtsp_transport tcp -i "rtsp://root:pass@10.1.30.11/axis-media/media.amp" -vcodec copy -acodec copy -f flv "rtmp://127.0.0.1:1935/live/"
Nginx
nginx rtmp module下载地址https://github.com/illuspas/nginx-rtmp-win32
配置rtmp代理:conf/nginx.conf 确保有以下内容
rtmp {
server {
listen ;
application live {
live on;
}
application hls {
live on;
hls on;
hls_path temp/hls;
hls_fragment 8s;
}
}
}
点击nginx.exe运行或者cmd窗口中输入nginx.exe
测试是否运行:访问http://127.0.0.1:8080/index.html
测试搭建是否成功
Cmd 窗口执行: ffmpeg -rtsp_transport tcp -i “rtsp://root:pass@10.1.30.11/axis-media/media.amp” -vcodec copy -acodec copy -f flv “rtmp://127.0.0.1:1935/live/”
使用vlc播放器播放rtmp://127.0.0.1:1935/live/ 是否成功
Linux 安装
Nginx
软件包nginx-1.15..tar.gz,nginx-rtmp-module-master.tar
依赖库openssl-1.0.2l.tar.gz; pcre-8.42.tar.gz; zlib-1.2..tar.gz;
安装openssl
解压openssl-1.0.2l.tar.gz
进入文件夹 ./config
make && make install
安装zlib
解压tar xf zlib-1.2..tar.gz
./configure
make && make install
安装 nginx
解压nginx-1.15..tar.gz; nginx-rtmp-module-master.tar
cd nginx-1.15.
./configure --prefix=/usr/local/nginx --add-module=../nginx-rtmp-module-master --with-http_ssl_module --with-pcre=../pcre-8.42 --with-openssl=../openssl-1.0.2l --with-zlib=../zlib-1.2.
安装: make &&make install
cd /usr/local/nginx/
vi ./conf/nginx.conf
添加以下内容
rtmp {
server {
listen ;
chunk_size ;
application live{
live on;
}
application hls {
live on;
hls on;
hls_path html/hls;
hls_fragment 3s;
}
}
}
修改http server端口为8001 修改servername 为本机ip,保存退出 开放1935端口和8001端口 firewall-cmd --zone=public --add-port=/tcp –permanent firewall-cmd --reload 启动 ./sbin/nginx -c ./conf/nginx.conf 查看是否启动成功:ps aux|grep nginx
ffmpeg
安装编译环境(root权限):yasm yasm-1.3..tar.gz
cd yasm-1.3./
./configure
make && make install
安装 ffmpeg tar -xvf ffmpeg-4.0..tar.gz
./configure
make && make isntall
修改文件/etc/ld.so.conf 内容增加第二行/usr/local/ffmpeg/lib/
增加环境变量ffmpeg:输入 export PATH=/usr/local/ffmpeg/bin/:$PATH
测试执行 ffmpeg -version 无报错则安装完成
推流测试
最新文章
- linux mint17.2 安装fcitx输入法
- node.js 基础学习笔记3 -express
- js代码学习
- Linux / UNIX create soft link with ln command
- sql去除某个字段中的某个字符串 replace
- windows系统mysql定时自动备份
- Bootstrap--下拉菜单.dropdown
- datatable使用笔记
- jmeter学习笔记--概述
- 利用os.system 截取终端日志输出 存为txt
- centos7根分区扩容(亲测有效)
- ubuntu彻底卸载软件
- Numpy三维数组的转置与交换轴
- CoreException: Could not get the value for parameter compilerId for plugin execution default-compile Maven项目pom文件报错,插件引用不到
- 搭建GlusterFS文件系统
- 缓存数据库-redis数据类型和操作(sorted set)
- C# 单元测试几个方法的用法
- Xpath,XQuery,DTD
- CentOS6.2 下安装OpenGL开发库
- HDU1164
热门文章
- 使用WireMock进行更好的集成测试
- tabBarItem是模型,只有控件才有textColor属性
- 【Python成长之路】python 基础篇 -- 装饰器【华为云分享】
- angularJS使用ocLazyLoad实现js延迟加载
- 浏览器/外网访问docker container中的hadoop
- k8s 开船记-首航:博客站点从 docker swarm 切换到 k8s
- UIView的作用
- E1.Send Boxes to Alice(Easy Version)//中位数
- python读取,显示,保存mnist图片
- 【MobX】390- MobX 入门教程(上)