@byxiaoxie3 年前

04/19
20:23
Home

搭建SRS服务器RTC串流

测试搭建环境 系统 [Ubuntu 20.04]
SRS项目地址:https://github.com/ossrs/srs
安装需要用到的软件包

apt-get install make
apt-get install gcc
apt-get install libssl-dev
apt-get install golang
apt-get install git
apt-get install python
下载SRS项目

git clone https://github.com/ossrs/srs.git
切换4.0版本 [默认版本为3.0,没有RTC所以需要4.0版本]

cd srs/
git checkout 4.0release  //切换最新版本
git branch -v  //查看当前版本
编译SRS

cd trunk/

./configure --with-hls --with-ssl --with-http-server --with-http-callback --with-http-api --with-ingest --with-stream-caster

make
编译完成后修改配置文件

vim conf/rtc.conf

找到[bframe discard]删除他 (原因我也不清楚这个会导致播放卡住)

修改后:
rtc {
    enabled     on;
}

保存配置文件

配置文件部分说明:

listen          1935;   //串流端口
listen          8080;   //HTTP端口
listen          1985;   //API端口(一般不修改)
listen          8000;   //UDP端口(一般不修改)

http_remux {
    enabled     on;
    mount       [vhost]/[app]/[stream].flv;
    hstrs      on;  //添加这个可拉流flv
}
启动RTC

./objs/srs -c conf/rtc.conf
OBS推流设置

服务器:rtmp://127.0.0.1/live/
串流秘钥:myname
播放地址:

webrtc          webrtc://127.0.0.1/live/myname         (端口1985可以不用填写因为webrtc默认端口是1985)
rtmp            rtmp://127.0.0.1:1935/live/myname      (端口1935可以不用填写因为RTMP默认端口是1935除非修改了)
http/flv	http://127.0.0.1:8080/live/myname.flv  (端口8080是HTTP端口如果修改过输入对应的端口即可)
http/m3u8	http://127.0.0.1:8080/live/myname.m3u8 (端口8080是HTTP端口如果修改过输入对应的端口即可)

SRS测试地址:http://127.0.0.1:8080/players/rtc_player.html
如果外网无法播放RTC打开rtc.conf配置文件修改

candidate       $CANDIDATE;  //搜索找到这个

外网无法播放把 [$CANDIDATE] 修改成你的外网IP 

例子: candidate       101.28.1.1;

或者尝试访问 webrtc://127.0.0.1/live/myname?eip=101.28.1.1

启动后可以看到端口信息:

QQ截图20210419200408 搭建SRS服务器RTC串流

WebRTC测试效果(延迟1秒以下,测试图非局域网情况下测试的,网络不好的情况下1~3秒):

QQ截图20210419200408 搭建SRS服务器RTC串流

搭建SRS服务器RTC串流

@byxiaoxie3 年前

11/3
17:56
Home

owncast 搭建自己的直播间(带聊天功能)

// 准备工作
系统 [Ubuntu 20.04] (其他系统自行测试)
GitHub:https://github.com/owncast/owncast
教程地址:https://owncast.online/docs/quickstart/
需要:FFmpeg版本4.2以上的版本 必须要支持:[x264/var_stream_map] 手动编译安装教程:https://www.byxiaoxie.com/?p=525
//安装 FFmpeg (Ubuntu20.04 ffmpeg版本4.2.4)

apt update

apt install ffmpeg
//下载[owncast] (GitHub上的发布版)

mkdir -p /opt/owncast && cd /opt/owncast  //创建文件夹并进入文件夹

wget https://github.com/owncast/owncast/releases/download/v0.0.2/owncast-0.0.2-linux-64bit.zip  //下载发布版

unzip owncast-0.0.2-linux-64bit.zip  // 解压
//编辑配置文件[config.yaml]

vim config.yaml

修改自己的串流秘钥和信息,我自己的文件内容如下:
# See https://owncast.online/docs/configuration/ for more details

instanceDetails:
  name: Gary   //名称
  title: Live Game Test  //网站标题

  logo:
    small: /img/logo128.png
    large: /img/logo256.png

  tags:
    - music
    - software
    - streaming

  # https://owncast.online/docs/configuration/#external-links
  # for full list of supported social links.  All optional.
  socialHandles:
    - platform: github
      url: http://github.com/owncast/owncast
    - platform: mastodon
      url: http://mastodon.something/owncast

videoSettings:
  # Change this value and keep it secure.  Treat it like a password to your live stream.
  streamingKey: xiaoxie   //串流秘钥
//启动 [owncast]

./owncast  //启动指令

启动后查看日志文件 [transcoder.log] 如果没有报错着运行成功,如报错无法正常串流播放

//使用后台运行  [owncast]

screen -S live  //创建新的命令行

cd cd /opt/owncast  //进入目录

./owncast  //执行脚本
服务器需要开放端口[1935,8080]
设置OBS串流

服务器 [rtmp://127.0.0.1/live]
串流秘钥 [xiaoxie] (名称自行修改)

播放器地址

播放地址 [http://127.0.0.1:8080]

阅读全文 →

owncast 搭建自己的直播间(带聊天功能)

@byxiaoxie4 年前

09/28
22:14
Home

Free HLS Live 服务器搭建

Free HLS Live 服务器搭建  测试环境 系统[CentOS 7]
Free HLS Live 需求的软件:
NodeJS
Yarn
FFmpeg
NodeJS 安装 官方网站[https://nodejs.org/en/download/]

下载 NodeJS
wget https://nodejs.org/dist/v12.18.4/node-v12.18.4-linux-x64.tar.xz

解压 NodeJS

xz -d node-v12.18.4-linux-x64.tar.xz
tar -xf node-v12.18.4-linux-x64.tar

设置软连接
ln -s ~/node-v12.18.4-linux-x64/bin/node /usr/bin/node
ln -s ~/node-v12.18.4-linux-x64/bin/npm /usr/bin/npm
ln -s ~/node-v12.18.4-linux-x64/bin/npm /usr/bin/npx

测试是否添加成功
node -v  返回值[v12.18.4]

阅读全文 →

Free HLS Live 服务器搭建

加载中……