After you complete recording configuration, 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 requests
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

The recording service compares the parameter values in the response with the parameter settings in the database and uses the comparison result to record the live stream. For example, if the value of the Interval parameter in the response is different from the value of Interval in the database, the recording service uses the value in the response to record the live stream. If the value of the Format parameter in the response and the value of Format in the database have an intersection, the recording service uses the intersection to record the live stream. If the value of the Format parameter in the response and the value of Format in the database do not have an intersection, the recording service does not record the live stream.
Note
  • If an HTTP status code other than 200 is returned, the user operation fails to be called.

  • The request body can be up to 2,048 characters in length. If the request body contains more than 2,048 characters, excess characters are truncated.