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.

Note For more information about how to configure on-demand recording, see On-demand recording.

Request parameters

ParameterTypeDescription
domainStringThe main streaming domain.
appStringThe name of the application to which the live stream belongs.
streamStringThe name of the live stream.
codecStringThe encoding format. Valid values:
  • h264
  • h265
vbitrateStringThe bitrate of the video. Unit: Kbit/s.

Response parameters

ParameterTypeRequiredDescription
ApiVersionStringNo

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

NeedRecordBoolYesIndicates whether recording is required.
IntervalJSONObjectNoThe duration of the recording in each format in each cycle. Valid values: 5 to 21600. Unit: seconds.
FormatJSONArrayNoThe format of the recording. The recording can be in the MP4, FLV, or M3U8 format.

Examples

Sample requests
GET /?app=seq_all&domain=demo.aliyundoc.com&stream=ondemand8&vbitrate=2000&codec=h264 HTTP/1.1
Host: example.aliyundoc.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, the operation failed to be called.

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

Usage notes

  • ApsaraVideo Live supports triggered stream pulling. If the streaming URL for a domain name is used for playback, ApsaraVideo Live is automatically triggered to pull live streams. If no live streams are played, ApsaraVideo Live does not pull live streams from the origin. In this case, automatic recording, on-demand recording, and manual recording are also disabled.