After you configure recording, you can determine whether to record live streams on demand.

You can implement on-demand recording by using one of the following methods:

  • Set ingest parameters. This method will be supported in the future.

  • Use an HTTP callback method.

    To implement on-demand recording by using an HTTP callback method, you must specify a callback URL and a domain name, an application, or a live stream. When the recording service receives the specified live stream or a live stream from the specified domain name or application, the recording service sends a request to the callback URL to ask whether to record the live stream. The request contains the five parameters that are described in the following table.

Request parameters

Parameter Type Description
domain String The main streaming domain.
app String The name of the application to which the live stream belongs.
stream String The name of the live stream.
codec String The encoding format. Valid values:
  • h264
  • h265
vbitrate String The bitrate of the video. Unit: Kbit/s.

Response parameters

Parameter Type Required Description
ApiVersion String No

The version of the API. The default version is 1.0.

NeedRecord Bool Yes Indicates whether recording is required.
Interval Json Object No The duration of the recording in each format in each cycle. Valid values: 5 to 21600. Unit: seconds.
Format Array No The format of the recording. The recording can be in the MP4, FLV, or M3U8 format.

Examples

Sample request
GET /?app=seq_all&domain=qt01.alivecdn.com&stream=ondemand8&vbitrate=2000&codec=h264 HTTP/1.1
Host: live.abc.com
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response parameters
{
    "ApiVersion" : "1.0",
    "NeedRecord" : true,
    "Interval" : {
        "Mp4": 300,
        "Flv": 120,
        "M3U8": 180
    },
    "Format" : ["mp4","flv"]
}

Processing of response parameters

ApsaraVideo Live uses the returned parameter settings to overwrite or modify the existing recording configuration. For example, if the Interval parameter is returned, ApsaraVideo Live uses the return value to overwrite the value of the Interval parameter in the existing recording configuration. If the Format parameter is returned, ApsaraVideo Live uses the intersection of the formats specified by the returned Format parameter and the formats specified in the existing recording configuration. If the formats specified by the returned Format parameter are not in the existing recording configuration, the live stream is not recorded.
Note
  • If a non-200 HTTP status code is returned, an error has occurred.

  • The request body cannot exceed 2,048 characters in length. Otherwise, the body is truncated to prevent malicious attacks.

Usage notes