直播服务器搭建
Nginx 安装流媒体
yum install gcc-c++ -y
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
wget https://nginx.org/download/nginx-1.22.1.tar.gz
tar -zxvf nginx-1.22.1.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
unzip master.zip
Master.zip和 nginx-1.22.1.tar.gz同一个目录里面
cd nginx-1.22.1
./configure --prefix=/usr/local/nginx --add-module=../nginx-rtmp-module-master
make
make install
cp stat.xsl /usr/local/nginx/html/
vim /usr/local/nginx/conf/nginx.conf
Server里面添加
location /stat{
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl{
root html;
}
最后添加
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
publish_notify on;
on_publish http://127.0.0.1:8080/sys/auth;
record off;
}
}
}
cd /usr/local/nginx/sbin
./nginx
鉴权接口
http://127.0.0.1:8080/sys/auth?passWord=123456
Java代码
@RequestMapping("/sys/auth")
public String auth(HttpServletRequest request, HttpServletResponse response, String passWord) {
try {
if (passWord.equals("123456")){
return "success";
}else{
response.setHeader("liveAuth","authCode error");
response.setStatus(500);
}
} catch (Exception e) {
response.setHeader("error","sys error");
response.setStatus(500);
}
return "success";
}
录屏推流测试:
ffmpeg -f gdigrab -i desktop -r 15 -rtsp_transport tcp -vcodec h264 -f flv rtmp://101.34.82.141/live/1668?passWord=123456
播放测试(vlc):
rtmp://101.34.82.141/live/1668
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY