You need to enable JavaScript to run this app.
导航

生成推流地址

最近更新时间2024.03.27 17:13:23

首次发布时间2023.09.25 14:34:03

调用 GeneratePushURL 接口,生成直播推流地址。

使用说明

视频直播推流地址生成规则请参见最佳实践-生成直播地址

注意事项

请求频率:单用户请求频率限制为 25 次/秒

请求说明

  • 请求方式:POST
  • 请求地址:https://live.volcengineapi.com?Action=GeneratePushURL&Version=2023-01-01

调试

请求参数

下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数

Query

参数类型是否必选示例值描述
ActionStringGeneratePushURL接口名称。当前 API 的名称为 GeneratePushURL
VersionString2023-01-01接口版本。当前 API 的版本为 2023-01-01

Body

参数类型是否必选示例值描述
VhostStringpush.example.com域名空间,即推流域名(Domain)所属的域名空间(Vhost)。您可以调用 ListDomainDetail 接口或在视频直播控制台的域名管理页面,查看推流域名所属的域名空间。
AppStringlive应用名称,取值与直播流地址中 AppName 字段取值相同。支持由大小写字母(A - Z、a - z)、下划线(_)、短横线(-)和句点(.)组成,长度为 1 到 30 个字符。
StreamStringexample_stream流名称,取值与直播流地址中 StreamName 字段取值相同。支持由大小写字母(A - Z、a - z)、下划线(_)、短横线(-)和句点(.)组成,长度为 1 到 100 个字符。

ValidDuration

Integer

5

推流地址的有效时长,单位为秒,超过有效时长后需要重新生成。缺省情况下表示 7 天,取值范围为正整数。

说明

如果同时设置 ValidDurationExpiredTime,以 ExpiredTime 的时间为准。

ExpiredTime

String

2023-08-19T16:07:25+08:00

推流地址的过期时间,RFC3339 格式的 UTC 时间,精度为秒,过期后需要重新生成。缺省情况下表示当前时间往后的 7 天。

说明

如果同时设置 ValidDurationExpiredTime,以 ExpiredTime 的时间为准。

Domain

String

push.example.com

推流域名名称,需要推流地址的域名,不填返回Vhost下所有推流域名生成的地址。
推流域名,默认为空,表示生成域名空间下所有推流域名的推流地址。您可以调用 ListDomainDetail 接口或在视频直播控制台的域名管理页面,查看需要的推流域名。

返回参数

下表仅列出本接口特有的返回参数。更多信息请见返回结构

参数类型示例值描述
PushURLListArray of String["rtmp://push.example.com/live/example_stream"]RTMP 推流地址。
PushURLListDetailArray of PushURLListDetail-推流地址详情。
TsOverSrtURLListArray of String["srt://push.example.com:9000?streamid=#!::h=push.example.com,r=live/example_stream,m=publish"]TS over SRT 推流地址。
RtmpOverSrtURLListArray of String["rtmp://push.example.com:1999/live/example_stream"]RTMP over SRT 推流地址。
RtmURLListArray of String["http://push.example.com/live/example_stream.sdp"]RTM 推流地址。
WebTransportURLListArray of String["https://push.example.com/live/example_stream"]网络传输推流地址。

PushURLListDetail

参数类型示例值描述
URLStringrtmp://live.push.example.com/live/example_stream推流地址。
DomainAppStringrtmp://push.example.com/live/OBS 推流地址,例如,rtmp://push.example.com/live/
StreamSignStringexample_streamOBS 推流名称,例如,streamname1?volcTime=1675652376&volcSecret=c57d247c2f19b395b6ec9b182******7

请求示例

POST https://live.volcengineapi.com?Action=GeneratePushURL&Version=2023-01-01
{
  "Vhost": "push.example.com",
  "Domain": "push.example.com",
  "App": "live",
  "Stream": "example_stream",
  "ExpiredTime": "2022-08-19T16:07:25+08:00"
}

返回示例

{
  "ResponseMetadata":{
    "RequestId":"2022081915573801022524312506B8B2EA",
    "Action":"GeneratePushURL",
    "Version":"2023-01-01",
    "Service":"live",
    "Region": "cn-north-1"
  },
  "Result": {
    "PushURLList": [
      "rtmp://push.example.com/live/example_stream"
    ],
    "PushURLListDetail": [
      {
        "DomainApp": "rtmp://push.example.com/live/",
        "StreamSign": "example_stream",
        "URL": "rtmp://push.example.com/live/example_stream"
      }
    ],
    "RtmURLList": [
      "http://push.example.com/live/example_stream.sdp"
    ],
    "RtmpOverSrtURLList": [
      "rtmp://push.example.com:1999/live/example_stream"
    ],
    "TsOverSrtURLList": [
      "srt://push.example.com:9000?streamid=#!::h=push.example.com,r=live/example_stream,m=publish",
      "WebTransportURLList": ["https://push.example.com/live/example_stream"]
    ]
  } 
}

错误码

下表仅列出本接口特有的错误码。更多信息请参见公共错误码获取详细信息。

状态码错误码错误信息说明
200CommonErr-未分类错误。建议重试,如果仍返回该错误码,请联系技术支持
400InvalidParam-输入的参数无效或不符合要求,请参照请求参数说明进行检查。
400InvalidParam.BindErrorRequest parameter error, please check input data参数未通过校验,请检查参数类型是否正确。
400InvalidParam.Format%s format error参数格式错误,请检查错误消息中指定参数中是否存在非法字符或 URL 格式错误。
400InvalidParam.OutOfRange%s should be one of {[%s]}%s should be between %d and %d参数超出允许范围,请检查错误消息中指定参数的取值是否超出取值范围。
400InvalidParam.TimeLogicstartTime later than endTime, etc.传入的时间参数不符合时间逻辑,请检查是否存在以下问题。开始时间晚于结束时间过期时间早于当前时间
403RequestForbidden-请求被拒绝,当前账号下无请求的资源(域名空间、域名、应用、配置模版、证书)。
403RequestForbidden.AccountIDNotAllowthis AccountID does not have permission to access the corresponding resource, please check the request parameters请求被拒绝,当前账号下无请求的资源(域名空间、域名、应用、配置模版、证书)。
403RequestForbidden.BillingStatusBilling status is not available for the AccountID, please activate the service or recharge.未开通视频直播服务或账号欠费,造成账单不可用,请检查服务开通情况和账号欠费情况。
404ResourceNotFound-未找到资源(域名空间、域名、应用、配置模版、证书)。建议重试,如果仍返回该错误码,请联系技术支持
500InternalErroran internal error occurred, please contact the administrator.出现内部错误,请联系技术支持
500InternalError.VhostOrDomainan internal error related to vhost or domain occurred, please contact the administrator.出现与域名空间(Vhost)或域名(Domain)相关的内部错误。请联系技术支持
502InternalServiceErroran internal error occurred, please contact the administrator.服务间出现错误,请联系技术支持
502InternalServiceError.BadResponsean internal error occurred, please contact the administrator.服务间出现错误,请联系技术支持
504InternalServiceTimeoutInternal Service is timeout. please contact the administrator.内部服务超时,请联系技术支持

服务端 SDK

视频直播提供了配套的开发工具集 SDK,支持多种编程语言,帮助您更方便的调用 API。