You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
SoftwareEngineering/StreamMedia/流媒体测试服务器搭建.md

63 lines
2.9 KiB

# Nginx 搭建rtmp流媒体服务器
## 1.源码下载(所有代码放一个路径)
### Nginx-1.17.6:https://nginx.org/en/download.html
### nginx-client-module:https://github.com/AlexWoo/nginx-client-module.git
### nginx-multiport-module:https://github.com/AlexWoo/nginx-multiport-module.git
### nginx-toolkit-module:https://github.com/AlexWoo/nginx-toolkit-module.git
### nginx-multiport-module:https://github.com/AlexWoo/nginx-multiport-module.git
## 2.解压Nginx
tar -zxvf nginx-1.17.6.tar.gz
## 3.配置
进入nginx-1.17.6路径,执行下面命令:
./configure --prefix=/home/kelinlang/workspace/install/nginx_rtmp/nginx-1.17.6 --add-module=../nginx-client-module --add-module=../nginx-multiport-module --add-module=../nginx-toolkit-module --add-module=../nginx-rtmp-module --with-http_ssl_module --with-cc-opt="-Wno-error"
备注:--prefix用于设置安装目录,根据实际情况设置路径
## 4.编译安装
make && make install
## 5.修改配置文件
配置文件路径:/home/kelinlang/workspace/install/nginx_rtmp/nginx-1.17.6/conf/nginx.conf
## 6.启动服务
进入安装目录sbin文件夹,执行nginx
备注:启动服务后出现报端口号错误需要修改配置文件或者杀占用端口号的进程
# ZLMeideaKit搭建rtsp服务器(开源库本身支持H265视频流)
## 1.源码下载
git clone https://github.com/xiongziliang/ZLMediaKit.git
## 2.更新依赖库
cd ZLMediaKit
git submodule update --init
## 3.编译
cd ZLMediaKit
./build_for_linux.sh
## 4.运行服务器
进入路径:/release/linux/Debug
执行:./MediaServer
备注:启动服务后会自动生成配置文件config.ini,如果运行服务打印log提示断开被占用需要修改对应端口号
# FFmpeg编译
## 配置
./configure --enable-ffplay --enable-gpl --enable-libx264 --enable-libx265 --enable-static --enable-shared --enable-debug --disable-yasm --prefix=/home/kelinlang/workspace/install/ffmpeg3.3.6
# 推拉流命令
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f flv rtmp://192.168.2.162:1935/live/test
./ffmpeg -re -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f rtsp rtsp://192.168.2.162:5555/live/test
./ffmpeg -i rtsp://192.168.2.162:5555/live/test -c copy -f flv rtmp://192.168.2.162:1935/hls/test
# ts切片
./ffmpeg -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -bsf:v hevc_mp4toannexb /home/kelinlang/workspace/testFiles/E1h265.ts
./ffmpeg -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c:v libx265 -c:a aac -strict -2 -f hls -hls_list_size 0 -hls_time 5 /home/kelinlang/workspace/testFiles/E1h265_hls_test_.m3u8
./ffmpeg -i /home/kelinlang/workspace/testFiles/E1h265.mp4 -c copy -f hls -hls_list_size 0 -hls_time 5 /home/kelinlang/workspace/testFiles/E1h265_hls_test_.m3u8