IBM Cloud CDN - 流媒体加速(拉流场景)实战

目前IBM Cloud CDN 直播功能仅支持拉流场景,包括HLS和DASH两种协议。
关于CDN入门和具体功能可以参考在线文档,
https://cloud.ibm.com/docs/CDN?topic=CDN-getting-started

测试准备:
如果用户自带源站,只需准备以下origin服务器信息,可直接在IBM Cloud测试账户直接进行CDN配置,包括:

  • 源站IP地址或者 Hostname
  • 确认源站域名能被公网解析
  • 访问URL具体路径,默认为站点根目录,i.e.: http://myorigin.danwcloud.com/hls
  • 站点是否 HTTP SSL(https)加密,检查站点证书 -
    https://www.sslshopper.com/ssl-checker.html

环境搭建:
这里会部署三个IBM Cloud 云主机和一个CDN服务,来实现一个直播流媒体拉流场景的端到端环境。 为了测试方便,我们将使用nginx(web)和nginx-rtmp-module在一台东京的虚拟机上(8c16g)搭建HLS流媒体服务器,OBS模拟主播端从韩国做RTMP直推(IBM Cloud CDN目前无法支持推流), 香港虚拟机作为客户端连接CDN的拉流边缘,查看播放和下载效果。

域名示例:
A. web站点域名 -> demopull.danwcloud.com
B. origin源站域名和IP -> myorigin.danwcloud.com / x.x.x.x
C. nginx-rtmp流媒体服务 -> myorigin.danwcloud.com / x.x.x.x
在这里插入图片描述

基本步骤:

  1. OBS直播推流配置 (windows VSI - 首尔)
  2. 流媒体和源站搭建 (CentOS VSI - 东京)
  3. IBM Cloud CDN服务创建和配置 (IBM Cloud Portal)
  4. 客户端拉流设置(Ubuntu VSI - 香港 )

1. OBS直播推流设置
OBS主播端到流媒体服务器将采用RTMP协议进行直推,不经过CDN。但一般生产环境下直播内容在传送到指定推流区域之前,还是会经过CDN边缘节点并进行相应转码处理,目前IBM Cloud尚无法支持这段路径

OBS下载和安装 - https://obsproject.com/download
Settings > Stream(指定RTMP远端服务)
Server: rtmp://nginx-rtmp-server-IP:1935/live
Stream Key: “stream”
在这里插入图片描述Settings > Output: 选择高级参数,配置输出流
在这里插入图片描述
2. 流媒体服务和源站搭建
FFmpeg
FFmpeg可以用来记录、转换数字音频、视频,并能将其转化为流的开源程序(软编码),它包括了目前领先的音/视频编码库libavcodec。

[root@myorigin ~]# yum install epel-release
[root@myorigin ~]# yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
[root@myorigin ~]# yum install ffmpeg ffmpeg-devel
[root@myorigin ~]# ffmpeg -version
ffmpeg version 3.4.7 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)

nginx-rtmp
因为需要LuaJIT支持动态标头和 CDN 预加载功能,所以nginx的安装我们选择OpenResty版本而不是编译安装.

It is highly recommended to use OpenResty releases which bundle Nginx, ngx_lua (this module), LuaJIT, as well as other powerful companion Nginx modules and Lua libraries. It is discouraged to build this module with Nginx yourself since it is tricky to set up exactly right.Note that Nginx, LuaJIT, and OpenSSL official releases have various limitations and long standing bugs that can cause some of this module’s features to be disabled, not work properly, or run slower. Official OpenResty releases are recommended because they bundle OpenResty’s optimized LuaJIT 2.1 fork and Nginx/OpenSSL patches.

#OpenResty
[root@myorigin ~]# mkdir /root/workspace;cd /root/workspace
[root@myorigin workspace]# wget https://openresty.org/download/openresty-1.15.8.3.tar.gz
[root@myorigin workspace]# tar -zxvf openresty-1.15.8.3.tar.gz

#nginx-rtmp-module
[root@myorigin workspace]# git clone https://github.com/arut/nginx-rtmp-module.git
[root@myorigin workspace]# git clone https://github.com/arut/nginx-let-module.git

#install OpenResty with nginx-rtmp-module
[root@myorigin ~]# yum install -y gcc pcre pcre-devel openssl openssl-devel

[root@myorigin workspace]# cd /root/workspace/openresty-1.15.8.3

[root@myorigin openresty-1.15.8.3]# ./configure --add-module=../nginx-rtmp-module --add-module=../nginx-let-module -j2

[root@myorigin openresty-1.15.8.3]# make && make install

OpenResty nginx目录结构和配置文件

[root@myorigin ~]# ln -s /usr/local/openresty/nginx/conf/nginx.conf /root/nginx.conf
#nginx执行程序
[root@myorigin ~]# ln -s /usr/local/openresty/nginx/sbin/nginx /root/nginx
#ngi
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值