Linux(Centos7)上搭建直播流服务器(Nginx+RTMP协议)

10 篇文章 0 订阅
这篇教程详细介绍了如何搭建Nginx服务器并安装nginx-rtmp-module模块,实现RTMP直播流服务。完成安装后,通过OBSstudio推流和Potplayer拉流进行验证。提供了相关软件的下载链接,以及Nginx的配置示例,包括RTMP和HLS直播流设置。此外,还给出了OBS推流和Potplayer播放时的配置注意事项。
摘要由CSDN通过智能技术生成

这是一篇入门基础教程,还有其他的SRS搭建,RTSP协议,他们的区别和搭建方式,感兴趣或者从事这方面工作的,就自己去研究了。

1:安装Nginx

教程:https://blog.csdn.net/Brave_heart4pzj/article/details/108556564

2:安装nginx-rtmp-module模块

参考: https://blog.csdn.net/O0mm0O/article/details/73896384 (1)
https://blog.tomhuang2000.com/archives/572/ (2)
教程(1)比较好,可能发生的错误都给补充上了
以上两步操作完成后,就可以使用这个直播流服务器了

3、使用方法

工具:OBS studio录屏推流、potplayer拉流播放器
视频教程:
Nginx+RTMP 服务器搭建教程:https://www.bilibili.com/video/av78957794
OBS录屏推流教程:https://www.bilibili.com/video/av78808759

补充注意点:

1、OBS推流时候:下面三个地方的配置要对应好,串流秘钥随意,但是它觉定你后面的访问路径
在这里插入图片描述
在这里插入图片描述2、potplayer使用时填写的播放地址
这里的yuchen111就是OBS里面配置的串流秘钥名称对应上
在这里插入图片描述
3、搭建过程中,所需相关软件下载地址
链接:https://pan.baidu.com/s/1v8E3BB-Ibtn4srLa1BQuwA
提取码:u5l8

补充:
可用Nginx配置:

#user  nobody;
worker_processes  1;

error_log  logs/error.log;
error_log  logs/error.log  notice;
error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

rtmp {

    server {

        listen 1935;

        chunk_size 4000;

        # TV mode: one publisher, many subscribers
        application mylive {

            # enable live streaming
            live on;

            # record first 200M of stream
            record all;
            record_path /opt/rtmp/live_record;
            record_max_size 200M;

            hls on;
            hls_path /opt/rtmp/hls;
            hls_fragment 1s;
            hls_playlist_length 500;

            allow play all;

            #on_publish 'http://when start publish live call this url';
            #on_done 'http://when live stop call this url';
        }
    }
}

http {
    server {
        listen       8080;

        # This URL provides RTMP statistics in XML
        location /stat {
            rtmp_stat all;

            # Use this stylesheet to view XML as web page
            # in browser
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            # XML stylesheet to view RTMP stats.
            # Copy stat.xsl wherever you want
            # and put the full directory path here
            root /usr/local/nginx/html/;
        }

        location /hls {
            # Serve HLS fragments
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            root /opt/rtmp;
            add_header Cache-Control no-cache;
        }
   }

}

你学废了吗?

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值