阿里云直播鉴权和直播地址算法

参数描述

要配置出正确的鉴权,需要明确以下几个参数:

  • 推流地址

    完整的推流地址,形如:rtmp://video-center.alivecdn.com/{AppName}/{StreamName}?vhost={yourdomain}

  • 鉴权类型

    阿里云CDN 兼容并支持A、B、C三种鉴权方式,具体见URL鉴权方式。这里选择的是A类型

  • 鉴权KEY

    privatekey字段用户可以自行设置

  • 时间戳

    时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数

  • 有效时间

    以秒为单位的整数时间,用来控制直播推流时效

鉴权计算

用户访问加密 URL :

rtmp://video-center.alivecdn.com/{AppName}/{StreamName}?vhost={yourdomain}&auth_key={timestamp}-{rand}-{uid}-{hashvalue}

auth_key字段描述
timestamp失效时间=时间戳+有效时间,CDN服务器拿到请求后,首先会判断请求中的失效时间是否小于当前时间,如果小于,则认为过期失效并返回HTTP 403错误。
rand随机数,一般设成0
uid暂未使用(设置成0)
hashvalue通过md5加密算法计算出的32位验证串

hashvalue 计算方式如下:

sstring = /{AppName}/{StreamName}-{timestamp}-{rand}-{uid}-{privatekey}

hashvalue = md5(sstring)

输入OBS中的鉴权内容如下:

url:rtmp://video-center.alivecdn.com/{AppName}

流密钥:{StreamName}?vhost={yourdomain}&auth_key={timestamp}-{rand}-{uid}-{hashvalue}

直播地址计算

rtmpPlayer = /{AppName}/{StreamName}-{timestamp}–{rand}-{uid}-{privatekey} 
flvPlayer = /{AppName}/{StreamName.flv}-{timestamp}–{rand}-{uid}-{privatekey} 
m3u8Player = /{AppName}/{StreamName.m3u8}-{timestamp}–{rand}-{uid}-{privatekey}

直播地址:

rtmpURL:http://{yourdomain}/{AppName}/{StreamName}?auth_key={timestamp}-{rand}-{uid}-{md5(rtmpPlayer)} 
flvURL:http://{yourdomain}/{AppName}/{StreamName.flv}?auth_key={timestamp}-{rand}-{uid}-{md5(flvPlayer)} 
m3u8URL:http://{yourdomain}/{AppName}/{StreamName.m3u8}?auth_key={timestamp}-{rand}-{uid}-{md5(m3u8Player)}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值