直播服务器搭建

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.zipnginx-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

原文链接: https://www.cnblogs.com/wangchaozhi/p/17050391.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    直播服务器搭建

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/311788

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月16日 下午12:08
下一篇 2023年2月16日 下午12:09

相关推荐